mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-12-23 02:10:15 +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
|
||||
def subscribe_to(url_str):
|
||||
"""take a list of urls to subscribe to"""
|
||||
youtube_ids = UrlListParser(url_str).process_list()
|
||||
for youtube_id in youtube_ids:
|
||||
if youtube_id["type"] == "video":
|
||||
to_sub = youtube_id["url"]
|
||||
vid_details = PendingList().get_youtube_details(to_sub)
|
||||
to_subscribe_list = UrlListParser(url_str).process_list()
|
||||
for item in to_subscribe_list:
|
||||
to_sub_id = item["url"]
|
||||
if item["type"] == "playlist":
|
||||
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"]
|
||||
elif youtube_id["type"] == "channel":
|
||||
channel_id_sub = youtube_id["url"]
|
||||
elif item["type"] == "channel":
|
||||
channel_id_sub = to_sub_id
|
||||
else:
|
||||
raise ValueError("failed to subscribe to: " + youtube_id)
|
||||
raise ValueError("failed to subscribe to: " + to_sub_id)
|
||||
|
||||
ChannelSubscription().change_subscribe(
|
||||
channel_id_sub, channel_subscribed=True
|
||||
)
|
||||
print("subscribed to: " + channel_id_sub)
|
||||
# notify
|
||||
RedisArchivist().set_message(
|
||||
"progress:subscribe", {"status": "subscribing"}
|
||||
@ -247,16 +252,3 @@ def index_channel_playlists(channel_id):
|
||||
handler = ThumbManager()
|
||||
missing_playlists = handler.get_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_restore_backup,
|
||||
subscribe_to,
|
||||
subscribe_to_playlist,
|
||||
update_subscribed,
|
||||
)
|
||||
|
||||
@ -827,7 +826,7 @@ class PlaylistView(View):
|
||||
if subscribe_form.is_valid():
|
||||
url_str = request.POST.get("subscribe")
|
||||
print(url_str)
|
||||
subscribe_to_playlist.delay(url_str)
|
||||
subscribe_to.delay(url_str)
|
||||
|
||||
sleep(1)
|
||||
return redirect("playlist")
|
||||
|
Loading…
Reference in New Issue
Block a user