Exemplo n.º 1
0
 def get(self, url):
     parsed_url = urlparse(url)
     path = parsed_url.path[1::]
     if 'video' in path:
         raise errors.ServiceError()
     try:
         if 'music/' in path:
             id = path.split('/')[-1]
             ids = id.split('_')
             o_id = ids[0]
             p_id = ids[1]
             audios = self.api.audio.get(owner_id=int(o_id),
                                         album_id=int(p_id))
         else:
             id = self.api.utils.resolveScreenName(
                 screen_name=path)['object_id']
             audios = self.api.audio.get(owner_id=id, count=6000)
         if 'count' in audios and audios['count'] > 0:
             tracks = []
             for audio in audios['items']:
                 if 'url' not in audio or not audio['url']:
                     continue
                 track = Track(url=audio['url'],
                               name='{} - {}'.format(
                                   audio['artist'], audio['title']))
                 tracks.append(track)
             if tracks:
                 return tracks
             else:
                 raise errors.NothingFoundError()
         else:
             raise errors.NothingFoundError
     except NotImplementedError as e:
         print('vk get error')
         print(e)
Exemplo n.º 2
0
 def search(self, query: str) -> List[Track]:
     tracks: List[Track] = []
     found_tracks = self.api.search(text=query, nocorrect=True,
                                    type_="all").tracks
     if found_tracks:
         for track in found_tracks.results:
             tracks.append(
                 Track(
                     service=self.name,
                     type=TrackType.Dynamic,
                     extra_info={"track_id": track.track_id},
                 ))
     found_podcast_episodes = self.api.search(
         text=query, nocorrect=True,
         type_="podcast_episode").podcast_episodes
     if found_podcast_episodes:
         for podcast_episode in found_podcast_episodes.results:
             tracks.append(
                 Track(
                     service=self.name,
                     type=TrackType.Dynamic,
                     extra_info={"track_id": podcast_episode.track_id},
                 ))
     if tracks:
         return tracks
     else:
         raise errors.NothingFoundError("")
Exemplo n.º 3
0
 def search(self, text):
     results = self.api.audio.search(q=text, count=300, sort=0)
     if 'count' in results and results['count'] > 0:
         tracks = []
         for track in results['items']:
             if 'url' not in track or not track['url']:
                 continue
             track = Track(url=track['url'],
                           name='{} - {}'.format(track['artist'],
                                                 track['title']))
             tracks.append(track)
         if tracks:
             return tracks
         else:
             raise errors.NothingFoundError()
     else:
         raise errors.NothingFoundError()
Exemplo n.º 4
0
 def search(self, text):
     search = VideosSearch(text, limit=300).result()
     if search['result']:
         tracks = []
         for video in search['result']:
             track = Track(url=video['link'], service=self)
             tracks.append(track)
         return tracks
     else:
         raise errors.NothingFoundError('')
Exemplo n.º 5
0
 def search(self, query: str) -> List[Track]:
     search = VideosSearch(query, limit=300).result()
     if search["result"]:
         tracks: List[Track] = []
         for video in search["result"]:
             track = Track(service=self.name,
                           url=video["link"],
                           type=TrackType.Dynamic)
             tracks.append(track)
         return tracks
     else:
         raise errors.NothingFoundError("")