當前位置: 首頁>>代碼示例>>Python>>正文


Python id3.APIC屬性代碼示例

本文整理匯總了Python中mutagen.id3.APIC屬性的典型用法代碼示例。如果您正苦於以下問題:Python id3.APIC屬性的具體用法?Python id3.APIC怎麽用?Python id3.APIC使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在mutagen.id3的用法示例。


在下文中一共展示了id3.APIC屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: modified_id3

# 需要導入模塊: from mutagen import id3 [as 別名]
# 或者: from mutagen.id3 import APIC [as 別名]
def modified_id3(self, file_name, info):
        id3 = ID3()
        id3.add(TRCK(encoding=3, text=str(info['track'])))
        id3.add(TDRC(encoding=3, text=str(info['year'])))
        id3.add(TIT2(encoding=3, text=info['song_name']))
        id3.add(TALB(encoding=3, text=info['album_name']))
        id3.add(TPE1(encoding=3, text=info['artist_name']))
        id3.add(TPOS(encoding=3, text=str(info['cd_serial'])))
        lyric_data = self.get_lyric(info)
        id3.add(USLT(encoding=3, text=lyric_data)) if lyric_data else None
        #id3.add(TCOM(encoding=3, text=info['composer']))
        #id3.add(WXXX(encoding=3, desc=u'xiami_song_url', text=info['song_url']))
        #id3.add(TCON(encoding=3, text=u'genre'))
        #id3.add(TSST(encoding=3, text=info['sub_title']))
        #id3.add(TSRC(encoding=3, text=info['disc_code']))
        id3.add(COMM(encoding=3, desc=u'Comment', \
            text=info['comment']))
        id3.add(APIC(encoding=3, mime=u'image/jpeg', type=3, \
            desc=u'Front Cover', data=self.get_cover(info)))
        id3.save(file_name) 
開發者ID:PeterDing,項目名稱:iScript,代碼行數:22,代碼來源:xiami.py

示例2: modified_id3

# 需要導入模塊: from mutagen import id3 [as 別名]
# 或者: from mutagen.id3 import APIC [as 別名]
def modified_id3(self, file_name, info):
        id3 = ID3()
        id3.add(TRCK(encoding=3, text=info['track']))
        id3.add(TDRC(encoding=3, text=info['year']))
        id3.add(TIT2(encoding=3, text=info['song_name']))
        id3.add(TALB(encoding=3, text=info['album_name']))
        id3.add(TPE1(encoding=3, text=info['artist_name']))
        id3.add(TPOS(encoding=3, text=info['cd_serial']))
        #id3.add(USLT(encoding=3, text=self.get_lyric(info['lyric_url'])))
        #id3.add(TCOM(encoding=3, text=info['composer']))
        #id3.add(TCON(encoding=3, text=u'genres'))
        #id3.add(TSST(encoding=3, text=info['sub_title']))
        #id3.add(TSRC(encoding=3, text=info['disc_code']))
        id3.add(COMM(encoding=3, desc=u'Comment', \
            text=info['song_url']))
        #id3.add(APIC(encoding=3, mime=u'image/jpg', type=3, \
            #desc=u'Front Cover', data=self.get_cover(info)))
        id3.save(file_name) 
開發者ID:PeterDing,項目名稱:iScript,代碼行數:20,代碼來源:music.163.com.py

示例3: setID3

# 需要導入模塊: from mutagen import id3 [as 別名]
# 或者: from mutagen.id3 import APIC [as 別名]
def setID3(self, lrc, info, path):
        tags = ID3(path)
        # remove old unsychronized lyrics
        len(tags.getall("USLT")) != 0 and tags.delall("USLT")
        for t in ['album', 'title', 'artist']:
            t in info and tags.add(
                tagMap[t](encoding=3, lang='', desc='', text=info[t][0]))
        'cover' in info and tags.add(APIC(
            encoding=3,
            mime='image/png',
            type=3,
            desc='cover',
            data=requests.get(info['cover'][0], stream=True,
                              headers=headers).raw.read()
        ))
        tags.add(USLT(encoding=3, lang='eng', desc='aaa', text=lrc))
        tags.save() 
開發者ID:mbinary,項目名稱:netease-music-cracker,代碼行數:19,代碼來源:decrypt.py

示例4: add_metadata_to_song

# 需要導入模塊: from mutagen import id3 [as 別名]
# 或者: from mutagen.id3 import APIC [as 別名]
def add_metadata_to_song(file_path, cover_path, song):
    # If no ID3 tags in mp3 file
    try:
        audio = MP3(file_path, ID3=ID3)
    except HeaderNotFoundError:
        print('Can\'t sync to MPEG frame, not an validate MP3 file!')
        return

    if audio.tags is None:
        print('No ID3 tag, trying to add one!')
        try:
            audio.add_tags()
            audio.save()
        except error as e:
            print('Error occur when add tags:', str(e))
            return

    # Modify ID3 tags
    id3 = ID3(file_path)
    # Remove old 'APIC' frame
    # Because two 'APIC' may exist together with the different description
    # For more information visit: http://mutagen.readthedocs.io/en/latest/user/id3.html
    if id3.getall('APIC'):
        id3.delall('APIC')
    # add album cover
    id3.add(
        APIC(
            encoding=0,         # 3 is for UTF8, but here we use 0 (LATIN1) for 163, orz~~~
            mime='image/jpeg',  # image/jpeg or image/png
            type=3,             # 3 is for the cover(front) image
            data=open(cover_path, 'rb').read()
        )
    )
    # add artist name
    id3.add(
        TPE1(
            encoding=3,
            text=song['artists'][0]['name']
        )
    )
    # add song name
    id3.add(
        TIT2(
            encoding=3,
            text=song['name']
        )
    )
    # add album name
    id3.add(
        TALB(
            encoding=3,
            text=song['album']['name']
        )
    )
    id3.save(v2_version=3) 
開發者ID:codezjx,項目名稱:netease-cloud-music-dl,代碼行數:57,代碼來源:file_util.py

示例5: modified_id3

# 需要導入模塊: from mutagen import id3 [as 別名]
# 或者: from mutagen.id3 import APIC [as 別名]
def modified_id3(self, file_name, info):
        id3 = ID3()
        id3.add(TRCK(encoding=3, text=info['track']))
        id3.add(TIT2(encoding=3, text=info['song_name']))
        id3.add(TALB(encoding=3, text=info['album_name']))
        id3.add(TPE1(encoding=3, text=info['artist_name']))
        id3.add(COMM(encoding=3, desc=u'Comment', text=info['song_url']))
        id3.add(APIC(encoding=3, mime=u'image/jpg', type=3, desc=u'Cover', data=self.get_cover(info['album_pic_url'])))
        id3.save(file_name) 
開發者ID:PeterDing,項目名稱:iScript,代碼行數:11,代碼來源:music.baidu.com.py

示例6: writePicture

# 需要導入模塊: from mutagen import id3 [as 別名]
# 或者: from mutagen.id3 import APIC [as 別名]
def writePicture(self, img):
        try:
            id3 = ID3(self.file)
            with open(img, 'rb') as pic:
                mine = "image/png" if img.split(".")[-1].lower() == "png" else "image/jpeg"
                id3['APIC'] = APIC(
                    # encoding=3,
                    mime=mine,
                    # type=3, desc=u'Cover',
                    data=pic.read()
                )
            id3.save()
            self.reload()
        except:
            pass 
開發者ID:LXG-Shadow,項目名稱:BilibiliTools,代碼行數:17,代碼來源:infoEditor.py


注:本文中的mutagen.id3.APIC屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。