aboutsummaryrefslogtreecommitdiff
path: root/track.py
diff options
context:
space:
mode:
authorAche <ache@ache.one>2016-09-29 06:47:17 +0200
committerAche <ache@ache.one>2016-09-29 06:47:17 +0200
commit63655138e90b01af0f21893c2f21c1cc05e2313e (patch)
tree49e85ad99b939b2bb5e528877cb82d6b1bf92b5f /track.py
parentFirst script (diff)
Init with more scripts
Diffstat (limited to 'track.py')
-rwxr-xr-xtrack.py64
1 files changed, 64 insertions, 0 deletions
diff --git a/track.py b/track.py
new file mode 100755
index 0000000..c1b58b1
--- /dev/null
+++ b/track.py
@@ -0,0 +1,64 @@
+#!/usr/bin/python
+#-*-coding:utf-8 -*
+
+import re, os, time, sys
+
+motif = sys.argv[1]
+fileName = sys.argv[2]
+titre = fileName[0:fileName.rindex('.')]
+
+l = [""]
+i = 0
+
+while i < len(motif) :
+ if motif[i] == '%' :
+ l.append(motif[i:i+2])
+ l.append("")
+ i+=2
+ else:
+ l[-1] += motif[i]
+ i+=1
+
+if l[-1] == "" :
+ l = l[0:len(l)-1]
+if l[0] == "" :
+ l = l[1:]
+
+regexString = "^"
+
+for t in l :
+ if t[0] == '%':
+ regexString += "(.*?)"
+ else:
+ regexString += t
+
+regexString += "$"
+
+reg = re.search(regexString, titre)
+
+if reg :
+ print(reg.group(0))
+ print(reg.group(1))
+ print(reg.group(2))
+ k = 1
+ option = { "%t":"title", "%a":"artist", "%A":"album", "%y":"year", "%n":"track", "%c":"comment"}
+ tag = { "title":"", "artist":"", "album":"", "year":"", "track":"", "comment":""}
+ optionEyeD3 = {"title":"-t", "artist":"-a", "album":"-A", "year":"-Y", "track":"-n", "comment":"-c"}
+ for i in range(len(l)):
+ if l[i] in option :
+ tag[option[l[i]]] = reg.group(k);
+ k+=1
+
+ cmdLine = "eyeD3 \"" + fileName + "\" "
+ for key, value in [ (x,y) for x,y in tag.items() if y != ""]:
+ cmdLine += optionEyeD3[key] + " \"" + value + "\" "
+ print(cmdLine)
+ os.system(cmdLine)
+
+
+else:
+ print("Didn't match");
+
+
+
+