def top10_torrent_groups(request): count = request.GET.get('count', 10) what_client = get_what_client(request) top10 = what_client.request('top10', limit=100)['response'] group_set = set() results = [] for torrent in top10[0]['results']: if torrent['groupId'] in group_set: continue if torrent['groupCategory'] != 1: continue group_set.add(torrent['groupId']) results.append({ 'id': torrent['groupId'], 'joined_artists': html_unescape(torrent['artist']), 'name': html_unescape(torrent['groupName']), 'year': torrent['groupYear'], 'wiki_image': get_image_cache_url(torrent['wikiImage']), }) if len(results) == count: break torrents_have = get_torrent_groups_have(t['id'] for t in results) for result in results: result.update(torrents_have[result['id']]) return results
def get_artist_group_dict(torrent_group): music_info = extended_artists_to_music_info(torrent_group['extendedArtists']) return { 'id': torrent_group['groupId'], 'joined_artists': get_artists(music_info), 'artists': get_artists_list(music_info), 'name': html_unescape(torrent_group['groupName']), 'year': torrent_group['groupYear'], 'wiki_image': get_image_cache_url(torrent_group['wikiImage']), }
def directory_name(self): torrent = self.what_torrent artists = get_artists(torrent["group"]) if len(artists) + len(torrent["group"]["name"]) > 80: if torrent["group"]["musicInfo"]["artists"]: if len(torrent["group"]["musicInfo"]["artists"]) > 1: artists = "Various Artists" else: artists = torrent["group"]["musicInfo"]["artists"][0]["name"] elif torrent["group"]["musicInfo"]["conductor"]: if len(torrent["group"]["musicInfo"]["conductor"]) > 1: artists = "Various Conductors" else: artists = torrent["group"]["musicInfo"]["conductor"][0]["name"] name = html_unescape(torrent["group"]["name"]) if len(name) > 70: name = name[:67] + "..." media = torrent["torrent"]["media"] year = torrent["torrent"]["remasterYear"] or torrent["group"]["year"] return fix_pathname( "{0} - {1} - {2} ({3} - MP3 - {4})".format(artists, name, year, media, self.bitrate.upper()) )
def directory_name(self): torrent = self.what_torrent artists = get_artists(torrent['group']) if len(artists) + len(torrent['group']['name']) > 80: if torrent['group']['musicInfo']['artists']: if len(torrent['group']['musicInfo']['artists']) > 1: artists = 'Various Artists' else: artists = torrent['group']['musicInfo']['artists'][0]['name'] elif torrent['group']['musicInfo']['conductor']: if len(torrent['group']['musicInfo']['conductor']) > 1: artists = 'Various Conductors' else: artists = torrent['group']['musicInfo']['conductor'][0]['name'] name = html_unescape(torrent['group']['name']) if len(name) > 70: name = name[:67] + '...' media = torrent['torrent']['media'] year = torrent['torrent']['remasterYear'] or torrent['group']['year'] return fix_pathname('{0} - {1} - {2} ({3} - MP3 - {4})'.format( artists, name, year, media, self.bitrate.upper() ))