forked from albertz/music-player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_dumpallmusic.py
45 lines (42 loc) · 1.07 KB
/
test_dumpallmusic.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
# MusicPlayer, https://github.com/albertz/music-player
# Copyright (c) 2012, Albert Zeyer, www.az2000.de
# All rights reserved.
# This code is under the 2-clause BSD license, see License.txt in the root directory of this project.
from Song import Song
import songdb
from utils import *
import appinfo
import better_exchook
better_exchook.install()
try:
songdb.initAllDbs()
useDb = True
except Exception:
# this might fail for various reasons. e.g. the DB might be locked by the player.
# ignore then
useDb = False
def doDir(dir):
import os
for fn in os.listdir(dir):
fullfn = dir + "/" + fn
if os.path.isfile(fullfn):
ext = os.path.splitext(fn)[1].lower()
if ext[:1] == ".": ext = ext[1:]
if ext in appinfo.formats:
song = Song(url=fullfn, _useDb=useDb)
assert song
songDict = {
"url": fullfn,
"artist": song.artist,
"title": song.title,
}
if useDb:
assert song.id
songDict["id"] = song.id
print betterRepr(songDict), ","
elif os.path.isdir(fullfn):
doDir(fullfn)
print "["
for d in appinfo.musicdirs:
doDir(d)
print "]"