コード例 #1
0
ファイル: Song.py プロジェクト: memres/music-player
	def metadata(self):
		if self._metadata is not None: return self._metadata
		import State
		player = State.state.player
		if self._fileMetadata is None:
			if player and player.curSong is self:
				self._fileMetadata = player.curSongMetadata or {}
			else:
				# try to read the metadata manually
				try:
					# make a new songObj. this prevents any multithreading issues
					songObj = Song(url=self.url, _useDb=False)
					songObj.openFile()
					import ffmpeg
					self._fileMetadata = ffmpeg.getMetadata(songObj) or {}
				except Exception: pass # couldn't open or so
		if self._fileMetadata is not None:
			m = dict([(key.lower(),value) for (key,value) in self._fileMetadata.items()])
			self._metadata = m # only save attrib if this is from player. otherwise we might get later some better results
		else:
			m = {}
		self.fixupMetadata(m)
		self.guessMetadata(m)
		self.makeMetadataUnicode(m)
		return m
コード例 #2
0
ファイル: Song.py プロジェクト: keverets/music-player
 def metadata(self):
     if self._metadata is not None: return self._metadata
     import State
     player = State.state.player
     if self._fileMetadata is None:
         if player and player.curSong is self:
             self._fileMetadata = player.curSongMetadata or {}
         else:
             # try to read the metadata manually
             try:
                 # make a new songObj. this prevents any multithreading issues
                 assert self.testUrl()
                 songObj = Song(url=self.url, _useDb=False)
                 songObj.openFile()
                 import ffmpeg
                 self._fileMetadata = ffmpeg.getMetadata(songObj) or {}
             except Exception:
                 pass  # couldn't open or so
     if self._fileMetadata is not None:
         m = dict([(key.lower(), value)
                   for (key, value) in self._fileMetadata.items()])
         self._metadata = m  # only save attrib if this is from player. otherwise we might get later some better results
     else:
         m = {}
     self.fixupMetadata(m)
     self.guessMetadata(m)
     self.makeMetadataUnicode(m)
     return m
コード例 #3
0
if len(sys.argv) == 2:
    filename = sys.argv[1]
else:
    files = [
        "~/Music/Classic/Glenn Gould Plays Bach/Two- & Three-Part Inventions - Gould/19 Bach - Invention 13 in a (BWV 784).mp3",
        "~/Music/Rock/Tool/Lateralus/09 Lateralus.flac",
        "~/Music/Cults - Cults 7/Cults - Cults 7- - 03 The Curse.flac",
        "~/Music/Special/zorba/(01) - Theme From Zorba The Greek.ogg",
        "~/Music/Classic/Glenn Gould Plays Bach/French Suites, BWV812-7 - Gould/Bach, French Suite 5 in G, BWV816 - 5 Bourree.mp3",
        "~/Music/Electronic/Von Paul Kalkbrenner - Aaron.mp3",
        "~/Music/Electronic/One Day_Reckoning Song (Wankelmut Remix) - Asaf Avidan & the Mojos.mp3",
        "~/Music/Electronic/Swing & Electro Swing/Parov Stelar/2008 - Daylight (Japan Only)/03 - Charlestone Butterfly.flac",  # this one has replaygain metadata
    ]
    files = map(os.path.expanduser, files)
    filename = files[7]

print(os.path.basename(filename))
assert os.path.isfile(filename)

import ffmpeg

metadata = ffmpeg.getMetadata(Song(filename))
from pprint import pprint

pprint(metadata)

duration, replaygain = ffmpeg.calcReplayGain(Song(filename))
print("duration: %f" % duration)
print("replaygain: %f" % replaygain)
print("gain factor: %f" % (10.0 ** (replaygain / 20)))
コード例 #4
0
step()


class Song:
	def __init__(self, fn):
		self.url = fn
		self.f = open(fn)
	def readPacket(self, bufSize):
		s = self.f.read(bufSize)
		return s
	def seekRaw(self, offset, whence):
		r = self.f.seek(offset, whence)
		return self.f.tell()

for f in files:
	ffmpeg.getMetadata(Song(f))
	progr()

print "after getMetadata"
step()


for f in files:
	ffmpeg.calcAcoustIdFingerprint(Song(f))
	progr()

print "after calcAcoustIdFingerprint"
step()


for f in files:
コード例 #5
0
class Song:
    def __init__(self, fn):
        self.url = fn
        self.f = open(fn)

    def readPacket(self, bufSize):
        s = self.f.read(bufSize)
        return s

    def seekRaw(self, offset, whence):
        r = self.f.seek(offset, whence)
        return self.f.tell()


for f in files:
    ffmpeg.getMetadata(Song(f))
    progr()

print "after getMetadata"
step()

for f in files:
    ffmpeg.calcAcoustIdFingerprint(Song(f))
    progr()

print "after calcAcoustIdFingerprint"
step()

for f in files:
    ffmpeg.calcBitmapThumbnail(Song(f))
    progr()
コード例 #6
0
import sys, os

if len(sys.argv) == 2:
    filename = sys.argv[1]
else:
    files = [
        "~/Music/Classic/Glenn Gould Plays Bach/Two- & Three-Part Inventions - Gould/19 Bach - Invention 13 in a (BWV 784).mp3",
        "~/Music/Rock/Tool/Lateralus/09 Lateralus.flac",
        "~/Music/Cults - Cults 7/Cults - Cults 7- - 03 The Curse.flac",
        "~/Music/Special/zorba/(01) - Theme From Zorba The Greek.ogg",
        "~/Music/Classic/Glenn Gould Plays Bach/French Suites, BWV812-7 - Gould/Bach, French Suite 5 in G, BWV816 - 5 Bourree.mp3",
        "~/Music/Electronic/Von Paul Kalkbrenner - Aaron.mp3",
        "~/Music/Electronic/One Day_Reckoning Song (Wankelmut Remix) - Asaf Avidan & the Mojos.mp3",
        "~/Music/Electronic/Swing & Electro Swing/Parov Stelar/2008 - Daylight (Japan Only)/03 - Charlestone Butterfly.flac",  # this one has replaygain metadata
    ]
    files = map(os.path.expanduser, files)
    filename = files[7]

print(os.path.basename(filename))
assert os.path.isfile(filename)

import ffmpeg
metadata = ffmpeg.getMetadata(Song(filename))
from pprint import pprint
pprint(metadata)

duration, replaygain = ffmpeg.calcReplayGain(Song(filename))
print("duration: %f" % duration)
print("replaygain: %f" % replaygain)
print("gain factor: %f" % (10.**(replaygain / 20)))