-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_folder_dict.py
65 lines (45 loc) · 2.16 KB
/
make_folder_dict.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
import os, re
SBDPATH = '/Volumes/gspeed1/thomasw/grateful_dead/lma_soundboards/sbd'
LMAPATH = '/Volumes/gspeed1/thomasw/grateful_dead/lma'
replace = {
#'flac16': ['flac24', 'flac2448', 'flac2496', 'flac1696', 'flac1648', 'shnf', 'flac1644', '1644'],
'flac1644': ['flac24', 'flac2448', 'flac2496', 'flac1696', 'flac1648', 'shnf'],
'shnf': ['flac24', 'flac2448', 'flac2496', 'flac1696', 'flac1648'],
'flac1648': ['flac24', 'flac2448', 'flac2496', 'flac1696'],
'flac1696': ['flac24', 'flac2448', 'flac2496'],
'flac24': ['flac2448', 'flac2496'],
'flac2448': ['flac2496']
}
ignore = ['vobf', 'dvda', 'dvdf', 'sirmickflac1648', 'fkac16', 'na', '127416', '127417', '127418', 'chuckm', '127360']
def dateDict():
DIRS = [os.path.join(SBDPATH, d) for d in os.listdir(SBDPATH) if os.path.isdir(os.path.join(SBDPATH, d))] + [os.path.join(LMAPATH, d) for d in os.listdir(LMAPATH) if os.path.isdir(os.path.join(LMAPATH, d))]
datedict = {}
for d in DIRS:
#print(d)
etree = d.split('/')[-1].split('.')
try:
if etree[-1] in ignore: continue
if etree[-1] == '1644': etree[-1] = 'flac1644'
if etree[-1] == '2496': etree[-1] = 'flac2496'
frmt = list(filter(lambda x: x.lower().startswith(('flac', 'shnf')), etree))[0]
except:
pass
#print(etree)
#sys.exit()
sortname = '.'.join(filter(lambda x: not (x.isdigit() or x.lower().startswith(('shnf', 'flac'))), etree))
if sortname in datedict and frmt.lower() in replace:
if datedict[sortname]['format'] in replace[frmt.lower()]:
datedict[sortname]['folder'] = d
datedict[sortname]['format'] = frmt.lower()
else:
datedict[sortname] = { 'folder': d, 'format': frmt.lower()}
newdict = {}
for k, v in datedict.items():
try:
date = k.split('/')[-1].split('.')[0]
date = re.findall(r'\d{2}-\d{2}-\d{2}', date)[0]
if date not in newdict:
newdict[date] = []
newdict[date].append(v['folder'])
except: pass
return newdict