-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py~
27 lines (25 loc) · 887 Bytes
/
test.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
#!/usr/bin/python
import gpod
import os
import shutil
import re
database = gpod.Database('/mnt/ipod')
master = database.get_master()
print 'Id', master.get_id()
print 'Master ', master.get_master()
print 'Order ', master.order
cnt = 0
size = 0
g = 1
for track in database:
if re.match('.*\.mp3$',track.ipod_filename()):
cnt+=1
size += os.path.getsize(track.ipod_filename())
#print track.artist, track.ipod_filename()
folder = "./music/{0}/{1}/".format(track['artist'],track['album'])
if not os.path.exists(folder):
os.makedirs(folder)
shutil.copy(track.ipod_filename(), "./music/{0}/{1}/{2}.mp3".format(track['artist'],track['album'],re.sub(r"\/",'\/',track['title'])))
print "copied {0}/{1}/{2}.mp3".format(track['artist'],track['album'],track['title'])
print "copied",size/1024/1024,"MB so far"
print 'There are', cnt,'songs on the IPOD summing up',size,'bytes.'