From 297eb058cc150fea04daab3121381efa4057863d Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 14 Sep 2021 18:24:02 +0700 Subject: [PATCH] added media files import to frontend and tasks --- tubearchivist/home/templates/home/settings.html | 11 +++++++---- tubearchivist/home/views.py | 8 ++++++-- tubearchivist/static/script.js | 13 +++++++++++++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/tubearchivist/home/templates/home/settings.html b/tubearchivist/home/templates/home/settings.html index 8333b34..9fcd189 100644 --- a/tubearchivist/home/templates/home/settings.html +++ b/tubearchivist/home/templates/home/settings.html @@ -3,7 +3,7 @@

Settings

-
+ {% csrf_token %}

Color scheme

@@ -113,11 +113,14 @@

Actions

-

Rescan filesystem.

- Coming soon +

Manual media files import.

+

Add files to the cache/import folder. Make sure to follow the instructions on Github.

+
+ +
-

Manual media files import.

+

Rescan filesystem.

Coming soon
diff --git a/tubearchivist/home/views.py b/tubearchivist/home/views.py index 5c90842..b978073 100644 --- a/tubearchivist/home/views.py +++ b/tubearchivist/home/views.py @@ -30,7 +30,8 @@ from home.tasks import ( update_subscribed, download_pending, extrac_dl, - download_single + download_single, + run_manual_import ) @@ -428,7 +429,7 @@ class PostData: VALID_KEYS = [ "watched", "rescan_pending", "ignore", "dl_pending", "unsubscribe", "sort_order", "hide_watched", "show_subed_only", - "channel-search", "video-search", "dlnow" + "channel-search", "video-search", "dlnow", "manual-import" ] def __init__(self, post_dict): @@ -497,6 +498,9 @@ class PostData: youtube_id = item['status'] print('downloading: ' + youtube_id) download_single(youtube_id) + elif task == 'manual-import': + print('starting manual import') + run_manual_import.delay() return {'success': True} def search_channels(self, search_query): diff --git a/tubearchivist/static/script.js b/tubearchivist/static/script.js index 1bbe600..8f8a377 100644 --- a/tubearchivist/static/script.js +++ b/tubearchivist/static/script.js @@ -79,6 +79,19 @@ function downloadNow(button) { }, 500); } +// settings page buttons +function manualImport() { + var payload = JSON.stringify({'manual-import': true}); + console.log(payload); + sendPost(payload); + // clear button + var message = document.createElement('p'); + message.innerText = 'processing import'; + var toReplace = document.getElementById('manual-import'); + toReplace.innerHTML = ''; + toReplace.appendChild(message); +} + // player function createPlayer(button) { var mediaUrl = button.getAttribute('data-src');