Ejemplo n.º 1
0
 def test_composer_performed_by_various_under_conductor(self):
     artists = {"musicInfo": {
         "composers": [
             {"id": 33445, "name": "Joaquín Rodrigo"}
         ],
         "dj": [],
         "artists": [
             {"id": 781081, "name": "Alexandre Logoya"},
             {"id": 517621, "name": "Catherine Michel"},
             {"id": 150064, "name": "Orchestre National de l'Opéra de Monte-Carlo"}
         ],
         "with": [],
         "conductor": [
             {"id": 407370, "name": "Antonio de Almeida"}
         ],
         "remixedBy": [],
         "producer": []
     }}
     self.assertEqual(get_artists(artists), 'Joaquín Rodrigo performed by Various Artists under '
                                            'Antonio de Almeida')
     self.assertEqual(get_artists_list(artists), [
         {'id': 33445, 'name': 'Joaquín Rodrigo', 'join': ' performed by '},
         {'id': -1, 'name': 'Various Artists', 'join': ' under '},
         {'id': 407370, 'name': 'Antonio de Almeida', 'join': ''},
     ])
Ejemplo n.º 2
0
 def test_composer_performed_by_various(self):
     artists = {"musicInfo": {
         "composers": [{"id": 18505, "name": "Rob Swift"}],
         "dj": [],
         "artists": [
             {"id": 34715, "name": "Al Hirt"},
             {"id": 270168, "name": "Boulaone"},
             {"id": 270167, "name": "Bronislau Kaper"},
             {"id": 6889, "name": "Dizzy Gillespie"},
             {"id": 4570, "name": "Eddie Harris"},
             {"id": 1906, "name": "Herbie Hancock"},
             {"id": 23734, "name": "Large Professor"},
             {"id": 19913, "name": "Les McCann"},
             {"id": 1181, "name": "Lou Donaldson"},
             {"id": 117375, "name": "Richard Evans"},
         ],
         "with": [
             {"id": 21519, "name": "Bob James"},
             {"id": 194729, "name": "Dave McMurray"},
             {"id": 76312, "name": "Dujeous"},
             {"id": 270169, "name": "Isaman"},
             {"id": 270170, "name": "Legrotony"},
         ],
         "conductor": [],
         "remixedBy": [],
         "producer": [],
     }}
     self.assertEqual(get_artists(artists), 'Rob Swift performed by Various Artists')
     self.assertEqual(get_artists_list(artists), [
         {'id': 18505, 'name': 'Rob Swift', 'join': ' performed by '},
         {'id': -1, 'name': 'Various Artists', 'join': ''},
     ])
Ejemplo n.º 3
0
 def test_two_composers_many_artists(self):
     artists = {"musicInfo": {
         "composers": [
             {"id": 1031282, "name": "Anónimo"},
             {"id": 1089741, "name": "Georg-Friedrich Haendel"},
             {"id": 1089740, "name": "Georg-Philipp Telemann"},
             {"id": 6522, "name": "Johann Sebastian Bach"},
             {"id": 1089742, "name": "Johann-Jakob van Eyck"},
             {"id": 35746, "name": "John Dowland"}
         ],
         "dj": [],
         "artists": [
             {"id": 1089739, "name": "Andras Kecskés"},
             {"id": 464752, "name": "René Clemencic"}
         ],
         "with": [],
         "conductor": [],
         "remixedBy": [],
         "producer": []
     }}
     self.assertEqual(get_artists(artists), 'Andras Kecskés & René Clemencic')
     self.assertEqual(get_artists_list(artists), [
         {'id': 1089739, 'name': 'Andras Kecskés', 'join': ' & '},
         {'id': 464752, 'name': 'René Clemencic', 'join': ''},
     ])
Ejemplo n.º 4
0
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']),
    }
Ejemplo n.º 5
0
 def test_two_composers_many_artists(self):
     artists = {
         "musicInfo": {
             "composers": [{
                 "id": 1031282,
                 "name": "Anónimo"
             }, {
                 "id": 1089741,
                 "name": "Georg-Friedrich Haendel"
             }, {
                 "id": 1089740,
                 "name": "Georg-Philipp Telemann"
             }, {
                 "id": 6522,
                 "name": "Johann Sebastian Bach"
             }, {
                 "id": 1089742,
                 "name": "Johann-Jakob van Eyck"
             }, {
                 "id": 35746,
                 "name": "John Dowland"
             }],
             "dj": [],
             "artists": [{
                 "id": 1089739,
                 "name": "Andras Kecskés"
             }, {
                 "id": 464752,
                 "name": "René Clemencic"
             }],
             "with": [],
             "conductor": [],
             "remixedBy": [],
             "producer": []
         }
     }
     self.assertEqual(get_artists(artists),
                      'Andras Kecskés & René Clemencic')
     self.assertEqual(get_artists_list(artists), [
         {
             'id': 1089739,
             'name': 'Andras Kecskés',
             'join': ' & '
         },
         {
             'id': 464752,
             'name': 'René Clemencic',
             'join': ''
         },
     ])
Ejemplo n.º 6
0
 def test_composer_performed_by_various_under_conductor(self):
     artists = {
         "musicInfo": {
             "composers": [{
                 "id": 33445,
                 "name": "Joaquín Rodrigo"
             }],
             "dj": [],
             "artists": [{
                 "id": 781081,
                 "name": "Alexandre Logoya"
             }, {
                 "id": 517621,
                 "name": "Catherine Michel"
             }, {
                 "id":
                 150064,
                 "name":
                 "Orchestre National de l'Opéra de Monte-Carlo"
             }],
             "with": [],
             "conductor": [{
                 "id": 407370,
                 "name": "Antonio de Almeida"
             }],
             "remixedBy": [],
             "producer": []
         }
     }
     self.assertEqual(
         get_artists(artists),
         'Joaquín Rodrigo performed by Various Artists under '
         'Antonio de Almeida')
     self.assertEqual(get_artists_list(artists), [
         {
             'id': 33445,
             'name': 'Joaquín Rodrigo',
             'join': ' performed by '
         },
         {
             'id': -1,
             'name': 'Various Artists',
             'join': ' under '
         },
         {
             'id': 407370,
             'name': 'Antonio de Almeida',
             'join': ''
         },
     ])
Ejemplo n.º 7
0
 def test_plain_artists(self):
     artists = {"musicInfo": {
         "composers": [],
         "dj": [],
         "artists": [
             {"id": 3632, "name": "Supertramp"}
         ],
         "with": [],
         "conductor": [],
         "remixedBy": [],
         "producer": [],
     }}
     self.assertEqual(get_artists(artists), 'Supertramp')
     self.assertEqual(get_artists_list(artists), [
         {'id': 3632, 'name': 'Supertramp', 'join': ''},
     ])
Ejemplo n.º 8
0
 def test_composer_performed_by_two(self):
     artists = {
         "musicInfo": {
             "composers": [{
                 "id": 64138,
                 "name": "Mikis Theodorakis (Μίκης Θεοδωράκης)"
             }],
             "dj": [],
             "artists": [{
                 "id": 5606,
                 "name": "John Williams"
             }, {
                 "id": 328352,
                 "name": "Maria Farantouri (Μαρία Φαραντούρη)"
             }],
             "with": [],
             "conductor": [],
             "remixedBy": [],
             "producer": []
         }
     }
     self.assertEqual(
         get_artists(artists),
         'Mikis Theodorakis (Μίκης Θεοδωράκης) performed by John Williams & '
         'Maria Farantouri (Μαρία Φαραντούρη)')
     self.assertEqual(get_artists_list(artists), [
         {
             'id': 64138,
             'name': 'Mikis Theodorakis (Μίκης Θεοδωράκης)',
             'join': ' performed by '
         },
         {
             'id': 5606,
             'name': 'John Williams',
             'join': ' & '
         },
         {
             'id': 328352,
             'name': 'Maria Farantouri (Μαρία Φαραντούρη)',
             'join': ''
         },
     ])
Ejemplo n.º 9
0
def add_collage(request, collage_id):
    what_client = get_what_client(request)
    response = what_client.request('collage', id=collage_id)['response']
    added = 0
    torrent_group_count = 0
    torrent_count = 0
    for group in response['torrentgroups']:
        if group['categoryId'] not in [1, '1']:
            continue
        artist = get_artists(group)
        title = html_unescape(group['name'])
        release_type = group['releaseType']
        for torrent in group['torrents']:
            what_id = torrent['torrentid']
            priority = filter_torrent(group, torrent)
            if priority and not is_existing(what_id):
                torrent_format = torrent['format']
                encoding = torrent['encoding']
                torrent_size = torrent['size']
                queue_item = QueueItem(
                    what_id=what_id,
                    priority=priority,
                    artist=artist,
                    title=title,
                    release_type=release_type,
                    format=torrent_format,
                    encoding=encoding,
                    torrent_size=torrent_size
                )
                queue_item.save()
                added += 1
            torrent_count += 1
        torrent_group_count += 1
    return {
        'success': True,
        'added': added,
        'groups': torrent_group_count,
        'torrents': torrent_count
    }
Ejemplo n.º 10
0
 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())
     )
Ejemplo n.º 11
0
 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()
     ))
Ejemplo n.º 12
0
 def update_if_newer(cls, group_id, retrieved, data_dict, torrents_dict=None):
     try:
         group = WhatTorrentGroup.objects.get(id=group_id)
         if retrieved < group.retrieved:
             return group
     except WhatTorrentGroup.DoesNotExist:
         group = WhatTorrentGroup(
             id=group_id
         )
     group.retrieved = retrieved
     group.wiki_body = data_dict['wikiBody']
     group.wiki_image = html_unescape(data_dict['wikiImage'])
     group.joined_artists = get_artists(data_dict)
     group.name = html_unescape(data_dict['name'])
     group.year = data_dict['year']
     group.record_label = html_unescape(data_dict['recordLabel'])
     group.catalogue_number = html_unescape(data_dict['catalogueNumber'])
     group.release_type = data_dict['releaseType']
     group.category_id = data_dict['categoryId']
     group.category_name = data_dict['categoryName']
     group.time = parse_datetime_with_timezone_support(data_dict['time'])
     group.vanity_house = data_dict['vanityHouse']
     group.info_json = ujson.dumps(data_dict)
     if torrents_dict is not None:
         group.torrents_json = ujson.dumps(torrents_dict)
     else:
         group.torrents_json = None
     with transaction.atomic():
         group.save()
         group.artists.clear()
         group.add_artists(1, data_dict['musicInfo']['artists'])
         group.add_artists(2, data_dict['musicInfo']['with'])
         group.add_artists(3, data_dict['musicInfo']['remixedBy'])
         group.add_artists(4, data_dict['musicInfo']['composers'])
         group.add_artists(5, data_dict['musicInfo']['conductor'])
         group.add_artists(6, data_dict['musicInfo']['dj'])
         group.add_artists(7, data_dict['musicInfo']['producer'])
     return group
Ejemplo n.º 13
0
 def test_composer_performed_by_two(self):
     artists = {"musicInfo": {
         "composers": [
             {"id": 64138, "name": "Mikis Theodorakis (Μίκης Θεοδωράκης)"}
         ],
         "dj": [],
         "artists": [
             {"id": 5606, "name": "John Williams"},
             {"id": 328352, "name": "Maria Farantouri (Μαρία Φαραντούρη)"}
         ],
         "with": [],
         "conductor": [],
         "remixedBy": [],
         "producer": []
     }}
     self.assertEqual(get_artists(artists),
                      'Mikis Theodorakis (Μίκης Θεοδωράκης) performed by John Williams & '
                      'Maria Farantouri (Μαρία Φαραντούρη)')
     self.assertEqual(get_artists_list(artists), [
         {'id': 64138, 'name': 'Mikis Theodorakis (Μίκης Θεοδωράκης)', 'join': ' performed by '},
         {'id': 5606, 'name': 'John Williams', 'join': ' & '},
         {'id': 328352, 'name': 'Maria Farantouri (Μαρία Φαραντούρη)', 'join': ''},
     ])
Ejemplo n.º 14
0
 def test_plain_artists(self):
     artists = {
         "musicInfo": {
             "composers": [],
             "dj": [],
             "artists": [{
                 "id": 3632,
                 "name": "Supertramp"
             }],
             "with": [],
             "conductor": [],
             "remixedBy": [],
             "producer": [],
         }
     }
     self.assertEqual(get_artists(artists), 'Supertramp')
     self.assertEqual(get_artists_list(artists), [
         {
             'id': 3632,
             'name': 'Supertramp',
             'join': ''
         },
     ])
Ejemplo n.º 15
0
 def joined_artists(self):
     return get_artists(self.info_loads['group'])
Ejemplo n.º 16
0
 def joined_artists(self):
     return get_artists(self.info_loads['group'])
Ejemplo n.º 17
0
 def test_composer_performed_by_various(self):
     artists = {
         "musicInfo": {
             "composers": [{
                 "id": 18505,
                 "name": "Rob Swift"
             }],
             "dj": [],
             "artists": [
                 {
                     "id": 34715,
                     "name": "Al Hirt"
                 },
                 {
                     "id": 270168,
                     "name": "Boulaone"
                 },
                 {
                     "id": 270167,
                     "name": "Bronislau Kaper"
                 },
                 {
                     "id": 6889,
                     "name": "Dizzy Gillespie"
                 },
                 {
                     "id": 4570,
                     "name": "Eddie Harris"
                 },
                 {
                     "id": 1906,
                     "name": "Herbie Hancock"
                 },
                 {
                     "id": 23734,
                     "name": "Large Professor"
                 },
                 {
                     "id": 19913,
                     "name": "Les McCann"
                 },
                 {
                     "id": 1181,
                     "name": "Lou Donaldson"
                 },
                 {
                     "id": 117375,
                     "name": "Richard Evans"
                 },
             ],
             "with": [
                 {
                     "id": 21519,
                     "name": "Bob James"
                 },
                 {
                     "id": 194729,
                     "name": "Dave McMurray"
                 },
                 {
                     "id": 76312,
                     "name": "Dujeous"
                 },
                 {
                     "id": 270169,
                     "name": "Isaman"
                 },
                 {
                     "id": 270170,
                     "name": "Legrotony"
                 },
             ],
             "conductor": [],
             "remixedBy": [],
             "producer": [],
         }
     }
     self.assertEqual(get_artists(artists),
                      'Rob Swift performed by Various Artists')
     self.assertEqual(get_artists_list(artists), [
         {
             'id': 18505,
             'name': 'Rob Swift',
             'join': ' performed by '
         },
         {
             'id': -1,
             'name': 'Various Artists',
             'join': ''
         },
     ])