summaryrefslogtreecommitdiff
path: root/src/index_files.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/index_files.py')
-rw-r--r--src/index_files.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/index_files.py b/src/index_files.py
new file mode 100644
index 0000000..ece51aa
--- /dev/null
+++ b/src/index_files.py
@@ -0,0 +1,58 @@
1import os
2import re
3import json
4import mutagen
5from pprint import pprint
6
7
8music = re.compile('.*\.(mp3|m4a)$')
9
10
11tags = set()
12
13
14def parse_frame(txt):
15 frame_type, remainder = txt.split(':', 1)
16 content = None
17
18 if remainder.startswith('http'):
19 remainder = remainder.split(':', 2)
20 content = remainder[-1]
21 remainder = ':'.join(remainder[:2])
22 elif ':' in remainder:
23 remainder, content = remainder.split(':', 1)
24
25 return frame_type, remainder, content
26
27
28for path, dirs, files in os.walk(os.path.expanduser('~/Desktop/Music')):
29 for file in files:
30 fullname = os.path.join(path, file)
31
32 if not music.match(fullname):
33 continue
34
35 file = mutagen.File(fullname)
36
37 if not file or not file.tags:
38 print "ERROR: ", fullname
39 continue
40
41 for tag, value in file.tags.items():
42 #if hasattr(value, 'text'):
43 # value = value.text
44
45 #if isinstance(value, list) and len(value) == 1:
46 # value = value[0]
47
48 #if tag == 'covr':
49 # continue
50
51 #if hasattr(value, 'mime') and value.mime.startswith('image'):
52 # continue
53
54 #if tag.startswith(('PRIV', 'APIC', 'COMM', 'USLT', 'WCOM')):
55 # continue
56
57 #if not isinstance(value, unicode):
58 print repr(tag), type(value), repr(value)