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))]
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))]
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
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