import requests
from utils.download import download_album


def process_artist_queue():
    print('Running Artist Queue process..')
    print('---')
    requests.get('http://nginx/api/queue/artists/run')
    return


def process_album_queue():
    print('Running Album Queue Process..')
    print('---')
    response = requests.get('http://nginx/api/album/queue')
    data = response.json()
    artist = data.get('artist', False)
    album = data.get('album', False)
    queue = data.get('queue')
    if not queue == False and artist and album:
        result = download_album(album, artist)
        requests.post('http://nginx/api/album/queue/update/%s' % queue.get('id'), json=result)
    return
