Exemple #1
0
	def updateTags(self):
		self.tags = [];
		self.tagsById = {};
		self.versions = {};
		try:
			self._addTagsFromAudioFile(eyed3.load(self.fpath, (1,None,None)));
			self._addTagsFromAudioFile(eyed3.load(self.fpath, (2,None,None)));
		except (ValueError, SongException) as e:
			self._isBadFile = True;
Exemple #2
0
	def trimTags(self):
		changed = {};
		changed1 = self._trimTags(eyed3.load(self.fpath, (1,None,None)));
		if (changed1 != None):
			changed.update(changed1);
		changed2 = self._trimTags(eyed3.load(self.fpath, (2,None,None)));
		if (changed2 != None):
			changed.update(changed2);
		return changed;
Exemple #3
0
 def trimTags(self):
     changed = {}
     changed1 = self._trimTags(eyed3.load(self.fpath, (1, None, None)))
     if changed1 is not None:
         changed.update(changed1)
     changed2 = self._trimTags(eyed3.load(self.fpath, (2, None, None)))
     if changed2 is not None:
         changed.update(changed2)
     return changed
Exemple #4
0
 def updateTags(self):
     self.tags = []
     self.tagsById = {}
     self.versions = {}
     try:
         self._addTagsFromAudioFile(eyed3.load(self.fpath, (1, None, None)))
         self._addTagsFromAudioFile(eyed3.load(self.fpath, (2, None, None)))
     except (ValueError, SongException) as e:
         self._isBadFile = True
Exemple #5
0
	def remTags(self, toRemove):
		if self._isBadFile: return;
		for v in range(2, 0, -1):												#Check V2 then V1
			changed = False;
			af = eyed3.load(self.fpath, (v,None,None));							#Load the tags for the selected version
			if (af.tag != None):												#If there are any tags
				for tagid in toRemove:											#Iterate through the tags to be removed
					trv = toRemove[tagid];										#Get the version to be removed
					if (trv == None) or (int(trv) == v):						#If the version isn't set or matches the selected version
						if (tagid in af.tag.frame_set):							#If the tag id is present in the file
							af.tag.frame_set.pop(tagid);						#Remove it
							changed = True;										#Indicate that a change was made that should be saved
				if changed:														#If a change was made
					atv = af.tag.version;										#Check the version number of the tag
					if (atv[0] == 2):											#If it's version 2
						af.tag.save(version=(2,4,0));							#Save as version 2.4
					else:														#Otherwise if it's version 1
						af.tag.save(version=atv);								#Save as its original version
		self.updateTags();
Exemple #6
0
 def remTags(self, toRemove):
     if self._isBadFile: return
     for v in range(2, 0, -1):  #Check V2 then V1
         changed = False
         af = eyed3.load(
             self.fpath,
             (v, None, None))  #Load the tags for the selected version
         if af.tag is not None:  #If there are any tags
             for tagid in toRemove:  #Iterate through the tags to be removed
                 trv = toRemove[tagid]  #Get the version to be removed
                 if (trv is None) or (
                         int(trv) == v
                 ):  #If the version isn't set or matches the selected version
                     if tagid in af.tag.frame_set:  #If the tag id is present in the file
                         af.tag.frame_set.pop(tagid)  #Remove it
                         changed = True  #Indicate that a change was made that should be saved
             if changed:  #If a change was made
                 atv = af.tag.version  #Check the version number of the tag
                 if atv[0] == 2:  #If it's version 2
                     af.tag.save(version=(2, 4, 0))  #Save as version 2.4
                 else:  #Otherwise if it's version 1
                     af.tag.save(version=atv)  #Save as its original version
     self.updateTags()
Exemple #7
0
    def remove_tag(self, tag_id, tag_val):
        if self._isBadFile: return
        for v in range(2, 0, -1):  #Check V2 then V1
            changed = False
            af = eyed3.load(
                self.fpath,
                (v, None, None))  #Load the tags for the selected version
            if af.tag is not None:  #If there are any tags
                if tag_id in af.tag.frame_set:
                    for i, frame in enumerate(af.tag.frame_set[tag_id]):
                        if hasattr(frame, "text") and frame.text == tag_val:
                            print("Removing {} # {} from {}".format(
                                tag_id, i, self.fpath))
                            af.tag.frame_set[tag_id].pop(i)
                            changed = True
                            break

                if changed:  #If a change was made
                    atv = af.tag.version  #Check the version number of the tag
                    if atv[0] == 2:  #If it's version 2
                        af.tag.save(version=(2, 4, 0))  #Save as version 2.4
                    else:  #Otherwise if it's version 1
                        af.tag.save(version=atv)  #Save as its original version
                    self.updateTags()
Exemple #8
0
 def convert_comment_to_lyrics(self):
     if self._isBadFile: return
     for v in range(2, 0, -1):
         changed = False
         af = eyed3.load(self.fpath, (v, None, None))
         if af is not None and af.tag is not None:
             if "COMM" in af.tag.frame_set:
                 comm_frames = af.tag.frame_set["COMM"]
                 if len(comm_frames) > 1:
                     raise ValueError(
                         "Expected only one comment frame, found {}".format(
                             len(comm_frames)))
                 comment = af.tag.frame_set["COMM"].pop(0)
                 lyrics = eyed3.id3.frames.LyricsFrame(text=comment.text)
                 print("Converting comment to lyrics for {}".format(
                     self.fpath))
                 af.tag.frame_set["USLT"] = lyrics
                 atv = af.tag.version
                 if atv[0] == 2:
                     af.tag.save(version=(2, 4, 0))
                 else:
                     af.tag.save(version=atv)
                 self.updateTags()
                 break
Exemple #9
0
 def raw_tags(self, id3_ver=2):
     af = eyed3.load(self.fpath, (id3_ver, None, None))
     return af.tag.frame_set
Exemple #10
0
 def raw_audio_file(self, id3_ver=2):
     return eyed3.load(self.fpath, (id3_ver, None, None))