From adafa985683d50b010defdd2fd01be5a70462ff5 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 10 Sep 2021 15:21:46 +0700 Subject: [PATCH] immediate feedback when adding long lists to queue --- tubearchivist/home/src/download.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/tubearchivist/home/src/download.py b/tubearchivist/home/src/download.py index 0631ddc..587f66a 100644 --- a/tubearchivist/home/src/download.py +++ b/tubearchivist/home/src/download.py @@ -32,6 +32,15 @@ class PendingList: """ extract youtube ids from list """ missing_videos = [] for entry in youtube_ids: + # notify + mess_dict = { + "status": "pending", + "level": "info", + "title": "Adding to download queue.", + "message": 'Extracting lists' + } + set_message('progress:download', mess_dict) + # extract url = entry['url'] url_type = entry['type'] if url_type == 'video': @@ -78,20 +87,20 @@ class PendingList: action = {"create": {"_id": youtube_id, "_index": "ta_download"}} bulk_list.append(json.dumps(action)) bulk_list.append(json.dumps(video)) + # notify + mess_dict = { + "status": "pending", + "level": "info", + "title": "Adding to download queue.", + "message": 'Processing IDs...' + } + set_message('progress:download', mess_dict) # add last newline bulk_list.append('\n') query_str = '\n'.join(bulk_list) headers = {'Content-type': 'application/x-ndjson'} url = self.ES_URL + '/_bulk' request = requests.post(url, data=query_str, headers=headers) - # notify - mess_dict = { - "status": "pending", - "level": "info", - "title": "Adding to download queue.", - "message": 'Processing IDs...' - } - set_message('progress:download', mess_dict) if not request.ok: print(request)