Example #1
0
def add_artist(request, artist_name):
    what_client = get_what_client(request)
    response = what_client.request('artist', artistname=artist_name)['response']
    added = 0
    for group in response['torrentgroup']:
        if filter_group(response['name'], group):
            artist = html_unescape(response['name'])
            title = html_unescape(group['groupName'])
            release_type = group['releaseType']
            for torrent in group['torrent']:
                id = torrent['id']
                priority = filter_torrent(group, torrent)
                if priority and not is_existing(id):
                    format = torrent['format']
                    encoding = torrent['encoding']
                    torrent_size = torrent['size']
                    queue_item = QueueItem(
                        what_id=id,
                        priority=priority,
                        artist=artist,
                        title=title,
                        release_type=release_type,
                        format=format,
                        encoding=encoding,
                        torrent_size=torrent_size
                    )
                    queue_item.save()
                    added += 1
    return {
        'success': True,
        'added': added
    }
Example #2
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
    }