示例#1
0
    def save_tag(self):
        """Updates the tag with the GUI data."""

        tag = self.tag

        for key, values in tag.iteritems():
            if isinstance(values, APETextValue):
                del tag[key]

        tb = self.tag_frame.tb
        lines = tb.get_text(tb.get_start_iter(),
                            tb.get_end_iter()).splitlines()

        for line in lines:
            try:
                key, val = line.split("=", 1)
            except ValueError:
                continue
            else:
                key = key.strip()
                val = val.strip()
                if val:
                    try:
                        tag[key].value += "\0" + val.decode("utf-8")
                    except (KeyError, AttributeError):
                        try:
                            tag[key] = APETextValue(val.decode("utf-8"), 0)
                        except KeyError:
                            print("Unacceptable key", key)

        tag.save()
示例#2
0
 def producer(self, producer: str):
     self.file['producer'] = APETextValue(value=producer, kind=0)
     return self
示例#3
0
 def disc_number(self, disc: str):
     self.file['DISCNUMBER'] = APETextValue(value=disc, kind=0)
     return self
示例#4
0
 def composer(self, composer: str):
     self.file['COMPOSER'] = APETextValue(value=composer, kind=0)
     return self
示例#5
0
 def track_number(self, track_number: str):
     self.file['Track'] = APETextValue(value=track_number, kind=0)
     return self
示例#6
0
 def genre(self, genre: str):
     self.file['Genre'] = APETextValue(value=genre, kind=0)
     return self
示例#7
0
 def album(self, album: str):
     self.file['Album'] = APETextValue(value=album, kind=0)
     return self
示例#8
0
 def year(self, year: str):
     self.file['Year'] = APETextValue(value=year, kind=0)
     return self
示例#9
0
 def album_artist(self, artist: str):
     self.file['Album artist'] = self.file['ALBUMARTIST'] = APETextValue(
         value=artist, kind=0)
     return self
示例#10
0
 def artist(self, artist: str):
     self.file['Artist'] = APETextValue(value=artist, kind=0)
     return self
示例#11
0
 def comments(self, comments: str):
     self.file['Comment'] = APETextValue(value=comments, kind=0)
     return self
示例#12
0
 def subtitle(self, subtitle: str):
     self.file['subtitle'] = APETextValue(value=subtitle, kind=0)
     return self
示例#13
0
 def title(self, title: str):
     self.file['Title'] = APETextValue(value=title, kind=0)
     return self