From: Oleg Broytman Date: Sat, 7 Dec 2019 20:26:54 +0000 (+0300) Subject: Fix(audio/mp3): Adapt code to newer version of `eyed3` X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=276d923954a25e142b349c78bb5dae23f476d00e;p=audio-cdr-video.git Fix(audio/mp3): Adapt code to newer version of `eyed3` --- diff --git a/audio/mp3/id3images.py b/audio/mp3/id3images.py index 6792ee0..461269c 100755 --- a/audio/mp3/id3images.py +++ b/audio/mp3/id3images.py @@ -3,8 +3,8 @@ import sys args = sys.argv[1:] -import eyeD3 -from eyeD3.tag import Mp3AudioFile +import eyed3 +from eyed3.mp3 import Mp3AudioFile def id3tag_recode(value): @@ -40,12 +40,12 @@ for filename in args: if not id3tag: sys.exit() - for version in eyeD3.ID3_V2, eyeD3.ID3_V1: - id3tag = eyeD3.Tag() - if not id3tag.link(filename, version): + for version in eyed3.id3.ID3_V2, eyed3.id3.ID3_V1: + id3tag = eyed3.id3.tag.Tag() + if not id3tag.parse(filename, version): continue - images = id3tag.getImages() + images = id3tag.images if images: for image in images: image.writeFile() diff --git a/audio/mp3/id3info.py b/audio/mp3/id3info.py index 5332fbd..f07fcb0 100755 --- a/audio/mp3/id3info.py +++ b/audio/mp3/id3info.py @@ -3,8 +3,8 @@ import sys from getopt import getopt, GetoptError -import eyeD3 -from eyeD3.tag import Mp3AudioFile +import eyed3 +from eyed3.mp3 import Mp3AudioFile def usage(msg): @@ -73,27 +73,27 @@ for filename in args: if not id3tag: sys.exit() - for version in eyeD3.ID3_V2, eyeD3.ID3_V1: - id3tag = eyeD3.Tag() - if not id3tag.link(filename, version): + for version in eyed3.id3.ID3_V2, eyed3.id3.ID3_V1: + id3tag = eyed3.id3.tag.Tag() + if not id3tag.parse(filename, version): continue print '-----' - printFrame("id3tag version", id3tag.getVersionStr()) - printFrame("Artist", id3tag_recode(id3tag.getArtist())) - printFrame("Album", id3tag_recode(id3tag.getAlbum())) - printFrame("Title", id3tag_recode(id3tag.getTitle())) - dates = id3tag.getDate() + printFrame("id3tag version", id3tag.versionStr) + printFrame("Artist", id3tag_recode(id3tag.artist)) + printFrame("Album", id3tag_recode(id3tag.album)) + printFrame("Title", id3tag_recode(id3tag.title)) + dates = id3tag.date if dates: printFramesList("Date", [date.getDate() for date in dates]) try: - printFrame("Genre", id3tag.getGenre().getName()) + printFrame("Genre", id3tag.genre.getName()) except: # Unknown id3tag or no id3tag at all pass - printTrack("Track num", id3tag.getTrackNum()) - printFramesList("Disc num", [str(n) for n in id3tag.getDiscNum() if n]) - printFramesList("Comments", [id3tag_recode(frame.comment) for frame in id3tag.getComments() if frame]) - printFramesList("Lyrics", [frame.description for frame in id3tag.getLyrics()]) - if id3tag.getImages(): + printTrack("Track num", id3tag.trackNum) + printFramesList("Disc num", [str(n) for n in id3tag.discNum if n]) + printFramesList("Comments", [id3tag_recode(frame.comment) for frame in id3tag.comments if frame]) + printFramesList("Lyrics", [frame.description for frame in id3tag.lyrics]) + if id3tag.images: print "Has images" - printFramesList("URLs", [frame.url for frame in id3tag.getURLs()]) + printFramesList("URLs", [frame.url for frame in id3tag.uRLs]) diff --git a/audio/mp3/id3v1-to-v2.py b/audio/mp3/id3v1-to-v2.py index 022f64c..5ccbda6 100755 --- a/audio/mp3/id3v1-to-v2.py +++ b/audio/mp3/id3v1-to-v2.py @@ -3,13 +3,13 @@ import sys from os import utime from os.path import getmtime -import eyeD3 +import eyed3 for filename in sys.argv[1:]: mtime = getmtime(filename) - id3tag = eyeD3.Tag() - id3tag.link(filename, eyeD3.ID3_V1) + id3tag = eyed3.id3.tag.Tag() + id3tag.parse(filename, eyed3.id3.ID3_V1) - id3tag.setVersion(eyeD3.ID3_V2) + id3tag.setVersion(eyed3.id3.ID3_V2) id3tag.update() utime(filename, (mtime, mtime)) diff --git a/audio/mp3/id3v2-to-v1.py b/audio/mp3/id3v2-to-v1.py index 1a47ed6..7e77c92 100755 --- a/audio/mp3/id3v2-to-v1.py +++ b/audio/mp3/id3v2-to-v1.py @@ -3,13 +3,13 @@ import sys from os import utime from os.path import getmtime -import eyeD3 +import eyed3 for filename in sys.argv[1:]: mtime = getmtime(filename) - id3tag = eyeD3.Tag() - id3tag.link(filename, eyeD3.ID3_V2) + id3tag = eyed3.id3.tag.Tag() + id3tag.parse(filename, eyed3.id3.ID3_V2) - id3tag.setVersion(eyeD3.ID3_V1) + id3tag.setVersion(eyed3.id3.ID3_V1) id3tag.update() utime(filename, (mtime, mtime)) diff --git a/audio/mp3/list-id3v2-frames.py b/audio/mp3/list-id3v2-frames.py index 926f5f3..5a9efac 100755 --- a/audio/mp3/list-id3v2-frames.py +++ b/audio/mp3/list-id3v2-frames.py @@ -1,16 +1,16 @@ #! /usr/bin/env python import sys -import eyeD3 -from eyeD3.frames import id3EncodingToString +import eyed3 +from eyed3.id3.frames import id3EncodingToString import locale locale.setlocale(locale.LC_ALL, '') for file in sys.argv[1:]: print "File:", file - tag = eyeD3.Tag() - tag.link(file) + tag = eyed3.id3.Tag() + tag.parse(file) for frame in tag.frames: print str(frame) if hasattr(frame, "text"): diff --git a/audio/mp3/name2tag.py b/audio/mp3/name2tag.py index 950721c..b6bab69 100755 --- a/audio/mp3/name2tag.py +++ b/audio/mp3/name2tag.py @@ -1,8 +1,8 @@ #! /usr/bin/env python import sys -import eyeD3 -from eyeD3.frames import UTF_8_ENCODING +import eyed3 +from eyed3.id3.frames import UTF_8_ENCODING from os import utime from os.path import getmtime, splitext, basename @@ -15,18 +15,18 @@ for filename in filenames: name = splitext(basename(filename))[0] mtime = getmtime(filename) - id3tag = eyeD3.Tag() - id3tag.link(filename) + id3tag = eyed3.id3.tag.Tag() + id3tag.parse(filename) match = mp3_file.match(name) if match: name = match.group(2) - id3tag.setVersion(eyeD3.ID3_V2) + id3tag.setVersion(eyed3.id3.ID3_V2) id3tag.setTextEncoding(UTF_8_ENCODING) id3tag.setTitle(name) - print id3tag.getTitle() + print id3tag.title id3tag.update() utime(filename, (mtime, mtime)) diff --git a/audio/mp3/recode-id3.py b/audio/mp3/recode-id3.py index a0aebee..c03dc5a 100755 --- a/audio/mp3/recode-id3.py +++ b/audio/mp3/recode-id3.py @@ -5,8 +5,8 @@ from os import utime from os.path import getmtime from getopt import getopt, GetoptError -import eyeD3 -from eyeD3.frames import id3EncodingToString, \ +import eyed3 +from eyed3.id3.frames import id3EncodingToString, \ LATIN1_ENCODING, UTF_16_ENCODING, UTF_16BE_ENCODING, UTF_8_ENCODING from m_lib.opstring import recode @@ -60,9 +60,9 @@ def id3tag_set(frame, attr, src_encoding, dst_encoding): for filename in args: mtime = getmtime(filename) - for version in eyeD3.ID3_V2, eyeD3.ID3_V1: - id3tag = eyeD3.Tag() - if not id3tag.link(filename, version): + for version in eyed3.id3.ID3_V2, eyed3.id3.ID3_V1: + id3tag = eyed3.id3.tag.Tag() + if not id3tag.parse(filename, version): continue if not src_encoding: @@ -74,7 +74,7 @@ for filename in args: elif hasattr(frame, "comment"): id3tag_set(frame, "comment", src_encoding, dst_encoding) - title_frame = id3tag.getTitle() + title_frame = id3tag.title if title_frame: try: print title_frame @@ -83,9 +83,9 @@ for filename in args: else: print filename - if id3tag.getVersion() == eyeD3.ID3_V2_2: - version = eyeD3.ID3_DEFAULT_VERSION + if id3tag.version == eyed3.id3.ID3_V2_2: + version = eyed3.id3.ID3_DEFAULT_VERSION else: - version = eyeD3.ID3_CURRENT_VERSION + version = eyed3.id3.ID3_CURRENT_VERSION id3tag.update(version=version) utime(filename, (mtime, mtime)) diff --git a/audio/mp3/remove-tag.py b/audio/mp3/remove-tag.py index c326654..802d092 100755 --- a/audio/mp3/remove-tag.py +++ b/audio/mp3/remove-tag.py @@ -45,17 +45,17 @@ from os import utime from os.path import getmtime mtime = getmtime(filename) -import eyeD3 +import eyed3 versions = [] if not write_id3v2: - versions.append(eyeD3.ID3_V2) + versions.append(eyed3.id3.ID3_V2) if not write_id3v1: - versions.append(eyeD3.ID3_V1) + versions.append(eyed3.id3.ID3_V1) for version in versions: - id3tag = eyeD3.Tag() - id3tag.link(filename, version) + id3tag = eyed3.id3.tag.Tag() + id3tag.parse(filename, version) id3tag.setVersion(version) id3tag.remove() diff --git a/audio/mp3/tag.py b/audio/mp3/tag.py index 569eaec..5e570cc 100755 --- a/audio/mp3/tag.py +++ b/audio/mp3/tag.py @@ -80,17 +80,17 @@ from os import utime from os.path import getmtime mtime = getmtime(filename) -import eyeD3 +import eyed3 versions = [] if write_id3v2: - versions.append(eyeD3.ID3_V2) + versions.append(eyed3.id3.ID3_V2) if write_id3v1: - versions.append(eyeD3.ID3_V1) + versions.append(eyed3.id3.ID3_V1) for version in versions: - id3tag = eyeD3.Tag() - id3tag.link(filename, version) + id3tag = eyed3.id3.tag.Tag() + id3tag.parse(filename, version) id3tag.setVersion(version) if album: id3tag.setAlbum(unicode(album, "latin1")) diff --git a/audio/mp3/tag2name.py b/audio/mp3/tag2name.py index 60aed7a..0254d9c 100755 --- a/audio/mp3/tag2name.py +++ b/audio/mp3/tag2name.py @@ -1,8 +1,8 @@ #! /usr/bin/env python import sys, os -import eyeD3 -from eyeD3.frames import TITLE_FID, id3EncodingToString +import eyed3 +from eyed3.id3.frames import TITLE_FID, id3EncodingToString from m_lib.defenc import default_encoding def id3tag_recode(value): @@ -13,7 +13,7 @@ def id3tag_recode(value): files = sys.argv[1:] for i, filename in enumerate(files): - id3tag = eyeD3.Tag() - id3tag.link(filename) - title = id3tag_recode(id3tag.getTitle()) + id3tag = eyed3.id3.tag.Tag() + id3tag.parse(filename) + title = id3tag_recode(id3tag.title) os.rename(filename, '%d - %s.mp3' % (i+1, title)) diff --git a/audio/mp3/upgrade-id3tag.py b/audio/mp3/upgrade-id3tag.py index b0e3fc0..d9bad79 100755 --- a/audio/mp3/upgrade-id3tag.py +++ b/audio/mp3/upgrade-id3tag.py @@ -1,16 +1,16 @@ #! /usr/bin/env python import sys -import eyeD3 -from eyeD3.frames import TITLE_FID, id3EncodingToString +import eyed3 +from eyed3.id3.frames import TITLE_FID, id3EncodingToString from os import utime from os.path import getmtime for filename in sys.argv[1:]: mtime = getmtime(filename) - id3tag = eyeD3.Tag() - id3tag.link(filename) + id3tag = eyed3.id3.tag.Tag() + id3tag.parse(filename) title_frames = id3tag.frames[TITLE_FID] if title_frames: @@ -19,7 +19,7 @@ for filename in sys.argv[1:]: else: print filename - id3tag.setVersion(eyeD3.ID3_V2) + id3tag.setVersion(eyed3.id3.ID3_V2) id3tag.update() utime(filename, (mtime, mtime))