From 4f35b5b3a6c860672984d405b8e68807b7b1ea9e Mon Sep 17 00:00:00 2001 From: kmb32123 Date: Sat, 19 Sep 2015 11:12:38 -0500 Subject: [PATCH] style(*): bootstrapify --- index.html | 56 +++++++++++++++ static/style.css | 157 +++++++++++++++++++++++++++++++++++++++++++ youtube-dl-server.py | 24 +++---- 3 files changed, 224 insertions(+), 13 deletions(-) create mode 100644 index.html create mode 100644 static/style.css diff --git a/index.html b/index.html new file mode 100644 index 00000000..e096f483 --- /dev/null +++ b/index.html @@ -0,0 +1,56 @@ + + + + + + + + + + + + + youtube-dl + + + + + + + +
+
+
+ +
+

youtube-dl

+

Enter a video url to download the video to the server. Url can be to YouTube or any other supported site. The server will automatically download the highest quality version available.

+
+
+
+ + + + +
+
+
+
+ +
+
+

Web frontend for youtube-dl, by @manbearwiz.

+
+
+ +
+
+
+ + + + + + diff --git a/static/style.css b/static/style.css new file mode 100644 index 00000000..5faea3a6 --- /dev/null +++ b/static/style.css @@ -0,0 +1,157 @@ +/* + * Globals + */ + + +/* Links */ + +a, a:focus, a:hover { + color: #fff; +} +.lead a { + color: #268bd2; +} + +/* Custom default button */ + +.btn-default, .btn-default:hover, .btn-default:focus { + color: #333; + text-shadow: none; + /* Prevent inheritence from `body` */ + background-color: #fff; + border: 1px solid #fff; +} + +/* + * Base structure + */ + +html, body { + height: 100%; + background-color: #002b36; +} +body { + color: #fff; + text-align: center; + text-shadow: 0 1px 3px rgba(0, 0, 0, .5); +} + +/* Extra markup and styles for table-esque vertical and horizontal centering */ + +.site-wrapper { + display: table; + width: 100%; + height: 100%; + /* For at least Firefox */ + min-height: 100%; + -webkit-box-shadow: inset 0 0 100px rgba(0, 0, 0, .5); + box-shadow: inset 0 0 100px rgba(0, 0, 0, .5); +} +.site-wrapper-inner { + display: table-cell; + vertical-align: top; +} +.cover-container { + margin-right: auto; + margin-left: auto; +} + +/* Padding for spacing */ + +.inner { + padding: 30px; +} + +/* + * Header + */ + +.masthead-brand { + margin-top: 10px; + margin-bottom: 10px; +} +.masthead-nav > li { + display: inline-block; +} +.masthead-nav > li + li { + margin-left: 20px; +} +.masthead-nav > li > a { + padding-right: 0; + padding-left: 0; + font-size: 16px; + font-weight: bold; + color: #fff; + /* IE8 proofing */ + color: rgba(255, 255, 255, .75); + border-bottom: 2px solid transparent; +} +.masthead-nav > li > a:hover, .masthead-nav > li > a:focus { + background-color: transparent; + border-bottom-color: #a9a9a9; + border-bottom-color: rgba(255, 255, 255, .25); +} +.masthead-nav > .active > a, .masthead-nav > .active > a:hover, .masthead-nav > .active > a:focus { + color: #fff; + border-bottom-color: #fff; +} +@media (min-width: 768px) { + .masthead-brand { + float: left; + } + .masthead-nav { + float: right; + } +} + +/* + * Cover + */ + +.cover { + padding: 0 20px; +} +.cover .btn-lg { + padding: 10px 20px; + font-weight: bold; +} + +/* + * Footer + */ + +.mastfoot { + color: #999; + /* IE8 proofing */ + color: rgba(255, 255, 255, .5); +} + +/* + * Affix and center + */ + +@media (min-width: 768px) { + /* Pull out the header and footer */ + .masthead { + position: fixed; + top: 0; + } + .mastfoot { + position: fixed; + bottom: 0; + } + /* Start the vertical centering */ + .site-wrapper-inner { + vertical-align: middle; + } + /* Handle the widths */ + .masthead, .mastfoot, .cover-container { + width: 100%; + /* Must be percentage or pixels for horizontal alignment */ + } +} +@media (min-width: 992px) { + .masthead, .mastfoot, .cover-container { + width: 700px; + } +} diff --git a/youtube-dl-server.py b/youtube-dl-server.py index 4bb7237f..d7f95c1d 100644 --- a/youtube-dl-server.py +++ b/youtube-dl-server.py @@ -2,20 +2,18 @@ import os import subprocess from queue import Queue -from bottle import route, run, Bottle, request +from bottle import route, run, Bottle, request, static_file from threading import Thread app = Bottle() @app.route('/youtube-dl') def dl_queue_list(): - print("bar") - return ''' -
- URL: - -
- ''' + return static_file('index.html', root='./') + +@app.route('/youtube-dl/static/:filename#.*#') +def server_static(filename): + return static_file(filename, root='./static') @app.route('/youtube-dl/q', method='GET') def q_size(): @@ -30,19 +28,19 @@ def q_put(): return { "success" : True, "url" : url } else: return { "success" : False, "error" : "dl called without a url" } - + def dl_worker(): while not done: - item = dl_q.get() + item = dl_q.get() download(item) dl_q.task_done() - + def download(url): print("Starting download of " + url) command = """youtube-dl -o "/youtube-dl/.incomplete/%(title)s.%(ext)s" -f best[acodec=none][ext=mp4]+best[vcodec=none][ext=m4a] --exec 'touch {} && mv {} /youtube-dl/' --merge-output-format mp4 """ + url - print("Finished downloading " + url) subprocess.call(command, shell=True) - + print("Finished downloading " + url) + dl_q = Queue(); done = False; dl_thread = Thread(target=dl_worker)