#! /bin/python
# -*- coding:utf-8 -*-

import sqlite3,urllib,os
con = sqlite3.connect("data/data.db")
cur=con.cursor()
import cgi,sys
reload(sys)
sys.setdefaultencoding('utf-8')


html="""
<meta http-equiv="Content-style-Type" content="text/css" />
<meta http-equiv="Page-Enter" content="blendTrans(Duration=0.8)" />
<link rel="shortcut icon" href="image/favicon.ico" />
<link rel="stylesheet" href="css/common.css" type="text/css" />
<title>『PSO2』動画コンテスト2018勝手に特設サイト</title>
</head>
<body>
<div id="wrapper">
   <div id="menu">
      <h1 class="title">『PSO2』動画コンテスト2018<br>勝手に特設サイト</h1>
      <ul>
      <li><a href="index.html">特設サイトTOP</a></li>
      <li><a href="https://dodomore.tokyo">ブログへ戻る</a></li>
      
      </ul>
   </div><!-- menu end -->
   <div id="contents">
<h2>
"""
print "Content-Type: text/html;charset=UTF-8"

code1="""
<script type="application/javascript" src="https://embed.nicovideo.jp/watch/sm
"""

code2="""
/script?w=640&h=360"></script><noscript><a href="http://www.nicovideo.jp/watch/sm
"""
code3="""
"> 
"""
code4="""
 </a></noscript>
"""

qu=cgi.parse_qs(os.environ["QUERY_STRING"])

sql=u"select title from movie where id =?"
cur.execute(sql,[qu["id"][0]])
s=cur.fetchall()[0][0]

print html+s+"</h2>"
print "<center>"+code1+qu["id"][0]+code2+qu["id"][0]+code3+s+code4+"</center>"
con.close()

print """
<br>
<p><center>
<a href="javascript:history.back()">前のページに戻る</a>
</center></p>
</div><!-- contents end -->
   <div id="footer">
      designed by <a href="http://www.coolwebwindow.com/">CoolWebWindow</a> / material <a href="http://shimizumari.com/fuwa2li/">ふわふわ。り</a><br />
   </div><!-- footer end -->
</div><!-- wrapper end -->
</body>
</html>
"""