tags 277932 + patch pending
thanks
* James R. Van Zandt <[EMAIL PROTECTED]> [2004-10-23 10:14]:
> CDDB protocol level 5 allows DYEAR and DGENRE lines, described as
> follows:
>
> DYEAR: This field contains the (4-digit) year, in which the CD was released.
> It should be empty (not 0) if the user hasn't entered a year.
>
> DGENRE: This field contains the exact genre of the disc in a textual form
> (i.e. write the genre here and do not use e.g. simply the MP3 ID3V1
> genre code). Please note that this genre is not limited to the
> 11 CDDB-genres. The Genre in this field should be capitalized, e.g.
> "New Age" instead of "newage" or "new age".
>
> jack should include these entries in its blank file (between DTITLE
> and TTITLE0). It should also fill them in (if the data is available),
> and use the DGENRE info to set the default for the the file submission
> (if it's a fuzzy match to one of the permitted values). The patch
> below just adds the two lines.
I think the following patch does everything that is needed for DYEAR
and DGENRE support:
diff -urN jack-3.1.1~/jack_freedb.py jack-3.1.1/jack_freedb.py
--- jack-3.1.1~/jack_freedb.py 2005-07-30 00:17:58.000000000 +0100
+++ jack-3.1.1/jack_freedb.py 2005-07-30 21:37:47.853857856 +0100
@@ -180,6 +180,23 @@
f.write(freedb_split("DTITLE", names[0][0] + " / " + names[0][1]))
else:
f.write("DTITLE=\n")
+ freedb_year, freedb_id3genre = -1, -1
+ if cf['_id3_genre'] >= 0 and cf['_id3_genre'] < len(id3genres) or
cf['_id3_genre'] == 255:
+ freedb_id3genre = cf['_id3_genre']
+ elif names and len(names[0]) == 4:
+ freedb_id3genre = names[0][3]
+ if cf['_id3_year'] >= 0:
+ freedb_year = cf['_id3_year']
+ elif names and len(names[0]) == 4:
+ freedb_year = names[0][2]
+ if freedb_year >= 0:
+ f.write("DYEAR=%d\n" % freedb_year)
+ else:
+ f.write("DYEAR=\n")
+ if freedb_id3genre >= 0:
+ f.write("DGENRE=%s\n" % id3genres[freedb_id3genre])
+ else:
+ f.write("DGENRE=\n")
for i in tracks:
if names:
if names[i[NUM]][0]: # various
@@ -194,15 +211,6 @@
f.write(freedb_split("TTITLE" + `i[NUM]-1`, names[i[NUM]][1]))
else:
f.write("TTITLE" + `i[NUM]-1` + "=\n")
- freedb_year, freedb_id3genre = -1, -1
- if cf['_id3_genre'] >= 0 and cf['_id3_genre'] < len(id3genres) or
cf['_id3_genre'] == 255:
- freedb_id3genre = cf['_id3_genre']
- elif names and len(names[0]) == 4:
- freedb_id3genre = names[0][3]
- if cf['_id3_year'] >= 0:
- freedb_year = cf['_id3_year']
- elif names and len(names[0]) == 4:
- freedb_year = names[0][2]
if freedb_year >= 0 or freedb_id3genre >= 0:
f.write("EXTD=\\nYEAR: %4s ID3G: %3s\n" % (freedb_year,
freedb_id3genre))
else:
@@ -342,7 +350,7 @@
line = string.replace(line, "\r", "") # I consider "\r"s as bugs in
db info
if jack_functions.starts_with(line, "# Revision:"):
revision = int(line[11:])
- for i in ["DISCID", "DTITLE", "TTITLE", "EXTD", "EXTT", "PLAYORDER"]:
+ for i in ["DISCID", "DTITLE", "DYEAR", "DGENRE", "TTITLE", "EXTD",
"EXTT", "PLAYORDER"]:
if jack_functions.starts_with(line, i):
buf = line
if string.find(buf, "=") != -1:
@@ -423,7 +431,29 @@
dtitle = "(unknown artist)/" + dtitle
names = [string.split(dtitle,"/",1)]
- if freedb.has_key('EXTD'):
+ year = 0
+ if freedb.has_key('DYEAR'):
+ try:
+ year = int(freedb['DYEAR'])
+ except ValueError:
+ warning("DYEAR has to be an integer but it's the string '%s'" %
freedb['DYEAR'])
+ else:
+ if year == 0:
+ warning("DYEAR should not be 0 but empty")
+ genre = -1
+ if freedb.has_key('DGENRE'):
+ try:
+ genre = int(freedb['DGENRE'])
+ except ValueError:
+ if freedb['DGENRE'].upper() in [x.upper() for x in id3genres]:
+ genre = [x.upper() for x in
id3genres].index(freedb['DGENRE'].upper())
+ else:
+ warning("DGENRE should be a string, not an integer.")
+ if genre != -1:
+ names[0].extend([year, genre])
+ else:
+ names[0].extend([year])
+ if freedb.has_key('EXTD') and not(freedb.has_key('DYEAR') or
freedb.has_key('DGENRE')):
extra_tag_pos = string.find(freedb['EXTD'], "\\nYEAR:")
if extra_tag_pos >= 0:
try:
diff -urN jack-3.1.1~/jack_tag.py jack-3.1.1/jack_tag.py
--- jack-3.1.1~/jack_tag.py 2005-07-30 00:17:58.000000000 +0100
+++ jack-3.1.1/jack_tag.py 2005-07-30 21:34:44.299762320 +0100
@@ -65,12 +65,11 @@
if cf['_set_id3tag'] or freedb_rename:
jack_m3u.init()
- if len(track_names[0]) == 4:
- # use freedb year and genre data if available
- if cf['_id3_genre'] == -1:
- cf['_id3_genre'] = track_names[0][3]
- if cf['_id3_year'] == -1:
- cf['_id3_year'] = track_names[0][2]
+ # use freedb year and genre data if available
+ if cf['_id3_year'] == -1 and len(track_names[0]) >= 3:
+ cf['_id3_year'] = track_names[0][2]
+ if cf['_id3_genre'] == -1 and len(track_names[0]) == 4:
+ cf['_id3_genre'] = track_names[0][3]
print "Tagging",
for i in jack_ripstuff.all_tracks_todo_sorted:
--
Martin Michlmayr
http://www.cyrius.com/
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]