48 lines
1.5 KiB
Python
Executable File
48 lines
1.5 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import configparser
|
|
import os
|
|
from time import sleep
|
|
import dir_activities
|
|
import api_calls
|
|
|
|
config = configparser.ConfigParser()
|
|
if os.path.exists('config.ini'):
|
|
conf_path = 'config.ini'
|
|
else:
|
|
conf_path = os.path.join(os.path.expanduser("~"), ".local/share/get_artist_art/config.ini")
|
|
|
|
config.read(conf_path)
|
|
|
|
music_path = config['music']['dir']
|
|
ftv_api_key = config['fanart_tv']['api_key']
|
|
mb_confidence = int(config['musicbrainz']['confidence'])
|
|
|
|
count = 1
|
|
dir_list = dir_activities.get_all(music_path)
|
|
dir_list.sort()
|
|
for artist in dir_list:
|
|
artist_path = os.path.join(music_path, artist)
|
|
if not(dir_activities.has_artist_art(artist_path)):
|
|
# print(dir_activities.has_artist_art(artist_path))
|
|
print(str(count) + ": " + artist.strip('_'))
|
|
try:
|
|
ftv_response = False
|
|
mb_exit = False
|
|
while not mb_exit:
|
|
found_status, mb_id, mb_exit = api_calls.get_mb_id(artist, mb_confidence)
|
|
# print("Getting ", artist_image)
|
|
if found_status:
|
|
while not ftv_response:
|
|
ftv_response = api_calls.get_image(mb_id, ftv_api_key, artist_path)
|
|
# print(ftv_response)
|
|
else:
|
|
print(f"{artist} returned no results.")
|
|
# api_requests.get_art(artist_image, artist, music_path)
|
|
except Exception as e:
|
|
print("Artist or art not found.")
|
|
print(e)
|
|
print("---------")
|
|
count += 1
|
|
#sleep(1)
|