-
Notifications
You must be signed in to change notification settings - Fork 0
/
qobuz_player.py
executable file
·38 lines (29 loc) · 1.21 KB
/
qobuz_player.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3
import os
import shutil
import sys
import configparser
from qobuz import qobuz_api as qobuz
CONFIG_PATH = os.path.expanduser('~/.qdl/qdl_config.ini')
config_folder = os.path.dirname(CONFIG_PATH)
if not os.path.exists(config_folder):
os.makedirs(config_folder)
if not os.path.isfile(CONFIG_PATH):
config_skel_path = os.path.join(os.path.dirname(__file__), 'config.ini.skel')
shutil.copyfile(config_skel_path, CONFIG_PATH)
print("A new config file in {} has been created.".format(CONFIG_PATH))
print("Please add your app and user info")
sys.exit(-1)
config = configparser.ConfigParser()
config.read(CONFIG_PATH)
app_secret = config['QOBUZ']['app_secret']
app_id = config['QOBUZ']['app_id']
user_auth_token = config['QOBUZ']['user_auth_token']
download_dir = config['DOWNLOAD']['directory']
format_id = int(config['DOWNLOAD']['format_id'])
log_dir = config['LOG']['directory']
os.makedirs(download_dir, exist_ok=True)
qobuz_client = qobuz.QobuzApi(app_id, app_secret, user_auth_token, format_id, download_dir, log_dir)
artist = qobuz_client.get_artist_from_catalog(sys.argv[1])
qobuz_client.play_artist(artist['id'])
qobuz_client.play_favorite_artists(cache_only=True, skip_existing=True)