From 63655138e90b01af0f21893c2f21c1cc05e2313e Mon Sep 17 00:00:00 2001 From: Ache Date: Thu, 29 Sep 2016 06:47:17 +0200 Subject: Init with more scripts --- track.py | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 track.py (limited to 'track.py') 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"); + + + + -- cgit v1.2.3