diff --git a/ydl_server/jobshandler.py b/ydl_server/jobshandler.py
index 67dd23b0..0b692a75 100644
--- a/ydl_server/jobshandler.py
+++ b/ydl_server/jobshandler.py
@@ -32,3 +32,6 @@ def worker(dl_queue):
dl_queue.put((Actions.DOWNLOAD, job))
queue.task_done()
+def join():
+ if thread is not None:
+ return thread.join()
diff --git a/ydl_server/static/js/youtubedl.js b/ydl_server/static/js/youtubedl.js
index c9618b15..b51f0c70 100644
--- a/ydl_server/static/js/youtubedl.js
+++ b/ydl_server/static/js/youtubedl.js
@@ -88,6 +88,19 @@ function get_download_logs(){
});
}
+function get_finished_files(){
+ $.getJSON("api/finished", function (data) {
+ let finished_files = "";
+ $.each(data.files, function(key, file) {
+ finished_files += "
";
+ finished_files += "" + file.name + " | ";
+ finished_files += "" + (new Date(file.modified)).toISOString() + " | ";
+ finished_files += "
";
+ });
+ $("#finished_files").html(finished_files);
+ });
+}
+
function hide_logs_detail(){
$('td:nth-child(6),th:nth-child(6)').hide();
}
diff --git a/ydl_server/templates/finished.html b/ydl_server/templates/finished.html
new file mode 100644
index 00000000..6c0af52b
--- /dev/null
+++ b/ydl_server/templates/finished.html
@@ -0,0 +1,88 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ youtube-dl - done
+
+
+
+
+
+
+
+
+
+
+
Finished Files
+
+
+
+
+
+ Name |
+ Date |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ydl_server/templates/index.html b/ydl_server/templates/index.html
index 674b986b..fb6a9d62 100644
--- a/ydl_server/templates/index.html
+++ b/ydl_server/templates/index.html
@@ -26,6 +26,9 @@
Logs
+
+ Finished
+
-
diff --git a/ydl_server/templates/logs.html b/ydl_server/templates/logs.html
index 31ff96f6..38f9318a 100644
--- a/ydl_server/templates/logs.html
+++ b/ydl_server/templates/logs.html
@@ -26,6 +26,9 @@
-
Logs
+ -
+ Finished
+
-
diff --git a/ydl_server/ydlhandler.py b/ydl_server/ydlhandler.py
index 2030e8cc..cfbcca39 100644
--- a/ydl_server/ydlhandler.py
+++ b/ydl_server/ydlhandler.py
@@ -135,4 +135,6 @@ def resume_pending():
job.id = pending["id"]
jobshandler.put((Actions.RESUME, job))
-
+def join():
+ if thread is not None:
+ return thread.join()
diff --git a/youtube-dl-server.py b/youtube-dl-server.py
index b81c9e7d..f316e345 100644
--- a/youtube-dl-server.py
+++ b/youtube-dl-server.py
@@ -2,6 +2,8 @@
import json
import os
from collections import ChainMap
+from itertools import chain
+from operator import itemgetter
from queue import Queue
from bottle import route, run, Bottle, request, static_file
from threading import Thread
@@ -22,6 +24,28 @@ def front_index():
def front_logs():
return static_file('templates/logs.html', root='./ydl_server')
+@app.route('/finished')
+def front_finished():
+ return static_file('templates/finished.html', root='./ydl_server')
+
+@app.route('/api/finished')
+def api_list_finished():
+ root_dir = Path(app_vars['YDL_OUTPUT_TEMPLATE']).parent
+ matches = chain(root_dir.glob('*'), root_dir.glob('*/*'))
+ files = [{
+ 'name': f.relative_to(root_dir).as_posix(),
+ 'modified': f.stat().st_mtime * 1000,
+ } for f in matches if not f.name.startswith('.') and f.is_file()]
+ files = sorted(files, key=itemgetter('modified'), reverse=True)
+ return {
+ "success": True,
+ "files": files
+ }
+
+@app.route('/api/finished/:filename#.*#')
+def api_serve_finished_file(filename):
+ root_dir = Path(app_vars['YDL_OUTPUT_TEMPLATE']).parent
+ return static_file(filename, root=root_dir)
@app.route('/static/:filename#.*#')
def server_static(filename):
@@ -92,5 +116,5 @@ def ydl_update():
debug=app_vars['YDL_DEBUG'])
ydlhandler.finish()
jobshandler.finish()
-ydlhandler.thread.join()
-jobshandler.thread.join()
+ydlhandler.join()
+jobshandler.join()