def testTagGenre(): from eyed3.id3 import Genre tag = Tag() assert (tag.genre is None) try: tag.genre = b"Not Unicode" except TypeError: pass # expected else: assert not("Non unicode genre, expected TypeError") gobj = Genre("Hardcore") tag.genre = "Hardcore" assert (tag.genre.name == "Hardcore") assert (tag.genre == gobj) tag.genre = 130 assert tag.genre.id == 130 assert tag.genre.name == "Terror" tag.genre = 0 assert tag.genre.id == 0 assert tag.genre.name == "Blues" tag.genre = None assert tag.genre is None assert tag.frame_set[b"TCON"] is None
def testTagGenre(): from eyed3.id3 import Genre tag = Tag() assert (tag.genre is None) try: tag.genre = b"Not Unicode" except TypeError: pass # expected else: assert not ("Non unicode genre, expected TypeError") gobj = Genre(u"Hardcore") tag.genre = u"Hardcore" assert (tag.genre.name == u"Hardcore") assert (tag.genre == gobj) tag.genre = 130 assert tag.genre.id == 130 assert tag.genre.name == u"Terror" tag.genre = 0 assert tag.genre.id == 0 assert tag.genre.name == u"Blues" tag.genre = None assert tag.genre is None assert tag.frame_set[b"TCON"] is None
def testTagGenre(): from eyed3.id3 import Genre tag = Tag() assert_is_none(tag.genre) try: tag.genre = "Not Unicode" except TypeError: pass # expected else: assert_false("Non unicode genre, expected TypeError") gobj = Genre(u"Hardcore") tag.genre = u"Hardcore" assert_equal(tag.genre.name, u"Hardcore") assert_equal(tag.genre, gobj) tag.genre = 130 assert_equal(tag.genre.id, 130) assert_equal(tag.genre.name, u"Terror") tag.genre = 0 assert_equal(tag.genre.id, 0) assert_equal(tag.genre.name, u"Blues") tag.genre = None assert_is_none(tag.genre) assert_is_none(tag.frame_set["TCON"])
def gen_tag(self, track, fake_art=False): tag = Tag() if track.has_key('album'): tag.album = track['album'] if track.has_key('artist'): tag.artist = track['artist'] if track.has_key('title'): tag.title = track['title'] if track.has_key('discNumber'): tag.disc_num = int(track['discNumber']) if track.has_key('trackNumber'): tag.track_num = int(track['trackNumber']) if track.has_key('genre'): tag.genre = track['genre'] if track.has_key('albumArtist') and track['albumArtist'] != track['artist']: tag.album_artist = track['albumArtist'] if track.has_key('year') and int(track['year']) != 0: tag.recording_date = track['year'] if track.has_key('albumArtRef'): art = None if self.__art is None: if fake_art: art = '\0' * self.__art_size else: if self.load_art(): art = self.__art else: art = None else: art = self.__art if art is not None: tag.images.set(0x03, art, 'image/jpeg', u'Front cover') return tag
def gen_tag(self, track, fake_art=False): tag = Tag() if track.has_key('album'): tag.album = track['album'] if track.has_key('artist'): tag.artist = track['artist'] if track.has_key('title'): tag.title = track['title'] if track.has_key('discNumber'): tag.disc_num = int(track['discNumber']) if track.has_key('trackNumber'): tag.track_num = int(track['trackNumber']) if track.has_key('genre'): tag.genre = track['genre'] if track.has_key( 'albumArtist') and track['albumArtist'] != track['artist']: tag.album_artist = track['albumArtist'] if track.has_key('year') and int(track['year']) != 0: tag.recording_date = track['year'] if track.has_key('albumArtRef'): art = None if self.__art is None: if fake_art: art = '\0' * self.__art_size else: if self.load_art(): art = self.__art else: art = None else: art = self.__art if art is not None: tag.images.set(0x03, art, 'image/jpeg', u'Front cover') return tag
def test_issue382_genres(audiofile): """Tags always written in v2.3 format, always including ID. https://github.com/nicfit/eyeD3/issues/382 """ tag = Tag() tag.genre = "Dubstep" assert tag.genre.id == 189 assert tag.genre.name == "Dubstep" audiofile.tag = tag tag.save() new_audiofile = eyed3.load(audiofile.path) # Prior versions would be `(189)Dubstep`, now no index. assert new_audiofile.tag.frame_set[b"TCON"][0].text == "Dubstep"
def set_mp3_album_tags(data: Dict[str, str], tag: id3.Tag, episode_num: int): # set album title and cover image tag.album = data["album"] image_type = id3.frames.ImageFrame.FRONT_COVER image_file = os.path.join("/srv", data["cover"].lstrip("/")) image_mime = mimetype.guessMimetype(image_file) # set cover image with open(image_file, "rb") as f: tag.images.set(image_type, f.read(), image_mime, "") # set various meta info tag.artist = data["artist"] tag.track_num = (episode_num, episode_num) tag.title = Template(data["title"]).substitute(episode_num=episode_num) tag.release_date = str(date.today()) tag.genre = "Podcast"
def gen_tag(self, track, fake_art=False): tag = Tag() if track.has_key('album'): tag.album = track['album'] if track.has_key('artist'): tag.artist = " / ".join(track['artist']) if len(track['artist']) == 2: print track['artist'] if track.has_key('title'): tag.title = track['title'] if track.has_key('discNumber') and self.show_discnum: tag.disc_num = int(track['discNumber']) if track.has_key('trackNumber'): tag.track_num = int(track['trackNumber']) if track.has_key('genre'): tag.genre = track['genre'] if track.has_key('albumArtist') and (len(track['artist']) != 1 or track['albumArtist'] != track['artist'][0]): tag.setTextFrame('TPE2', track['albumArtist']) if track.has_key('year') and int(track['year']) != 0: tag.recording_date = track['year'] if track.has_key('albumArtRef'): art = None if self.__art is None: if fake_art: art = '\0' * self.__art_size else: if self.load_art(): art = self.__art else: art = None else: art = self.__art if art is not None: tag.images.set(0x03, art, 'image/jpeg', u'Front cover') return tag
# # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/> ################################################################################ from eyed3.id3 import Tag from eyed3.id3 import ID3_V1_0, ID3_V1_1, ID3_V2_3, ID3_V2_4 import logging from eyed3 import log log.setLevel(logging.DEBUG) t = Tag() t.artist = u"M.O.P." t.title = u"How About Some Hardcore" t.album = u"To The Death" t.genre = u"Hip-Hop" t.track_num = (3, 5) t.disc_num = (1, 1) t.original_release_date = "1994-04-07" t.release_date = "1994-04-07" t.encoding_date = "2002-03" t.recording_date = 1996 t.tagging_date = "2012-2-5" t.comments.set(u"Gritty, yo!") t.comments.set(u"Brownsville, Brooklyn", u"Origin") t.user_text_frames.set(u"****", u"Rating") t.artist_url = b"http://allmusic.com/artist/mop-p194909" t.user_url_frames.set(b"http://eyed3.nicfit.net/")
#!/usr/bin/env python from eyed3.id3 import Tag from eyed3.id3 import ID3_V1_0, ID3_V1_1, ID3_V2_3, ID3_V2_4 import logging from eyed3 import log log.setLevel(logging.DEBUG) t = Tag() t.artist = "M.O.P." t.title = "How About Some Hardcore" t.album = "To The Death" t.genre = "Hip-Hop" t.track_num = (3, 5) t.disc_num = (1, 1) t.original_release_date = "1994-04-07" t.release_date = "1994-04-07" t.encoding_date = "2002-03" t.recording_date = 1996 t.tagging_date = "2012-2-5" t.comments.set("Gritty, yo!") t.comments.set("Brownsville, Brooklyn", "Origin") t.user_text_frames.set("****", "Rating") t.artist_url = b"http://allmusic.com/artist/mop-p194909" t.user_url_frames.set(b"http://eyed3.nicfit.net/") t.bpm = 187 t.play_count = 125
# # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/> ################################################################################ from eyed3.id3 import Tag from eyed3.id3 import ID3_V1_0, ID3_V1_1, ID3_V2_3, ID3_V2_4 import logging from eyed3 import log log.setLevel(logging.DEBUG) t = Tag() t.artist = u"M.O.P." t.title = u"How About Some Hardcore" t.album = u"To The Death" t.genre = u"Hip-Hop" t.track_num = (3,5) t.disc_num = (1,1) t.original_release_date = "1994-04-07" t.release_date = "1994-04-07" t.encoding_date = "2002-03" t.recording_date = 1996 t.tagging_date = "2012-2-5" t.comments.set(u"Gritty, yo!") t.comments.set(u"Brownsville, Brooklyn", u"Origin") t.user_text_frames.set(u"****", u"Rating") t.artist_url = b"http://allmusic.com/artist/mop-p194909" t.user_url_frames.set(b"http://eyed3.nicfit.net/")