Package: eyed3 Version: 0.6.18-1 Severity: wishlist Tags: upstream patch Dear Maintainer,
I added an option to have the value written into the tag come from the substitution of other tag values and/or the filename according to a pattern. Just as you can use a pattern for the filename to rename to, you can use a pattern for the tag value. I had downloaded some files with DownThemAll asking to name the files from the link text. The filename was more accurate as a tittle than the title tag, so I wanted to replace the tittle with the filename and the old title. Maybe I should have changed the tag class and introduce the old filename as a variable for renaming the file too. I'm not sure how lively this package is, so I'm just sending a patch that worked for me in case anyon emight find it useful. I'm sending this to debian because I'm not finding upstream, the url http://www.travisshirk.net/eyeD3/releases/ gives 404 Not Found -- System Information: Debian Release: 7.3 APT prefers stable-updates APT policy: (500, 'stable-updates'), (500, 'proposed-updates'), (500, 'stable') Architecture: i386 (i686) Foreign Architectures: armhf Kernel: Linux 3.2.0-4-686-pae (SMP w/2 CPU cores) Locale: LANG=ca_ES.UTF-8, LC_CTYPE=ca_ES.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages eyed3 depends on: ii python 2.7.3-4+deb7u1 ii python-eyed3 0.6.18-1 eyed3 recommends no packages. eyed3 suggests no packages. -- no debconf information
--- eyeD3.orig 2013-12-24 20:28:09.013765827 +0100 +++ eyeD3 2013-12-24 20:37:14.569426681 +0100 @@ -259,6 +259,11 @@ grp1.add_option("--remove-all", action="store_true", dest="remove_all", default=0, help="Remove both ID3 v1.x and v2.x tags."); + grp1.add_option("--pattern", action="store_true", + dest="pattern", default=0, + help="Treat the tag value given as a pattern using "\ + "substitution variables as with --rename, plus "\ + "%f for the filename (without directory or extension)."); optParser.add_option_group(grp1); # Misc. options. @@ -543,7 +548,7 @@ # Handle frame edits. try: - tagModified = self.handleEdits(self.tag) or self.opts.force_update; + tagModified = self.handleEdits(self.tag,f) or self.opts.force_update; except CommandException, ex: printError(ex); return self.R_HALT; @@ -610,7 +615,7 @@ return status; - def handleEdits(self, tag): + def handleEdits(self, tag,f): retval = 0; # First set new version if requested @@ -629,19 +634,19 @@ artist = self.opts.artist; if artist != None: printWarning("Setting artist: %s" % artist); - tag.setArtist(artist); + tag.setArtist(self.fill(f,tag,artist)); retval |= 1; album = self.opts.album; if album != None: printWarning("Setting album: %s" % album); - tag.setAlbum(album); + tag.setAlbum(self.fill(f,tag,album)); retval |= 1; title = self.opts.title; if title != None: printWarning("Setting title: %s" % title); - tag.setTitle(title); + tag.setTitle(self.fill(f,tag,title)); retval |= 1; discNum = self.opts.disc @@ -679,13 +684,13 @@ genre = self.opts.genre; if genre != None: printWarning("Setting track genre: %s" % genre); - tag.setGenre(genre); + tag.setGenre(self.fill(f,tag,genre)); retval |= 1; year = self.opts.year; if year != None: printWarning("Setting year: %s" % year); - tag.setDate(year); + tag.setDate(self.fill(f,tag,year)); retval |= 1; play_count = self.opts.play_count; @@ -728,7 +733,7 @@ pub = self.opts.publisher; if pub != None: printWarning("Setting publisher: %s" % (pub)); - tag.setPublisher(pub); + tag.setPublisher(self.fill(f,tag,pub)); retval |= 1; comments = self.opts.comments; @@ -746,7 +751,7 @@ printWarning("Removing comment: %s" % (desc)); else: printWarning("Setting comment: [%s]: %s" % (desc, comm)); - tag.addComment(comm, desc, lang); + tag.addComment(comm, self.fill(f,tag,desc), lang); retval |= 1; except ValueError: printError("Invalid Comment; see --help: %s" % c); @@ -929,6 +934,16 @@ return retval; + def fill(self,f,tag,pattern): + + if (self.opts.pattern): + result = tag.tagToString(pattern); + result = tag._subst(result,"%f",unicode(os.path.splitext(os.path.basename(f))[0], + self.opts.fs_encoding,'replace')); + else: + result = pattern; + return result; + def handleRenames(self, f, pattern, fs_encoding): try: name = f.getTag().tagToString(pattern);