当前位置: 首页>>代码示例>>Python>>正文


Python id3.add函数代码示例

本文整理汇总了Python中mutagen.id3.add函数的典型用法代码示例。如果您正苦于以下问题:Python add函数的具体用法?Python add怎么用?Python add使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了add函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_tyer_tdat

 def test_tyer_tdat(self):
     id3 = ID3()
     id3.version = (2, 3)
     id3.add(TYER(encoding=0, text="2006"))
     id3.add(TDAT(encoding=0, text="0603"))
     id3.update_to_v24()
     self.failUnlessEqual(id3["TDRC"], "2006-03-06")
开发者ID:quodlibet,项目名称:mutagen,代码行数:7,代码来源:test_id3.py

示例2: setter

 def setter(id3, key, value):
     try:
         frame = id3[frameid]
     except KeyError:
         id3.add(mutagen.id3.Frames[frameid](encoding=3, text=value))
     else:
         frame.text = value
开发者ID:Knio,项目名称:tag2itunes,代码行数:7,代码来源:easyid3.py

示例3: test_chap_subframes

 def test_chap_subframes(self):
     id3 = ID3()
     id3.version = (2, 3)
     id3.add(CHAP(element_id="foo", start_time=0, end_time=0,
                  start_offset=0, end_offset=0,
                  sub_frames=[TYER(encoding=0, text="2006")]))
     id3.update_to_v24()
     chap = id3.getall("CHAP:foo")[0]
     self.assertEqual(chap.sub_frames.getall("TDRC")[0], u"2006")
开发者ID:gdelfresno,项目名称:mutagen,代码行数:9,代码来源:test_id3.py

示例4: gain_set

def gain_set(id3, key, value):
    if len(value) != 1:
        raise ValueError("there must be exactly one gain value, not %r.", value)
    gain = float(value[0].split()[0])
    try:
        frame = id3["RVA2:" + key[11:-5]]
    except KeyError:
        frame = mutagen.id3.RVA2(desc=key[11:-5], gain=0, peak=0, channel=1)
        id3.add(frame)
    frame.gain = gain
开发者ID:Knio,项目名称:tag2itunes,代码行数:10,代码来源:easyid3.py

示例5: performer_set

def performer_set(id3, key, value):
    wanted_role = key.split(":", 1)[1]
    try: mcl = id3["TMCL"]
    except KeyError:
        mcl = mutagen.id3.TMCL(encoding=3, people=[])
        id3.add(mcl)
    people = [p for p in mcl.people if p[0] != wanted_role]
    for v in value:
        people.append((wanted_role, v))
    mcl.people = people
开发者ID:Knio,项目名称:tag2itunes,代码行数:10,代码来源:easyid3.py

示例6: test_ctoc_subframes

 def test_ctoc_subframes(self):
     id3 = ID3()
     id3.version = (2, 3)
     id3.add(CTOC(sub_frames=[TYER(encoding=0, text="2006")]))
     id3.update_to_v24()
     ctoc = id3.getall("CTOC")[0]
     self.assertEqual(ctoc.sub_frames.getall("TDRC")[0], u"2006")
     self.assertFalse(ctoc.sub_frames.getall("TYER"))
     id3.update_to_v23()
     self.assertEqual(ctoc.sub_frames.getall("TYER")[0], u"2006")
开发者ID:quodlibet,项目名称:mutagen,代码行数:10,代码来源:test_id3.py

示例7: musicbrainz_trackid_set

def musicbrainz_trackid_set(id3, key, value):
    if len(value) != 1:
        raise ValueError("only one track ID may be set per song")
    value = value[0].encode('ascii')
    try:
        frame = id3["UFID:http://musicbrainz.org"]
    except KeyError:
        frame = mutagen.id3.UFID(owner="http://musicbrainz.org", data=value)
        id3.add(frame)
    else:
        frame.data = value
开发者ID:Knio,项目名称:tag2itunes,代码行数:11,代码来源:easyid3.py

示例8: peak_set

def peak_set(id3, key, value):
    if len(value) != 1:
        raise ValueError("there must be exactly one peak value, not %r.", value)
    peak = float(value[0])
    if peak >= 2 or peak < 0:
        raise ValueError("peak must be => 0 and < 2.")
    try:
        frame = id3["RVA2:" + key[11:-5]]
    except KeyError:
        frame = mutagen.id3.RVA2(desc=key[11:-5], gain=0, peak=0, channel=1)
        id3.add(frame)
    frame.peak = peak
开发者ID:Knio,项目名称:tag2itunes,代码行数:12,代码来源:easyid3.py

示例9: write_tags

 def write_tags(self):
     """Write all ID3v2.4 tags by mapping dub2id3_dict dictionnary with the
         respect of mutagen classes and methods"""
     from mutagen import id3  
     id3 = id3.ID3(self.dest)
     for tag in self.metadata.keys():
         if tag in self.dub2id3_dict.keys():
             frame_text = self.dub2id3_dict[tag]
             value = self.metadata[tag]
             frame = mutagen.id3.Frames[frame_text](3,value)
             id3.add(frame)
     id3.save()
开发者ID:Parisson,项目名称:telecaster-client,代码行数:12,代码来源:mp3.py

示例10: peak_set_with_txxx

def peak_set_with_txxx(id3, key, value):
  frameid = 'TXXX:' + key

  try:
    frame = id3[frameid]
  except KeyError:
    enc = get_best_txxx_encoding(value)

    id3.add(mutagen.id3.TXXX(encoding=enc, text=value, desc=key))
  else:
    frame.text = value

  return peak_set(id3, key, value)
开发者ID:dremelofdeath,项目名称:euphonogenizer,代码行数:13,代码来源:tagext.py

示例11: write_metadata

 def write_metadata(self):
     """Write all ID3v2.4 tags to file from self.metadata"""
     from mutagen import id3
     id3 = id3.ID3(self.filename)
     for tag in self.metadata.keys():
         value = self.metadata[tag]
         frame = mutagen.id3.Frames[tag](3,value)
         try:
             id3.add(frame)
         except:
             raise IOError('EncoderError: cannot tag "'+tag+'"')
     try:
         id3.save()
     except:
         raise IOError('EncoderError: cannot write tags')
开发者ID:MaiTiano,项目名称:TimeSide,代码行数:15,代码来源:mp3.py

示例12: setter

        def setter(id3, key, value):
            try:
                frame = id3[frameid]
            except KeyError:
                enc = 0
                # Store 8859-1 if we can, per MusicBrainz spec.
                try:
                    for v in value:
                        v.encode('latin_1')
                except UnicodeError:
                    enc = 3

                id3.add(mutagen.id3.TXXX(encoding=enc, text=value, desc=desc))
            else:
                frame.text = value
开发者ID:LordSputnik,项目名称:mutagen,代码行数:15,代码来源:easyid3.py

示例13: test_unknown_chap

    def test_unknown_chap(self):
        # add ctoc
        id3 = ID3(self.filename)
        id3.add(CTOC(element_id="foo", flags=3, child_element_ids=["ch0"],
                     sub_frames=[TIT2(encoding=3, text=["bla"])]))
        id3.save()

        # pretend we don't know ctoc and save
        id3 = ID3(self.filename, known_frames={"CTOC": CTOC})
        ctoc = id3.getall("CTOC")[0]
        self.assertFalse(ctoc.sub_frames)
        self.assertTrue(ctoc.sub_frames.unknown_frames)
        id3.save()

        # make sure we wrote all sub frames back
        id3 = ID3(self.filename)
        self.assertEqual(
            id3.getall("CTOC")[0].sub_frames.getall("TIT2")[0].text, ["bla"])
开发者ID:quodlibet,项目名称:mutagen,代码行数:18,代码来源:test_id3.py

示例14: test_merge

    def test_merge(self):
        id3 = ID3(self.filename)
        id3.delete()
        id3.add(mutagen.id3.TALB(text=[u"foo"]))
        id3.save(v2_version=3)

        target = ID3()
        target.add(mutagen.id3.TPE1(text=[u"bar", u"quux"]))
        target.save(self.blank_file, v2_version=4)

        res, out, err = self.call2(
            self.filename, self.blank_file, fsn(u"--merge"))
        assert not any([res, out, err])

        result = ID3(self.blank_file)
        assert result.version == (2, 4, 0)
        assert result.getall("TALB")[0].text == [u"foo"]
        assert result.getall("TPE1")[0].text == [u"bar", u"quux"]
开发者ID:quodlibet,项目名称:mutagen,代码行数:18,代码来源:test_tools_mid3cp.py

示例15: write_tags

 def write_tags(self):
     """Write all ID3v2.4 tags by mapping dub2id3_dict dictionnary with the
         respect of mutagen classes and methods"""
     from mutagen import id3
     id3 = id3.ID3(self.dest)
     for tag in self.metadata.keys():
         if tag in self.dub2id3_dict.keys():
             frame_text = self.dub2id3_dict[tag]
             value = self.metadata[tag]
             frame = mutagen.id3.Frames[frame_text](3,value)
             try:
                 id3.add(frame)
             except:
                 raise IOError('EncoderError: cannot tag "'+tag+'"')
     try:
         id3.save()
     except:
         raise IOError('EncoderError: cannot write tags')
开发者ID:MechanisM,项目名称:TimeSide,代码行数:18,代码来源:mp3.py


注:本文中的mutagen.id3.add函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。