-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path241 mp3 scan.py
67 lines (59 loc) · 2.43 KB
/
241 mp3 scan.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
64
65
66
67
import os
import fnmatch
import id3reader_p3 as id3
def find_file_name(root, filename=None, start=None, ext=None):
if filename:
if start:
for path, directories, files in os.walk(root):
if start in path:
for file in (f for f in files if fnmatch.fnmatch(f, filename)):
if ext:
file_name, file_ext = os.path.splitext(file)
if ext in file_ext:
yield os.path.abspath(path) + "\\" + file
else:
yield os.path.abspath(path) + "\\" + file
else:
for path, directories, files in os.walk(root):
for file in (f for f in files if fnmatch.fnmatch(f, filename)):
if ext:
file_name, file_ext = os.path.splitext(file)
if ext == file_ext:
yield os.path.abspath(path) + "\\" + file
else:
yield os.path.abspath(path) + "\\" + file
else:
if start:
for path, directories, files in os.walk(root):
if start in path:
for file in files:
file_name, file_ext = os.path.splitext(file)
if ext:
if ext == file_ext:
yield os.path.abspath(path) + "\\" + file
else:
yield os.path.abspath(path) + "\\" + file
else:
for path, directories, files in os.walk(root):
for file in files:
file_name, file_ext = os.path.splitext(file)
if ext:
if ext == file_ext:
yield os.path.abspath(path) + "\\" + file
else:
yield os.path.abspath(path) + "\\" + file
file_list = find_file_name("Polskie", ext=".mp3")
def get_tag(filelist):
errors = []
for f in file_list:
try:
id3r = id3.Reader(f)
print("Artist: {}, Album: {}, Track: {}, Song: {}".format(
id3r.get_value('performer'),
id3r.get_value('album'),
id3r.get_value('track'),
id3r.get_value('title')
))
except:
errors.append(f)
get_tag(file_list)