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


Python FLAC.pprint方法代码示例

本文整理汇总了Python中mutagen.flac.FLAC.pprint方法的典型用法代码示例。如果您正苦于以下问题:Python FLAC.pprint方法的具体用法?Python FLAC.pprint怎么用?Python FLAC.pprint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mutagen.flac.FLAC的用法示例。


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

示例1: _tag_flac

# 需要导入模块: from mutagen.flac import FLAC [as 别名]
# 或者: from mutagen.flac.FLAC import pprint [as 别名]
    def _tag_flac(self, trackno):
        """ Calls the mutagen library to perform metadata changes for FLAC files """

        logging.debug("Tagging '%s'" % os.path.join(self.dest_dir_name,
                    self.file_tag_map[trackno][1]))

        audio = FLAC(os.path.join(self.dest_dir_name,
                    self.file_tag_map[trackno][1]))
        try:
            encoding = audio["ENCODING"]
        except:
            encoding = ""
            audio.delete()

        # add FLAC tag data
        audio["TITLE"] = self.tracks[trackno][1]
        audio["ARTIST"] = self.tracks[trackno][0]
        audio["ALBUM"] = self.title
        audio["COMPOSER"] = self.artist
        audio["ORGANIZATION"] = self.label
        audio["CATALOGNUM"] = self.catno
        audio["GENRE"] = self.genre
        audio["YEAR"] = self.year
        audio["TRACKNUMBER"] = str(trackno)
        audio["TRACKTOTAL"] = str(len(self.tracks))
        audio["DESCRIPTION"] = '::> Don\'t believe the hype! <::'
        if(len(encoding) != 0):
            audio["ENCODING"] = encoding
        audio.pprint()
        try:
            audio.save()
        except:
            logging.error("Unable to tag '%s'" % self.file_tag_map[trackno][1])
            raise DiscogsTaggerError, "Unable to write tag '%s'" % \
                            self.file_tag_map[trackno][1]
开发者ID:tfriedel,项目名称:discogstagger,代码行数:37,代码来源:discogs_tagger.py

示例2: flac

# 需要导入模块: from mutagen.flac import FLAC [as 别名]
# 或者: from mutagen.flac.FLAC import pprint [as 别名]
 def flac(file_path):
     audio = FLAC(file_path)
     print "p p r i n t for %s" % file_path
     audio.pprint()
     print "p p r i n t"
     print audio
     length = audio.info.length
     #bitrate = audio.info.bitrate
     bitrate = 0
     return length, bitrate
开发者ID:propeersinfo,项目名称:investigations,代码行数:12,代码来源:media_info.py

示例3: add_metadata

# 需要导入模块: from mutagen.flac import FLAC [as 别名]
# 或者: from mutagen.flac.FLAC import pprint [as 别名]
 def add_metadata(self, file, sound):
     # "sound" requires a "freesound_client.get_sound" object
     # http://wiki.hydrogenaud.io/index.php?title=APE_key
     try:
         # Write it
         audio = FLAC(file)
         audio["title"] = sound.name
         audio["Artist"] = sound.username
         audio["Comment"] = sound.description
         audio["Publisher"] = "freesound.org"
         audio["File"] = sound.url
         # Save it
         audio.pprint()
         audio.save()
         # Read it
         file_info = mutagen.File(file)
         log.debug("Result metadata update:")
         log.debug(file_info)
         return file_info
     except Exception as e:
         log.debug(e)
         return False
开发者ID:Canule,项目名称:Mash-Cogs,代码行数:24,代码来源:freesound.py

示例4: TFLAC

# 需要导入模块: from mutagen.flac import FLAC [as 别名]
# 或者: from mutagen.flac.FLAC import pprint [as 别名]

#.........这里部分代码省略.........
        self.failIf(value and value != badval)

    def test_save_unknown_block(self):
        block = MetadataBlock("test block data")
        block.code = 99
        self.flac.metadata_blocks.append(block)
        self.flac.save()

    def test_load_unknown_block(self):
        self.test_save_unknown_block()
        flac = FLAC(self.NEW)
        self.failUnlessEqual(len(flac.metadata_blocks), 7)
        self.failUnlessEqual(flac.metadata_blocks[5].code, 99)
        self.failUnlessEqual(flac.metadata_blocks[5].data, "test block data")

    def test_two_vorbis_blocks(self):
        self.flac.metadata_blocks.append(self.flac.metadata_blocks[1])
        self.flac.save()
        self.failUnlessRaises(IOError, FLAC, self.NEW)

    def test_missing_streaminfo(self):
        self.flac.metadata_blocks.pop(0)
        self.flac.save()
        self.failUnlessRaises(IOError, FLAC, self.NEW)

    def test_load_invalid_flac(self):
        self.failUnlessRaises(
            IOError, FLAC, os.path.join("tests", "data", "xing.mp3"))

    def test_save_invalid_flac(self):
        self.failUnlessRaises(
            IOError, self.flac.save, os.path.join("tests", "data", "xing.mp3"))

    def test_pprint(self):
        self.failUnless(self.flac.pprint())

    def test_double_load(self):
        blocks = list(self.flac.metadata_blocks)
        self.flac.load(self.flac.filename)
        self.failUnlessEqual(blocks, self.flac.metadata_blocks)

    def test_seektable(self):
        self.failUnless(self.flac.seektable)

    def test_cuesheet(self):
        self.failUnless(self.flac.cuesheet)

    def test_pictures(self):
        self.failUnless(self.flac.pictures)

    def test_add_picture(self):
        f = FLAC(self.NEW)
        c = len(f.pictures)
        f.add_picture(Picture())
        f.save()
        f = FLAC(self.NEW)
        self.failUnlessEqual(len(f.pictures), c + 1)

    def test_clear_pictures(self):
        f = FLAC(self.NEW)
        c1 = len(f.pictures)
        c2 = len(f.metadata_blocks)
        f.clear_pictures()
        f.save()
        f = FLAC(self.NEW)
        self.failUnlessEqual(len(f.metadata_blocks), c2 - c1)
开发者ID:andrewboie,项目名称:discogstool,代码行数:70,代码来源:test_flac.py

示例5: TFLAC

# 需要导入模块: from mutagen.flac import FLAC [as 别名]
# 或者: from mutagen.flac.FLAC import pprint [as 别名]

#.........这里部分代码省略.........
        self.failIf(call_flac("-t", self.flac.filename) != 0)

    def test_save_unknown_block(self):
        block = MetadataBlock(b"test block data")
        block.code = 99
        self.flac.metadata_blocks.append(block)
        self.flac.save()

    def test_load_unknown_block(self):
        self.test_save_unknown_block()
        flac = FLAC(self.NEW)
        self.failUnlessEqual(len(flac.metadata_blocks), 7)
        self.failUnlessEqual(flac.metadata_blocks[5].code, 99)
        self.failUnlessEqual(flac.metadata_blocks[5].data, b"test block data")

    def test_two_vorbis_blocks(self):
        self.flac.metadata_blocks.append(self.flac.metadata_blocks[1])
        self.flac.save()
        self.failUnlessRaises(error, FLAC, self.NEW)

    def test_missing_streaminfo(self):
        self.flac.metadata_blocks.pop(0)
        self.flac.save()
        self.failUnlessRaises(error, FLAC, self.NEW)

    def test_load_invalid_flac(self):
        self.failUnlessRaises(
            error, FLAC, os.path.join(DATA_DIR, "xing.mp3"))

    def test_save_invalid_flac(self):
        self.failUnlessRaises(
            error, self.flac.save, os.path.join(DATA_DIR, "xing.mp3"))

    def test_pprint(self):
        self.failUnless(self.flac.pprint())

    def test_double_load(self):
        blocks = list(self.flac.metadata_blocks)
        self.flac.load(self.flac.filename)
        self.failUnlessEqual(blocks, self.flac.metadata_blocks)

    def test_seektable(self):
        self.failUnless(self.flac.seektable)

    def test_cuesheet(self):
        self.failUnless(self.flac.cuesheet)

    def test_pictures(self):
        self.failUnless(self.flac.pictures)

    def test_add_picture(self):
        f = FLAC(self.NEW)
        c = len(f.pictures)
        f.add_picture(Picture())
        f.save()
        f = FLAC(self.NEW)
        self.failUnlessEqual(len(f.pictures), c + 1)

    def test_clear_pictures(self):
        f = FLAC(self.NEW)
        c1 = len(f.pictures)
        c2 = len(f.metadata_blocks)
        f.clear_pictures()
        f.save()
        f = FLAC(self.NEW)
        self.failUnlessEqual(len(f.metadata_blocks), c2 - c1)
开发者ID:quodlibet,项目名称:mutagen,代码行数:70,代码来源:test_flac.py

示例6: open

# 需要导入模块: from mutagen.flac import FLAC [as 别名]
# 或者: from mutagen.flac.FLAC import pprint [as 别名]
#hey imma parse ur boxes ok

import csv
from mutagen.flac import FLAC

#discogs.user_agent = 'CrystalDiscogsBot/0.1 +http://www.crystal-lp.com'

with open('boxes.csv', 'r') as boxes:
	spamreader = csv.reader(boxes)
	print 'Hello, world!'
	rowdata = []
	for row in spamreader:
		rowdata.append(row)
	rowInput = 14
	for row in rowdata:
		if row[0] == str(rowInput):
			print 'Match!'
			print 'RealRow:',row
			audio = FLAC('fong1.flac')
			audio['title'] = row[0]
			audio['artist'] = row[1]
			audio['album'] = row[2]
			audio.pprint()
			audio.save()
			break
	else:
		print 'No match found.'
	print
开发者ID:broxeph,项目名称:ameryn,代码行数:30,代码来源:boxparse.py

示例7: FLAC

# 需要导入模块: from mutagen.flac import FLAC [as 别名]
# 或者: from mutagen.flac.FLAC import pprint [as 别名]
            flac_file = filename.replace('.wav', '.flac')
            assert os.path.exists(flac_file), \
                   "%s file was not converted to %s" % (filename, flac_file)

            os.chmod(flac_file,
                     stat.S_IRUSR|stat.S_IWUSR|stat.S_IRGRP|stat.S_IROTH)

            audio = FLAC(flac_file)
            audio['title'] = "%s (%s)" % (metadata['track_name'],
                                          metadata['mix_name'])
            audio['artist'] = metadata['artist']
            audio['album'] = metadata['release']
            audio['date'] = metadata['release_date'][0]
            audio['genre'] = metadata['genre']

            log(audio.pprint())

            audio.save()
        except MissingMetadataError as exception :
            log("Could not find (or missing) track information: %s. Skipping" %
                exception.message)
        except AssertionError as exception :
            log(exception)
        except Exception as exception :
            log("Hey you found a bug! Bugs really suck, I'm sorry.\r\n"\
                "We have to skip this file, but you can file an issue at\r\n"\
                "https://github.com/cdolivei/beatport2flac/issues\r\n"
                "with the track name and this message : %s" % repr(exception))
        finally:
            if artwork != None:
                os.remove(artwork)
开发者ID:cdolivei,项目名称:beatport2flac,代码行数:33,代码来源:beatport2flac.py

示例8: __init__

# 需要导入模块: from mutagen.flac import FLAC [as 别名]
# 或者: from mutagen.flac.FLAC import pprint [as 别名]
	def __init__(self,filesrc):
		folderpaths = [path for (path, folders, files) in os.walk(filesrc)]
		filenames = [files for (path, folders, files) in os.walk(filesrc)]
		for i in range(len(folderpaths)):
			for j in range(len(filenames[i])):
				if(i==0):
					filenames[i][j] = folderpaths[i] + filenames[i][j]
				else:
					filenames[i][j] = folderpaths[i] + "/"+ filenames[i][j]

		for i in range(len(folderpaths)):
			for j in range(len(filenames[i])):
				if len(filenames[i]) == 0:
					continue
				temp = i
				src = filenames[i][j]
				mime = magic.open(magic.MAGIC_MIME)
				mime.load()
				mime = mime.file(src).split(";")[0]
				mp3Type = ['audio/mpeg', 'audio/mpeg3', 'audio/x-mpeg', 'audio/x-mpeg-3']
				flacType = ['audio/x-flac', 'audio/flac']
				oggType = ['application/ogg', 'audio/vorbis', 'audio/x-vorbis', 'application/ogg', 'application/x-ogg', 'application/octet-stream', 'audio/ogg', 'video/ogg']
				wmaType = ['video/x-ms-asf','audio/x-ms-wma', 'audio/x-ms-wmv', 'audio/x-wma', 'video/x-wmv', 'application/octet-stream']
				found = 0
				filetype = ""
				if found==0:
					for i in range(len(mp3Type)):
						if mime == mp3Type[i]:
							audio = MP3(src)
							found = 1
							filetype = "mp3"
							break
					for i in range(len(flacType)):
						if mime == flacType[i]:
							audio = FLAC(src)
							found = 1
							filetype = "flac"
							break
					for i in range(len(oggType)):
						if mime == oggType[i]:
							audio = OggVorbis(src)
							found = 1
							filetype = "ogg"
							break
					for i in range(len(wmaType)):
						if mime == wmaType[i]:
							audio = ASF(src)
							found = 1
							filetype = "wma"

				if found!=1:
					print "Data type is not found."
					return
				filedict = dict()
				if filetype == "mp3":
					audioprop = audio.pprint().split("\n")
					fileprop = audioprop[0].split(", ") #fileprop:  u'MPEG 1 layer 3, 320000 bps, 44100 Hz, 246.73 seconds (audio/mp3)'
					filedict['Audio Codec'] = fileprop[0]
					filedict['Bitrate'] = fileprop[1]
					filedict['Sample Rate'] = fileprop[2]
					filedict['Length'] = fileprop[3].split(" (")[0]
					audioprop = audioprop[1:]
					for i in audioprop:
						values = i.split("=")
						filedict[values[0]] = values[1]

					if filedict.has_key("UFID"):
						filedict["Unique File Identifier"] = filedict["UFID"]
						del filedict["UFID"]
					
					if filedict.has_key("TIT1"): 
						filedict["Content group description"] = filedict["TIT1"]
						del filedict["TIT1"]
					
					if filedict.has_key("TIT2"):     
						filedict["Title"] = filedict["TIT2"]
						del filedict["TIT2"]
					
					if filedict.has_key("TIT3"):     
						filedict["Subtitle/Description refinement"] = filedict["TIT3"]
						del filedict["TIT3"]
					
					if filedict.has_key("TPE1"):     
						filedict["Artist"] = filedict["TPE1"]
						del filedict["TPE1"]
					
					if filedict.has_key("TPE2"):     
						filedict["Band"] = filedict["TPE2"]
						del filedict["TPE2"]		 
					
					if filedict.has_key("TPE3"):     
						filedict["Conductor"] = filedict["TPE3"]
						del filedict["TPE3"]		
					
					if filedict.has_key("TPE4"):     
						filedict["Remixer"] = filedict["TPE4"]
						del filedict["TPE4"]
					
					if filedict.has_key("TCOM"):     
						filedict["Composer"] = filedict["TCOM"]
#.........这里部分代码省略.........
开发者ID:COMU,项目名称:papatya,代码行数:103,代码来源:fileinfo.py


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