mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-04 19:30:13 +00:00
extend playlists to get all playlists of a channel and upload single playlist to index
This commit is contained in:
parent
15845da3a8
commit
bd37b653c2
@ -245,6 +245,22 @@ class YoutubeChannel:
|
|||||||
if not response.ok:
|
if not response.ok:
|
||||||
print(response.text)
|
print(response.text)
|
||||||
|
|
||||||
|
def get_all_playlists(self):
|
||||||
|
"""get all playlists owned by this channel"""
|
||||||
|
url = (
|
||||||
|
f"https://www.youtube.com/channel/{self.channel_id}"
|
||||||
|
+ "/playlists?view=1&sort=dd&shelf_id=0"
|
||||||
|
)
|
||||||
|
obs = {
|
||||||
|
"quiet": True,
|
||||||
|
"skip_download": True,
|
||||||
|
"extract_flat": True,
|
||||||
|
}
|
||||||
|
playlists = youtube_dl.YoutubeDL(obs).extract_info(url)
|
||||||
|
all_entries = [(i["id"], i["title"]) for i in playlists["entries"]]
|
||||||
|
|
||||||
|
return all_entries
|
||||||
|
|
||||||
|
|
||||||
class YoutubeVideo:
|
class YoutubeVideo:
|
||||||
"""represents a single youtube video"""
|
"""represents a single youtube video"""
|
||||||
@ -503,6 +519,16 @@ class YoutubePlaylist:
|
|||||||
|
|
||||||
return all_members
|
return all_members
|
||||||
|
|
||||||
|
def upload_to_es(self):
|
||||||
|
"""add playlist to es with its entries"""
|
||||||
|
playlist = self.get_playlist_dict()
|
||||||
|
playlist["playlist_entries"] = self.get_entries()
|
||||||
|
|
||||||
|
url = f"{self.ES_URL}/ta_playlist/_doc/{self.playlist_id}"
|
||||||
|
response = requests.put(url, json=playlist, auth=self.ES_AUTH)
|
||||||
|
if not response.ok:
|
||||||
|
print(response.text)
|
||||||
|
|
||||||
|
|
||||||
class WatchState:
|
class WatchState:
|
||||||
"""handle watched checkbox for videos and channels"""
|
"""handle watched checkbox for videos and channels"""
|
||||||
|
Loading…
Reference in New Issue
Block a user