Update mode back to working, non mp3's are not added to the database
This commit is contained in:
parent
247c684b58
commit
83fbdc7658
1 changed files with 12 additions and 8 deletions
|
|
@ -22,17 +22,17 @@ else:
|
||||||
# apikeylastfm = "KeyHere"
|
# apikeylastfm = "KeyHere"
|
||||||
# soundLocation = "directoryHere"
|
# soundLocation = "directoryHere"
|
||||||
songFiles = os.listdir(soundLocation)
|
songFiles = os.listdir(soundLocation)
|
||||||
if args.mode == "update":
|
if args.mode.lower() == "update":
|
||||||
try:
|
try:
|
||||||
with open('songDatabase.json', 'r') as handle:
|
with open('songDatabase.json', 'r') as handle:
|
||||||
songDatabaseList = json.load(handle)
|
songDatabaseList = json.load(handle)
|
||||||
except:
|
except:
|
||||||
songDatabaseList={"songDirectory":soundLocation,'songData':{}}
|
songDatabaseList={"songDirectory":soundLocation,'songData':{}}
|
||||||
|
|
||||||
for i in songDatabaseList["songData"]:
|
|
||||||
deleteySongs = []
|
deleteySongs = []
|
||||||
|
for i in songDatabaseList["songData"]:
|
||||||
try:
|
try:
|
||||||
songFiles.index(i) != -1
|
if songFiles.index(i) == -1:
|
||||||
|
deleteySongs.append(i)
|
||||||
except:
|
except:
|
||||||
deleteySongs.append(i)
|
deleteySongs.append(i)
|
||||||
if deleteySongs:
|
if deleteySongs:
|
||||||
|
|
@ -41,11 +41,12 @@ if args.mode == "update":
|
||||||
songDatabaseList["songData"].pop(i)
|
songDatabaseList["songData"].pop(i)
|
||||||
for i in songDatabaseList["songData"]:
|
for i in songDatabaseList["songData"]:
|
||||||
songFiles.remove(i)
|
songFiles.remove(i)
|
||||||
print("new songs: " + str(songFiles))
|
print("new songs: " + ", ".join(songFiles))
|
||||||
elif args.mode=="new":
|
elif args.mode.lower()=="new":
|
||||||
songDatabaseList={"songDirectory":soundLocation,'songData':{}}
|
songDatabaseList={"songDirectory":soundLocation,'songData':{}}
|
||||||
|
else:
|
||||||
if args.art.lower() == "true":
|
raise ValueError("Must be \"new\" or \"update\"")
|
||||||
|
if args.art.lower() == "true" and not(args.apikey == ""):
|
||||||
x = len(songFiles)*0.25
|
x = len(songFiles)*0.25
|
||||||
if x > 60:
|
if x > 60:
|
||||||
print("ETA "+ str(x/60) + " minutes")
|
print("ETA "+ str(x/60) + " minutes")
|
||||||
|
|
@ -53,6 +54,9 @@ if args.art.lower() == "true":
|
||||||
print("ETA "+ str(x) + " seconds")
|
print("ETA "+ str(x) + " seconds")
|
||||||
|
|
||||||
for i in songFiles:
|
for i in songFiles:
|
||||||
|
if i[-4].lower() != ".mp3":
|
||||||
|
# skip any non-mp3's (like directories or cover art)
|
||||||
|
continue
|
||||||
try:
|
try:
|
||||||
# get the metadata
|
# get the metadata
|
||||||
song = EasyID3(soundLocation+i)
|
song = EasyID3(soundLocation+i)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue