diff --git a/tubearchivist/home/tasks.py b/tubearchivist/home/tasks.py
index fee59862..66a9c58f 100644
--- a/tubearchivist/home/tasks.py
+++ b/tubearchivist/home/tasks.py
@@ -25,6 +25,7 @@ from home.src.index.reindex import Reindex, ReindexManual, ReindexPopulate
from home.src.ta.config import AppConfig, ReleaseVersion, ScheduleBuilder
from home.src.ta.ta_redis import RedisArchivist
from home.src.ta.task_manager import TaskManager
+from home.src.ta.urlparser import Parser
CONFIG = AppConfig().config
REDIS_HOST = os.environ.get("REDIS_HOST")
@@ -196,7 +197,12 @@ def download_pending(self, auto_only=False):
def extrac_dl(self, youtube_ids, auto_start=False):
"""parse list passed and add to pending"""
TaskManager().init(self)
- pending_handler = PendingList(youtube_ids=youtube_ids, task=self)
+ if isinstance(youtube_ids, str):
+ to_add = Parser(youtube_ids).parse()
+ else:
+ to_add = youtube_ids
+
+ pending_handler = PendingList(youtube_ids=to_add, task=self)
pending_handler.parse_url_list()
pending_handler.add_to_pending(auto_start=auto_start)
diff --git a/tubearchivist/home/templates/home/downloads.html b/tubearchivist/home/templates/home/downloads.html
index 35ed3d91..a1d9be29 100644
--- a/tubearchivist/home/templates/home/downloads.html
+++ b/tubearchivist/home/templates/home/downloads.html
@@ -20,10 +20,10 @@
Add to download queue
-
diff --git a/tubearchivist/home/views.py b/tubearchivist/home/views.py
index 9f891c48..142c6bc8 100644
--- a/tubearchivist/home/views.py
+++ b/tubearchivist/home/views.py
@@ -41,8 +41,7 @@ from home.src.index.video_constants import VideoTypeEnum
from home.src.ta.config import AppConfig, ReleaseVersion, ScheduleBuilder
from home.src.ta.helper import time_parser
from home.src.ta.ta_redis import RedisArchivist
-from home.src.ta.urlparser import Parser
-from home.tasks import extrac_dl, index_channel_playlists, subscribe_to
+from home.tasks import index_channel_playlists, subscribe_to
from rest_framework.authtoken.models import Token
@@ -368,7 +367,7 @@ class AboutView(MinView):
class DownloadView(ArchivistResultsView):
"""resolves to /download/
- takes POST for downloading youtube links
+ handle the download queue
"""
view_origin = "downloads"
@@ -452,34 +451,6 @@ class DownloadView(ArchivistResultsView):
return buckets_sorted
- @staticmethod
- def post(request):
- """handle post requests"""
- to_queue = AddToQueueForm(data=request.POST)
- if to_queue.is_valid():
- url_str = request.POST.get("vid_url")
- print(url_str)
- try:
- youtube_ids = Parser(url_str).parse()
- except ValueError:
- # failed to process
- key = "message:add"
- print(f"failed to parse: {url_str}")
- mess_dict = {
- "status": key,
- "level": "error",
- "title": "Failed to extract links.",
- "message": "Not a video, channel or playlist ID or URL",
- }
- RedisArchivist().set_message(key, mess_dict, expire=True)
- return redirect("downloads")
-
- print(youtube_ids)
- extrac_dl.delay(youtube_ids)
-
- sleep(2)
- return redirect("downloads", permanent=True)
-
class ChannelIdBaseView(ArchivistResultsView):
"""base class for all channel-id views"""
diff --git a/tubearchivist/static/script.js b/tubearchivist/static/script.js
index 5df3f08b..59161447 100644
--- a/tubearchivist/static/script.js
+++ b/tubearchivist/static/script.js
@@ -160,6 +160,20 @@ function dlPending() {
}, 500);
}
+function addToQueue() {
+ let textArea = document.getElementById('id_vid_url');
+ if (textArea.value === '') {
+ return
+ }
+ let toPost = {data: [{youtube_id: textArea.value, status: 'pending'}]};
+ let apiEndpoint = '/api/download/';
+ apiRequest(apiEndpoint, 'POST', toPost);
+ textArea.value = "";
+ setTimeout(function () {
+ checkMessages();
+ }, 500);
+}
+
function toIgnore(button) {
let youtube_id = button.getAttribute('data-id');
let apiEndpoint = '/api/download/' + youtube_id + '/';