-
Notifications
You must be signed in to change notification settings - Fork 2
/
player.py
executable file
·163 lines (141 loc) · 5.68 KB
/
player.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
from __future__ import unicode_literals
from bottle import route, run
import json
import pymssql
from azure.storage.blob import AppendBlobService
import os
from multiprocessing import Process, Queue
append_blob_service = AppendBlobService(account_name='asqdata', account_key='FB9fAfnEv1uokM0KZmEbC38EFpxBESFCJKboqQaxSysTudNsRsHTB0HHDv4eSqUV2RUUK7RR9WiplPn0C07LZw==')
html1 = """<!DOCTYPE html>
<html>
<head>
<title>"""
html2 = """</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="/static/content/player.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
</head>
<body>
<header>
<div class="container">
<div class="row">
<div class="col-md-8">
<h1><a href="/home" class="logo">Parrot</a></h1>
</div>
<div class="col-md-4">
<div class="searchBox">
<div class="input-group">
<input type="text" class="form-control" id="search" placeholder="What do you want to learn?">
<span class="input-group-btn">
<button class="btn btn-default" id="go-btn" type="button" onclick="go_search();">Go</button>
</span>
</div>
</div>
</div>
</div>
</div>
</header>
<br>
<div class="container" id="player">
<h2>"""
html3 = """</h2>
<br>
<div class="row">
<div class="col-md-3" id="left">
<div class="concept">
<h4>Concepts</h4>
<ul>"""
html4 = """ </ul>
</div>
<hr>
<div class="info">
<p><strong>Author: </strong>"""
html5 = """</p>
<p><strong>Course: </strong>"""
html6 = """</p>
<p><strong>School: </strong>"""
html7 = """</p>
<p><strong>Category: </strong>"""
html8 = """</p>
</div>
</div>
<div class="col-md-9" id="right">
<div class="video-container">
<video width="100%" id="video" controls>
<source src=\""""
html9 = """\" type="video/mp4">
Your browser is currently not compatible, please use the newest version of Google Chrome.
</video>
</div>
<br>
<div class="description">
<p><strong>Description:</strong> <br>"""
html10 = """</p>
</div>
<br><br>
</div>
</div>
</div>
<br>
<div class="footer">
<footer>
<div class="container">
<h3>About</h3>
<p>Parrot is brought to you by Ruizhe Li, Ruoxi Li, and Shengyi Chen</p>
<p>Parrot provides students with an efficient and streamlined way to refresh their memory with important concepts. Students can search for and upload lecture recordings, search any keyword or concept in the recordings, or discover new content to satisfy their intellectual needs. Parrot will take the student to that moment in the lecture with clinical precision. </p><p>
<b>Disclaimer: All videos from this site are from YouTube. All rights belong to the original creaters/publishers of these videos. All videos are used for demo purpose only. The site is not intended for any commercial usage. The videos will be deleted immediately once the demo ends. </b>
</p> </div>
</footer>
</div>
<script src="/static/scripts/player.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</body>
</html>"""
def get_files(title):
key_time_map_file = open(os.path.join('transcripts', title.split('.')[0] + '.json'),'r')
key_time_map = json.load(key_time_map_file)
key_time_map_file.close()
server = 'tcp:asq-file.database.windows.net'
database = 'asq-file'
username = 'ruizheli@asq-file'
password = 'Fzj990418.'
driver= '{ODBC Driver 13 for SQL Server}'
# pyodbc part, for deploying only
# conn = pyodbc.connect('DRIVER='+driver+';PORT=1433;SERVER='+server+';PORT=1443;DATABASE='+database+';UID='+username+';PWD='+ password)
# pymssql part, for testing only
conn = pymssql.connect(server='asq-file.database.windows.net',user='[email protected]', password='Fzj990418.', database='asq-file', tds_version='7.0')
temp_file_name = title
video_pwd = 'https://asqdata.blob.core.windows.net/media-file/' + title.split('.')[0]
print(title)
# logics for uploading
cursor = conn.cursor()
query = """SELECT * FROM [dbo].[asq_file] WHERE file_name=\'%s\'"""
print(query % (str(title.split('.')[0]),))
cursor.execute(query % (str(title.split('.')[0]),))
result = cursor.next()
title = str(result[0])
tags = str(result[2])
education = str(result[8])
user = str(result[1])
abstract = str(result[3])
category = str(result[4])
course = str(result[9])
return (title, key_time_map,education,user,course,abstract,category, video_pwd)
@route('/player/<title:re:[\w\-]+>/<type:re:[\w\-]+>/<keys:re:((\w+\+)*)?\w+>')
def player(title, type, keys):
s1 = """<li class="jump"><a href="#" onclick="jumpToTime("""
s2 = """)">"""
s3 = """</a></li>"""
s_html = ""
(title, key_time_map,education,user,course,abstract,category,video_pwd) = get_files(title + '.' + type)
keys = keys.split("+")
for k in keys:
for i in key_time_map[k]:
m, s = divmod(i[0], 60)
h, m = divmod(m, 60)
time = "%d:%02d:%02d" % (h, m, s)
s = s1 + str(int(i[0])) +s2 + k + " (" + time + ")" + s3
s_html += s
html = html1 + title + html2 + title + html3 + s_html + html4 + user + html5 + course + html6 + education + html7 + category + html8 + video_pwd + html9 +abstract +html10
return html