Beispiel #1
0
    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
Beispiel #2
0
 async def extract_first_infos_youtube(self, url, ctx):
     youtube_type = Url.determine_youtube_type(url=url)
     if youtube_type == Url.youtube_url:
         __song = Song()
         __song.user = ctx.message.author
         __song.link = url
         return [__song]
     if youtube_type == Url.youtube_playlist:
         __songs = []
         __song_list = await self.parent.youtube.youtube_playlist(url)
         if len(__song_list) == 0:
             await self.parent.send_error_message(ctx, Errors.spotify_pull)
             return []
         for track in __song_list:
             track.user = ctx.message.author
             __songs.append(track)
         return __songs
Beispiel #3
0
    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