async def youtube_playlist(self, url: str) -> List[Song]: """ Extract information from YouTube by Playlist url @param url: @return: """ url = VariableStore.youtube_url_to_id(url) node: Node = self.node_controller.get_best_node() response = await node.client.request("youtube_playlist", url, response=True, timeout=10) if not response.successful: raise PlaylistExtractionException() songs = [] for track in json.loads(response.text): song = Song() song.title = track["title"] song.link = track["link"] songs.append(song) return songs
async def extract_first_infos_spotify(self, url, ctx): spotify_type = Url.determine_spotify_type(url=url) __songs = [] __song = Song() __song.user = ctx.message.author if spotify_type == Url.spotify_playlist: __song_list = await self.parent.spotify.spotify_playlist(url) if len(__song_list) == 0: await self.parent.send_error_message( ctx=ctx, message=Errors.spotify_pull) return [] for track in __song_list: track: SpotifySong __song = Song(song=__song) __song.title = track.title __song.image_url = track.image_url __song.artist = track.artist __song.song_name = track.song_name __songs.append(__song) return __songs if spotify_type == Url.spotify_track: track = await self.parent.spotify.spotify_track(url) if track is not None: __song.title = track.title __song.image_url = track.image_url __song.artist = track.artist __song.song_name = track.song_name return [__song] return [] if spotify_type == Url.spotify_artist: song_list = await self.parent.spotify.spotify_artist(url) for track in song_list: __song = Song(song=__song) __song.title = track __songs.append(__song) return __songs if spotify_type == Url.spotify_album: song_list = await self.parent.spotify.spotify_album(url) for track in song_list: __song = Song(song=__song) __song.title = track __songs.append(__song) return __songs
async def extract_first_infos_other(self, url, ctx): if url == "charts": __songs = [] __song = Song() __song.user = ctx.message.author song_list = await self.extract_first_infos_spotify( "https://open.spotify.com/playlist/37i9dQZEVXbMDoHDwVN2tF?si=vgYiEOfYTL-ejBdn0A_E2g", ctx, ) for track in song_list: track.user = ctx.message.author __songs.append(track) return __songs __song = Song() __song.title = url __song.user = ctx.message.author return [__song]
async def youtube_playlist(self, url): url = VariableStore.youtube_url_to_id(url) node = self.node_controller.get_best_node() sd = await self.http_post( url=self.playlist_url.format(node.ip, node.port), data=url ) if isinstance(sd, Error): return [] songs = [] for t in json.loads(sd): s = Song() s.title = t["title"] s.link = t["link"] songs.append(s) return songs