summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Steinke <rasi@xssn.at>2015-02-15 18:47:19 +0100
committerRasmus Steinke <rasi@xssn.at>2015-02-15 18:47:19 +0100
commit9061d9dc13539645094ce8b76022af0fbe7782bd (patch)
tree088babdc7c2937ca0bf39b14cd4f4c895928c5fc
parent2fafdd438ee2985d41313f4b351951d6a60536d1 (diff)
downloadmppc-9061d9dc13539645094ce8b76022af0fbe7782bd.tar.gz
mppc-9061d9dc13539645094ce8b76022af0fbe7782bd.tar.bz2
fix latest additions for beets duplicate tags
-rw-r--r--mppc50
1 files changed, 27 insertions, 23 deletions
diff --git a/mppc b/mppc
index a7db904..d011b93 100644
--- a/mppc
+++ b/mppc
@@ -161,17 +161,20 @@ def trackCache(args):
fields = ('artist', 'track', 'title', 'album')
fh = open(os.getenv('HOME')+'/.config/clerk/tracks.cache', "w")
for artist in artistlist:
- try:
- for element in client.find('artist', artist):
- fh.write(element['artist']+os.getenv('seperator')+element['track'][0]+os.getenv('seperator')+element['title']+os.getenv('seperator')+element['album']+"\n")
- except KeyError:
- errors.add(element['file'])
- except TypeError:
- errors2.add(element['file'])
- for line in sorted(errors, key=str.lower):
- print("Missing tags for file: "+line, file=sys.stderr)
- for line in sorted(errors2, key=str.lower):
- print("Duplicate tags for file: "+line, file=sys.stderr)
+ for element in client.find('artist', artist):
+ # die werte aller felder
+ elementvalues = []
+ for field in fields:
+ # der wert dieses einen feldes
+ fieldvalue = element[field]
+ if isinstance(fieldvalue, list):
+ elementvalues.append(fieldvalue[0])
+ else:
+ elementvalues.append(fieldvalue)
+ # alle felder wurden abgegrast
+ content.add(os.getenv('seperator').join(elementvalues))
+ for line in sorted(content, key=str.lower):
+ fh.write(line+"\n")
fh.close()
@@ -208,22 +211,23 @@ def lastCache(args):
fh = open(os.getenv('HOME')+'/.config/clerk/last.cache', "w")
seen = set()
for artist in artistlist:
- try:
- for element in client.find('albumartist', artist):
- content.add(tuple(element[f] for f in fields))
- except KeyError:
- errors.add(element['file'])
- except TypeError:
- errors2.add(element['file'])
+ for element in client.find('albumartist', artist):
+ # die werte aller felder
+ elementvalues = []
+ for field in fields:
+ # der wert dieses einen feldes
+ fieldvalue = element[field]
+ if isinstance(fieldvalue, list):
+ elementvalues.append(fieldvalue[0])
+ else:
+ elementvalues.append(fieldvalue)
+ # alle felder wurden abgegrast
+ content.add(os.getenv('seperator').join(elementvalues))
for element in sorted(content, key=lambda elem: elem[0], reverse=True):
if element[1:] not in seen:
line = element[1:]
- fh.write(os.getenv('seperator').join(line)+"\n")
+ fh.write(line)+"\n")
seen.add(line)
- for line in sorted(errors, key=str.lower):
- print("Missing tags for file: "+line, file=sys.stderr)
- for line in sorted(errors2, key=str.lower):
- print("Duplicate tags for file: "+line, file=sys.stderr)
fh.close()
def mpdStats(args):