-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.py
63 lines (56 loc) · 1.52 KB
/
main.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import argparse
import logging
from config_manager import cM
from spotify import Spotify
from token_manager import TokenManager
if __name__ == '__main__':
parser = argparse.ArgumentParser(prog="Spotify Downloader")
parser.add_argument(
'--id',
type=str,
help='Spotify URL/URI/ID',
required=True
)
parser.add_argument(
'--quality',
help='Quality level',
default='MP4_128',
required=False,
choices=[
'MP4_128',
'MP4_128_DUAL',
'MP4_256',
'MP4_256_DUAL',
'OGG_VORBIS_320',
'OGG_VORBIS_160',
'OGG_VORBIS_96'
]
)
parser.add_argument(
'--output',
type=str,
default='.',
help='Output path',
required=False,
)
parser.add_argument(
'--debug',
action="store_true",
default=False,
help='Print debug information',
required=False
)
args = parser.parse_args()
# TODO: add metadata
cM.initialize()
logging.basicConfig(format='[%(levelname)s]: %(message)s', level=logging.DEBUG if args.debug else logging.INFO)
token_manager = TokenManager()
token_manager.query_sp_dc()
spotify = Spotify(
url_id=args.id,
token_manager=token_manager,
quality=args.quality,
output_folder=args.output
)
for track in spotify.get_tracks():
spotify.download(track)