Exemplo n.º 1
0
 def set_similiar_artists(self):
     if int(common.limit_artists()) <= 50 or not self.similar_artists:
         common.limit_artists(int(common.limit_artists())+5)
         self.similar_artists = lastfm.get_similar_artists(self.last_artist)
     elif int(common.limit_artists()) > 50:
         self.similar_artists = lastfm.get_similar_artists(self.last_artist)
         if self.similar_artists:
             self.last_artist = self.similar_artists[random.randint(0,(len(self.similar_artists)-1))]
Exemplo n.º 2
0
 def set_similiar_artists(self):
     if int(common.limit_artists()) <= 50 or not self.similar_artists:
         common.limit_artists(int(common.limit_artists()) + 5)
         self.similar_artists = lastfm.get_similar_artists(self.last_artist)
     elif int(common.limit_artists()) > 50:
         self.similar_artists = lastfm.get_similar_artists(self.last_artist)
         if self.similar_artists:
             self.last_artist = self.similar_artists[random.randint(
                 0, (len(self.similar_artists) - 1))]
Exemplo n.º 3
0
def get_similar_artists(artist):
    n = '100'
    value = cache.get_value(artist, n, lastfm=True)
    if value == None:
        value = []
        try:
            params = {
                'method': 'artist.getsimilar',
                'artist': artist,
                'autocorrect': '1',
                'limit': n,
                'api_key': api_key,
                'format': 'json'
            }
            json_data = requests.get(api_url, params=params).json()
            for item in json_data['similarartists']['artist']:
                value.append(item['name'])
            cache.save_value(artist, n, value, lastfm=True)
        except:
            pass
    similar_artists = []
    for s in value:
        similar_artists.append(s)
        if len(similar_artists) == int(common.limit_artists()):
            break
    return similar_artists
Exemplo n.º 4
0
 def playArtist(self, artist):
     self.is_active = True
     common.process_true()
     common.limit_artists(common.limit_result())
     self.similar_artists = []
     self.ignore_list = []
     self.video_list = []
     self.genre_list = lastfm.get_artist_genre(artist)
     self.start_artist = artist
     self.last_artist = self.start_artist
     self.artist = artist
     self.set_resume_point()
     self.playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
     self.clear_playlist()
     self.add_video(artist)
     self.play(self.playlist)
Exemplo n.º 5
0
 def add_video(self, artist=False):
     common.log('[mvmixPlayer] add video')
     video_url = None
     loops = 0
     if not artist:
         self.similar_artists = lastfm.get_similar_artists(self.artist)
     while not video_url and not xbmc.abortRequested and self.is_active:
         loops += 1
         self.set_artist(artist)
         self.artist = common.utf_enc(self.artist)
         common.log('[mvmixPlayer] loop: %s' % str(loops))
         common.log('[mvmixPlayer] artist: %s' % str(self.artist))
         videos = __videos__.get_videos(self.artist)
         videos = self.remove_added_videos(videos)
         common.log('[mvmixPlayer] videos found: %s' % str(len(videos)))
         if videos:
             common.limit_artists(common.limit_result())
             video = videos[random.randint(0, (len(videos) - 1))]
             self.video_list.append(video)
             video_url = common.import_site(video['site']).get_video_url(
                 video['id'])
             if video_url:
                 artist = common.utf_enc(video['artist'][0])
                 title = common.utf_enc(video['title'])
                 name = '%s - %s' % (artist, title)
                 listitem = xbmcgui.ListItem(name,
                                             thumbnailImage=video['image'])
                 self.playlist.add(video_url, listitem=listitem)
                 xbmcplugin.setResolvedUrl(int(sys.argv[1]), False,
                                           listitem)
         else:
             self.add_to_ignore_list()
         if artist and not video_url and not self.similar_artists:
             self.similar_artists = lastfm.get_similar_artists(artist)
         if common.resume():
             resume_point = {
                 'start_artist': self.start_artist,
                 'artist': self.artist,
                 'genre_list': self.genre_list,
                 'video_list': self.video_list,
                 'ignore_list': self.ignore_list
             }
             resume.save_resume_point(resume_point)
         self.sleep(200)
         if loops == 10:
             self.is_active = False
             break
Exemplo n.º 6
0
 def playArtist(self,artist):
     self.is_active = True
     common.process_true()
     common.limit_artists(common.limit_result())
     self.similar_artists = []
     self.ignore_list = []
     self.video_list = []
     self.genre_list = lastfm.get_artist_genre(artist)
     self.start_artist = artist
     self.last_artist = self.start_artist
     self.artist = artist
     if common.resume():
         self.set_resume_point()
     self.playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
     self.clear_playlist()
     self.add_video(artist)
     self.play(self.playlist)
Exemplo n.º 7
0
 def add_video(self,artist=False):
     common.log('[mvmixPlayer] add video')
     video_url = None
     loops = 0
     if not artist:
         self.similar_artists = lastfm.get_similar_artists(self.artist)
     while not video_url and not xbmc.abortRequested and self.is_active:
         loops += 1
         self.set_artist(artist)
         self.artist = common.utf_enc(self.artist)
         common.log('[mvmixPlayer] loop: %s' % str(loops))
         common.log('[mvmixPlayer] artist: %s' % str(self.artist))
         videos = __videos__.get_videos(self.artist)
         videos = self.remove_added_videos(videos)
         common.log('[mvmixPlayer] videos found: %s' % str(len(videos)))
         if videos:
             common.limit_artists(common.limit_result())
             video = videos[random.randint(0,(len(videos)-1))]
             self.video_list.append(video)
             video_url = common.import_site(video['site']).get_video_url(video['id'])
             if video_url:
                 artist = common.utf_enc(video['artist'][0])
                 title = common.utf_enc(video['title'])
                 name = '%s - %s' % (artist,title)
                 listitem = xbmcgui.ListItem(name, thumbnailImage=video['image'])
                 self.playlist.add(video_url, listitem=listitem)
                 xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, listitem)
         else:
             self.add_to_ignore_list()
         if artist and not video_url and not self.similar_artists:
             self.similar_artists = lastfm.get_similar_artists(artist)
         if common.resume():
             resume_point = {'start_artist': self.start_artist, 'artist': self.artist,
                             'genre_list': self.genre_list, 'video_list': self.video_list,
                             'ignore_list': self.ignore_list}
             resume.save_resume_point(resume_point)
         self.sleep(200)
         if loops == 10:
             self.is_active = False
             break
Exemplo n.º 8
0
def get_similar_artists(artist):
    n = '100'
    value = cache.get_value(artist,n,lastfm=True)
    if value == None:
        value = []
        try:
            params = {'method':'artist.getsimilar', 'artist':artist, 'autocorrect':'1',
                        'limit':n, 'api_key':api_key, 'format':'json'}
            json_data = requests.get(api_url, params=params).json()
            for item in json_data['similarartists']['artist']:
                value.append(item['name'])
            cache.save_value(artist,n,value,lastfm=True)
        except:
            pass
    similar_artists = []
    for s in value:
        similar_artists.append(s)
        if len(similar_artists) == int(common.limit_artists()):
            break
    return similar_artists