mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-22 20:00:15 +00:00
better error handeling in add to download form
This commit is contained in:
parent
ef3447cbfb
commit
214a248821
@ -46,6 +46,9 @@ def process_url_list(url_str):
|
|||||||
url_list = re.split("\n+", url_str[0])
|
url_list = re.split("\n+", url_str[0])
|
||||||
youtube_ids = []
|
youtube_ids = []
|
||||||
for url in url_list:
|
for url in url_list:
|
||||||
|
if "/c/" in url or "/user/" in url:
|
||||||
|
raise ValueError("user name is not unique, use channel ID")
|
||||||
|
|
||||||
url_clean = url.strip().strip("/").split("/")[-1]
|
url_clean = url.strip().strip("/").split("/")[-1]
|
||||||
for i in to_replace:
|
for i in to_replace:
|
||||||
url_clean = url_clean.replace(i, "")
|
url_clean = url_clean.replace(i, "")
|
||||||
|
@ -195,16 +195,16 @@ class DownloadView(View):
|
|||||||
download_post = dict(request.POST)
|
download_post = dict(request.POST)
|
||||||
if "vid-url" in download_post.keys():
|
if "vid-url" in download_post.keys():
|
||||||
url_str = download_post["vid-url"]
|
url_str = download_post["vid-url"]
|
||||||
print("adding to queue")
|
try:
|
||||||
youtube_ids = process_url_list(url_str)
|
youtube_ids = process_url_list(url_str)
|
||||||
if not youtube_ids:
|
except ValueError:
|
||||||
# failed to process
|
# failed to process
|
||||||
print(url_str)
|
print(f"failed to parse: {url_str}")
|
||||||
mess_dict = {
|
mess_dict = {
|
||||||
"status": "downloading",
|
"status": "downloading",
|
||||||
"level": "error",
|
"level": "error",
|
||||||
"title": "Failed to extract links.",
|
"title": "Failed to extract links.",
|
||||||
"message": "",
|
"message": "Not a video, channel or playlist ID or URL",
|
||||||
}
|
}
|
||||||
set_message("progress:download", mess_dict)
|
set_message("progress:download", mess_dict)
|
||||||
return redirect("downloads")
|
return redirect("downloads")
|
||||||
|
Loading…
Reference in New Issue
Block a user