mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-04 19:30:13 +00:00
consolidate subscribe to single task for channel and playlist
This commit is contained in:
parent
2ebd0a3e2f
commit
bad129d630
@ -196,21 +196,26 @@ def re_sync_thumbs():
|
|||||||
@shared_task
|
@shared_task
|
||||||
def subscribe_to(url_str):
|
def subscribe_to(url_str):
|
||||||
"""take a list of urls to subscribe to"""
|
"""take a list of urls to subscribe to"""
|
||||||
youtube_ids = UrlListParser(url_str).process_list()
|
to_subscribe_list = UrlListParser(url_str).process_list()
|
||||||
for youtube_id in youtube_ids:
|
for item in to_subscribe_list:
|
||||||
if youtube_id["type"] == "video":
|
to_sub_id = item["url"]
|
||||||
to_sub = youtube_id["url"]
|
if item["type"] == "playlist":
|
||||||
vid_details = PendingList().get_youtube_details(to_sub)
|
new_thumbs = PlaylistSubscription().process_url_str([item])
|
||||||
|
if new_thumbs:
|
||||||
|
ThumbManager().download_playlist(new_thumbs)
|
||||||
|
continue
|
||||||
|
|
||||||
|
if item["type"] == "video":
|
||||||
|
vid_details = PendingList().get_youtube_details(to_sub_id)
|
||||||
channel_id_sub = vid_details["channel_id"]
|
channel_id_sub = vid_details["channel_id"]
|
||||||
elif youtube_id["type"] == "channel":
|
elif item["type"] == "channel":
|
||||||
channel_id_sub = youtube_id["url"]
|
channel_id_sub = to_sub_id
|
||||||
else:
|
else:
|
||||||
raise ValueError("failed to subscribe to: " + youtube_id)
|
raise ValueError("failed to subscribe to: " + to_sub_id)
|
||||||
|
|
||||||
ChannelSubscription().change_subscribe(
|
ChannelSubscription().change_subscribe(
|
||||||
channel_id_sub, channel_subscribed=True
|
channel_id_sub, channel_subscribed=True
|
||||||
)
|
)
|
||||||
print("subscribed to: " + channel_id_sub)
|
|
||||||
# notify
|
# notify
|
||||||
RedisArchivist().set_message(
|
RedisArchivist().set_message(
|
||||||
"progress:subscribe", {"status": "subscribing"}
|
"progress:subscribe", {"status": "subscribing"}
|
||||||
@ -247,16 +252,3 @@ def index_channel_playlists(channel_id):
|
|||||||
handler = ThumbManager()
|
handler = ThumbManager()
|
||||||
missing_playlists = handler.get_missing_playlists()
|
missing_playlists = handler.get_missing_playlists()
|
||||||
handler.download_playlist(missing_playlists)
|
handler.download_playlist(missing_playlists)
|
||||||
|
|
||||||
|
|
||||||
@shared_task
|
|
||||||
def subscribe_to_playlist(url_str):
|
|
||||||
"""process url string to subscribe to playlists"""
|
|
||||||
RedisArchivist().set_message(
|
|
||||||
"progress:subscribe", {"status": "subscribing"}
|
|
||||||
)
|
|
||||||
new_playlists = UrlListParser(url_str).process_list()
|
|
||||||
|
|
||||||
new_thumbs = PlaylistSubscription().process_url_str(new_playlists)
|
|
||||||
if new_thumbs:
|
|
||||||
ThumbManager().download_playlist(new_thumbs)
|
|
||||||
|
@ -52,7 +52,6 @@ from home.tasks import (
|
|||||||
run_manual_import,
|
run_manual_import,
|
||||||
run_restore_backup,
|
run_restore_backup,
|
||||||
subscribe_to,
|
subscribe_to,
|
||||||
subscribe_to_playlist,
|
|
||||||
update_subscribed,
|
update_subscribed,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -827,7 +826,7 @@ class PlaylistView(View):
|
|||||||
if subscribe_form.is_valid():
|
if subscribe_form.is_valid():
|
||||||
url_str = request.POST.get("subscribe")
|
url_str = request.POST.get("subscribe")
|
||||||
print(url_str)
|
print(url_str)
|
||||||
subscribe_to_playlist.delay(url_str)
|
subscribe_to.delay(url_str)
|
||||||
|
|
||||||
sleep(1)
|
sleep(1)
|
||||||
return redirect("playlist")
|
return redirect("playlist")
|
||||||
|
Loading…
Reference in New Issue
Block a user