How to use the mutagen.flac.FLAC function in mutagen

To help you get started, we’ve selected a few mutagen examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github quodlibet / mutagen / tests / test_flac.py View on Github external
def test_delete_multiple_fail(self):
        f = FLAC(self.filename)
        with pytest.raises(MutagenError):
            f.delete(os.devnull)
        f.save()

        # if delete failed we shouldn't see a difference
        f = FLAC(self.filename)
        assert f.metadata_blocks[2] is f.tags
        assert f.metadata_blocks[3].code == f.tags.code
github LordSputnik / mutagen / tests / test_flac.py View on Github external
def test_write_changetitle(self):
        f = FLAC(self.NEW)
        if PY3:
            self.assertRaises(ValueError, f.__setitem__, b'title', b"A New Title")
        else:
            f[b'title'] = b"A New Title"
            f.save()
            f = FLAC(self.NEW)
            self.failUnlessEqual(f[b"title"][0], b"A New Title")
github quodlibet / mutagen / tests / test_flac.py View on Github external
def test_overwritten_read(self):
        flac = FLAC(self.OVERWRITTEN)
        self.failUnlessEqual(flac["artist"], ["Giora Feidman"])
github LordSputnik / mutagen / tests / test_flac.py View on Github external
def test_variable_block_size(self):
        FLAC(os.path.join("tests", "data", "variable-block.flac"))
github LordSputnik / mutagen / tests / test_flac.py View on Github external
def test_12_write_too_big(self):
        filename = os.path.join("tests", "data", "silence-44-s.flac")
        f = FLAC(filename)
        # This size is too big to be an integer.
        f.metadata_blocks[-1].length = 0xFFFFFFFFFFFFFFFF
        self.failUnlessRaises(IOError, f.metadata_blocks[-1].write)
github LordSputnik / mutagen / tests / test_flac.py View on Github external
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)
github Sorrow446 / MQ-DL / MQ-DL.py View on Github external
def write_tags(pre_abs, meta, fmt, cov_abs):
	if fmt == "FLAC":
		audio = FLAC(pre_abs)
		del meta['track_padded']
		for k, v in meta.items():
			if v:
				audio[k] = str(v)
		if cov_abs:
			with open(cov_abs, "rb") as f:
				image = Picture()
				image.type = 3
				image.mime = "image/jpeg"
				image.data = f.read()
				audio.add_picture(image)
	elif fmt == "MP3":
		try: 
			audio = id3.ID3(pre_abs)
		except ID3NoHeaderError:
			audio = id3.ID3()
github MediaBrowser / plugin.video.emby / resources / lib / musicutils.py View on Github external
def getSongTags(file):
    # Get the actual ID3 tags for music songs as the server is lacking that info
    rating = 0
    comment = ""
    hasEmbeddedCover = False
    
    isTemp,filename = getRealFileName(file)
    log.info( "getting song ID3 tags for " + filename)
    
    try:
        ###### FLAC FILES #############
        if filename.lower().endswith(".flac"):
            audio = FLAC(filename)
            if audio.get("comment"):
                comment = audio.get("comment")[0]
            for pic in audio.pictures:
                if pic.type == 3 and pic.data:
                    #the file has an embedded cover
                    hasEmbeddedCover = True
                    break
            if audio.get("rating"):
                rating = float(audio.get("rating")[0])
                #flac rating is 0-100 and needs to be converted to 0-5 range
                if rating > 5: rating = (rating / 100) * 5
        
        ###### MP3 FILES #############
        elif filename.lower().endswith(".mp3"):
            audio = ID3(filename)
github quodlibet / mutagen / fuzzing / fuzztools.py View on Github external
from mutagen.musepack import Musepack
from mutagen.monkeysaudio import MonkeysAudio
from mutagen.optimfrog import OptimFROG
from mutagen.aiff import AIFF
from mutagen.aac import AAC
from mutagen.ac3 import AC3
from mutagen.smf import SMF
from mutagen.tak import TAK
from mutagen.dsf import DSF
from mutagen.wave import WAVE
from mutagen.dsdiff import DSDIFF


OPENERS = [
    MP3, TrueAudio, OggTheora, OggSpeex, OggVorbis, OggFLAC,
    FLAC, AIFF, APEv2File, MP4, ID3FileType, WavPack,
    Musepack, MonkeysAudio, OptimFROG, ASF, OggOpus, AC3,
    TAK, DSF, EasyMP3, EasyID3FileType, EasyTrueAudio, EasyMP4,
    File, SMF, AAC, EasyID3, ID3, APEv2, WAVE, DSDIFF]

# If you only want to test one:
# OPENERS = [AAC]


def run(opener, data):
    f = BytesIO(data)
    try:
        res = opener(f)
    except MutagenError:
        pass
    else:
        # File is special and returns None if loading fails
github harvest-project / harvest / upload_studio / executors / sox_process.py View on Github external
def __init__(self, src_file, dst_file):
            self.src_file = src_file
            self.dst_file = dst_file
            self.src_muta = mutagen.flac.FLAC(self.src_file)
            self.processing_chain = None