-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsonglist_maker.py
More file actions
36 lines (27 loc) · 939 Bytes
/
songlist_maker.py
File metadata and controls
36 lines (27 loc) · 939 Bytes
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
import os, json, csv
import getter as UG
model_path = os.path.join(__file__.split(os.sep)[0], 'models')
data_dir = os.path.join(__file__.split(os.sep)[0], 'valid_retrain')
res_dir = os.path.join(__file__.split(os.sep)[0], 'valid_retrain')
#res_dir = '/media/dxk/TOSHIBA EXT/llm_playlist_res'
y = UG.playlist_csv_generator('train_pids.csv', csv_path = data_dir)
train_uris = set()
prev_pid = -1
prev_pl = None
for _i,_x in enumerate(y):
print(f'processing {_i}')
_y = None
cur_pid = int(_x['pid'])
if prev_pid != cur_pid:
_y = UG.get_playlist(_x['file'], int(_x['idx']))
prev_pl = _y
else:
_y = prev_pl
prev_pid = cur_pid
_u = [_t['track_uri'].strip() for _t in _y['tracks']]
train_uris.update(set(_u))
with open(os.path.join(res_dir, 'train.uris'), 'w') as f:
for uri in train_uris:
f.write(uri)
f.write('\n')
print('train song count:', len(train_uris))