tag 320116 + patch forwarded 320116 Arne Zellentin <[EMAIL PROTECTED]> thanks
* Philipp Weis <[EMAIL PROTECTED]> [2005-07-27 00:04]: > I just came accross a freedb entry which is so long that the resulting > file name would be too long. I get the following error message: > > | Tagging. *error* Cannot rename "track_01.ogg" to "Béla Bartók- Krystian > Zimerman - > | Leif Ove Andsnes - Hélène Grimaud - Pierre Boulez - The Piano > | Concertos Nos. 1-3 - Krystian Zimerman - Leif Ove Andsnes - Hélène > | Grimaud - Pierre Boulez - 01 - Krystian Zimerman - Chicago Symphony > | Orchestra - Pierre Boulez % Allegro moderato - Allegro.ogg" > (Filename > | is too long or has unusable characters) > > There is no obvious way to tell jack to tag these files without renaming them. > I got it to work with '--rename-ftm "%n"', but something like '--rename=no' > would be nicer. I agree that such an option would be good. > Another nice option would be to crop filenames that are too long. I don't really like this idea, especially since there can be other reasons why a rename fails (e.g. VFAT doesn't allow specific characters). Anyway, I looked at the code to see how this can be implemented... I noticed there's a -R/--rename option but this code is really a mess: -R doesn't actually do anything at all. And the internal freedb_rename variable (which has nothing to do with -R) is completely useless too: jack tries to do renames even when you don't use -Q/-q at all (i.e. just 'jack -t 1') and then fails: Traceback (most recent call last): File "/usr/bin/jack", line 270, in ? jack_tag.tag(1) File "/usr/lib/python2.3/site-packages/jack_tag.py", line 70, in tag if cf['_id3_year'] == -1 and len(track_names[0]) >= 3: TypeError: unsubscriptable object I tried to clean up the code, and I introduced a --dont-rename variable. In the patch, I got rid of all the freedb_rename variables (which don't actually do anything), got rid of -R/--rename (which again, doesn't do anything, and doesn't make sense since -Q/-q automatically renames). I won't apply this to the Debian package for now since I'd ideally like to hear comments from upstream. In particular, I'm not sure if --dont-rename is such a good name but --rename=no doesn't seem good to me either given that --rename=yes doesn't actually do anything (it's implied by -Q/-q anyway). Philipp, feel free to apply this patch though and let me know if this is what you want. Oh, by the way, even with --dont-rename, directories *are* renamed. This is because there's another option to stop this: --rename-dir=bool Hmm, looking at this, maybe the --dont-rename option should be called --rename-files=bool after all. Arne/Michael, what do you think? (BTW, this patch depends on some other Debian patches.) diff -urN jack-3.1.1~/jack jack-3.1.1/jack --- jack-3.1.1~/jack 2005-11-10 11:36:23.000000000 +0000 +++ jack-3.1.1/jack 2005-11-10 11:36:30.000000000 +0000 @@ -144,17 +144,16 @@ sys.exit(0) ### (9) do query on start -freedb_rename = 0 if cf['_query_if_needed']: if not os.path.exists(cf['_freedb_form_file'] + ".bak"): cf['_query_on_start'] = 1 if cf['_query_on_start']: - freedb_rename = jack_prepare.query_on_start(todo) + jack_prepare.query_on_start(todo) ### (10) update freedb dbfile if cf['_update_freedb']: if not jack_tag.track_names: - err, jack_tag.track_names, jack_tag.locale_names, freedb_rename, revision = jack_freedb.interpret_db_file(jack_ripstuff.all_tracks, todo, cf['_freedb_form_file'], verb = 1, dirs = 0) + err, jack_tag.track_names, jack_tag.locale_names, revision = jack_freedb.interpret_db_file(jack_ripstuff.all_tracks, todo, cf['_freedb_form_file'], verb = 1, dirs = 0) jack_freedb.freedb_template(jack_ripstuff.all_tracks, jack_tag.track_names, revision + 1) jack_utils.ex_edit(cf['_freedb_form_file']) info("now submit your changes if you like, using the option --submit (via http POST). Don't forget to activate your changes locally with -R") @@ -251,7 +250,7 @@ jack_display.exit() if cf['_query_when_ready'] or cf['_read_freedb_file'] or cf['_query_on_start']: - err, jack_tag.track_names, jack_tag.locale_names, freedb_rename, revision = jack_freedb.interpret_db_file(jack_ripstuff.all_tracks, todo, cf['_freedb_form_file'], verb = 1, dirs = 1) + err, jack_tag.track_names, jack_tag.locale_names, revision = jack_freedb.interpret_db_file(jack_ripstuff.all_tracks, todo, cf['_freedb_form_file'], verb = 1, dirs = 1) if err: error("could not read freedb file") @@ -266,7 +265,7 @@ os.system(cf['_exec_err']) error("aborting because of previous error(s) [%i]." % global_error) -jack_tag.tag(freedb_rename) +jack_tag.tag() if jack_functions.progress_changed: jack_functions.progress("all", "done", time.strftime("%b %2d %H:%M:%S", time.localtime(time.time()))) diff -urN jack-3.1.1~/jack.man jack-3.1.1/jack.man --- jack-3.1.1~/jack.man 2005-11-10 11:36:23.000000000 +0000 +++ jack-3.1.1/jack.man 2005-11-10 11:38:23.000000000 +0000 @@ -147,6 +147,12 @@ .B \-\-dir-template string if directories are renamed, this is the format used (default "%a/%l") .TP +.B \-\-dont\-rename +don't rename audo files after tagging them. This can be useful on +filesystems, such as FAT, which have filename limits. Another option +in this case is to specify +.B \-\-rename\-fmt. +.TP .B \-d, \-\-dont-work don't do DAE, encoding, tagging or renaming. This may be useful if you only want to do a FreeDB query, e.g. while another jack is running. @@ -294,20 +300,6 @@ have Jack remove its temp jack*-files. Be careful - don't delete them too early! .TP -.B \-R, \-\-rename -rename and tag files according to FreeDB file. On startup, Jack -creates a blank FreeDB entry file (except if -.B \-\-query-now -is used, -then the file is queried from your FreeDB server). If you have -changed its contents (e.g. because the CD was unknown to FreeDB) -and want to rename and tag your MP3s accordingly, use this option. -Give all other needed options too, like -.B \-t -, -.B \-E -, ... -.TP .B \-\-rename-dir=bool rename directory as well (default). .TP diff -urN jack-3.1.1~/jack_checkopts.py jack-3.1.1/jack_checkopts.py --- jack-3.1.1~/jack_checkopts.py 2005-11-10 11:36:23.000000000 +0000 +++ jack-3.1.1/jack_checkopts.py 2005-11-10 11:36:30.000000000 +0000 @@ -56,9 +56,6 @@ if cf2.has_key('create_dirs') and cf2['create_dirs']['val']: cf.rupdate({'rename_dir': {'val': 1}}, "check") - if cf2.has_key('freedb_rename') and cf2['freedb_rename']['val']: - cf.rupdate({'read_freedb_file': {'val': 1}, 'set_id3tag':{'val': 1}}, "check") - if cf2.has_key('id3_genre_txt'): genre = jack_functions.check_genre_txt(cf2['id3_genre_txt']['val']) if genre != cf['_id3_genre']: diff -urN jack-3.1.1~/jack_config.py jack-3.1.1/jack_config.py --- jack-3.1.1~/jack_config.py 2005-11-10 11:36:23.000000000 +0000 +++ jack-3.1.1/jack_config.py 2005-11-10 11:36:30.000000000 +0000 @@ -585,14 +585,20 @@ 'doc': "read freedb file", }, 'freedb_rename': { + # Only for backwards compatibility: doesn't do anything 'type': 'toggle', 'val': 0, - 'help': 1, - 'save': 0, - 'usage': "rename according to freedb file, eg. after editing it", + 'help': 0, 'long': 'rename', 'short': 'R', }, + 'dont_rename': { + 'type': 'toggle', + 'val': 0, + 'save': 0, + 'usage': "don't rename files after tagging them", + 'long': 'AUTO', + }, 'set_id3tag': { 'type': 'toggle', 'val': 0, diff -urN jack-3.1.1~/jack_freedb.py jack-3.1.1/jack_freedb.py --- jack-3.1.1~/jack_freedb.py 2005-11-10 11:36:23.000000000 +0000 +++ jack-3.1.1/jack_freedb.py 2005-11-10 11:36:30.000000000 +0000 @@ -57,16 +57,9 @@ def interpret_db_file(all_tracks, todo, freedb_form_file, verb, dirs = 0, warn = None): "read freedb file and rename dir(s)" global names_available, dir_created - freedb_rename = 0 - if warn == None: - err, track_names, locale_names, cd_id, revision = freedb_names(freedb_id(all_tracks), all_tracks, todo, freedb_form_file, verb = verb) - else: - err, track_names, locale_names, cd_id, revision = freedb_names(freedb_id(all_tracks), all_tracks, todo, freedb_form_file, verb = verb, warn = warn) - if (not err) and dirs: - freedb_rename = 1 - + err, track_names, locale_names, cd_id, revision = freedb_names(freedb_id(all_tracks), all_tracks, todo, freedb_form_file, verb = verb) + if dirs and not err: # The user wants us to use the current dir, unconditionally. - if cf['_claim_dir']: dir_created = jack_utils.split_dirname(os.getcwd())[-1] jack_functions.progress("all", "mkdir", dir_created) @@ -80,7 +73,6 @@ # only do the following if we are where we think we are and the dir has to be # renamed. - if jack_utils.check_path(dirs_created, old_dirs) and not jack_utils.check_path(dirs_created, new_dirs): jack_utils.rename_path(dirs_created, new_dirs) print "Info: cwd now", os.getcwd() @@ -88,9 +80,7 @@ if not err: names_available = 1 - else: - freedb_rename = 0 - return err, track_names, locale_names, freedb_rename, revision + return err, track_names, locale_names, revision #/ end of interpret_db_file /# def local_freedb(cd_id, freedb_dir, outfile = "/tmp/testfilefreedb"): diff -urN jack-3.1.1~/jack_prepare.py jack-3.1.1/jack_prepare.py --- jack-3.1.1~/jack_prepare.py 2005-11-10 11:36:23.000000000 +0000 +++ jack-3.1.1/jack_prepare.py 2005-11-10 11:36:30.000000000 +0000 @@ -519,12 +519,11 @@ freedb_submit(jack_progress.status_all['freedb_cat']) if cf['_query_on_start']: - err, jack_tag.track_names, jack_tag.locale_names, freedb_rename, revision = jack_freedb.interpret_db_file(jack_ripstuff.all_tracks, todo, cf['_freedb_form_file'], verb = cf['_query_on_start'], dirs = 1) + err, jack_tag.track_names, jack_tag.locale_names, revision = jack_freedb.interpret_db_file(jack_ripstuff.all_tracks, todo, cf['_freedb_form_file'], verb = cf['_query_on_start'], dirs = 1) if err: error("query on start failed to give a good freedb file, aborting.") else: - err, jack_tag.track_names, jack_tag.locale_names, freedb_rename, revision = jack_freedb.interpret_db_file(jack_ripstuff.all_tracks, todo, cf['_freedb_form_file'], verb = cf['_query_on_start'], warn = cf['_query_on_start']) - return freedb_rename + err, jack_tag.track_names, jack_tag.locale_names, revision = jack_freedb.interpret_db_file(jack_ripstuff.all_tracks, todo, cf['_freedb_form_file'], verb = cf['_query_on_start'], warn = cf['_query_on_start']) def undo_rename(status, todo): ext = jack_targets.targets[jack_helpers.helpers[cf['_encoder']]['target']]['file_extension'] diff -urN jack-3.1.1~/jack_tag.py jack-3.1.1/jack_tag.py --- jack-3.1.1~/jack_tag.py 2005-11-10 11:36:23.000000000 +0000 +++ jack-3.1.1/jack_tag.py 2005-11-10 11:36:30.000000000 +0000 @@ -41,7 +41,7 @@ a_artist = None a_title = None -def tag(freedb_rename): +def tag(): global a_artist, a_title ext = jack_targets.targets[jack_helpers.helpers[cf['_encoder']]['target']]['file_extension'] @@ -63,7 +63,7 @@ p_artist = locale_names[0][0] # string p_title = locale_names[0][1] # string - if cf['_set_id3tag'] or freedb_rename: + if cf['_set_id3tag'] and jack_freedb.names_available: jack_m3u.init() # use freedb year and genre data if available if cf['_id3_year'] == -1 and len(track_names[0]) >= 3: @@ -192,7 +192,7 @@ if cf['_id3_year'] != -1: oggi.add_tag('DATE', `cf['_id3_year']`) oggi.write_to(mp3name) - if freedb_rename: + if not cf['_dont_rename']: if t_artist: # 'Various Artists' replacelist = (("%n", cf['_rename_num'] % i[NUM]), ("%a", t_artist), ("%t", t_name), ("%l", a_title), ("%y", `cf['_id3_year']`), ("%g", genretxt)) newname = jack_misc.multi_replace(cf['_rename_fmt_va'], replacelist) -- Martin Michlmayr http://www.cyrius.com/