-
Notifications
You must be signed in to change notification settings - Fork 0
/
dl.py
48 lines (38 loc) · 1.33 KB
/
dl.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
# -*- coding: utf-8 -*-
import os
import ConfigParser
import argparse
import eyed3
def get_dest():
cf = ConfigParser.ConfigParser()
cf.read('conf.ini')
DEST = cf.get('dir', 'dest')
return DEST
def make_folder(name):
DEST = get_dest()
folder = os.path.join(os.getcwd(), DEST, name);
if not os.path.exists(folder):
os.makedirs(folder)
return folder
def parse_arguments(VERSION):
note = 'The following SONG, ALBUM, and PLAYLIST are IDs which can be' \
'obtained from the URL of corresponding web page.'
parser = argparse.ArgumentParser(description=note)
parser.add_argument('-v', '--version', action='version', version=VERSION)
parser.add_argument('-a', '--album',
help='adds all songs in the albums for download',
type=int, nargs='+')
parser.add_argument('-s', '--song',
help='add a songs in the albums for download',
type=int, nargs='+')
parser.add_argument('-se', '--search',
help='search album or song',
type=str, nargs='+')
return parser.parse_args()
def set_song_info(filename, info):
audio = eyed3.load(filename)
audio.tag.title = info[u'title']
audio.tag.album = info[u'album']
audio.tag.artist = info[u'artist']
audio.tag.track_num = info[u'track_num']
audio.tag.save()