def getTrack(filename): """ Return a Track created from a WavPack file """ from mutagen.wavpack import WavPack wvFile = WavPack(filename) length = int(round(wvFile.info.length)) samplerate = int(wvFile.info.sample_rate) try: title = str(wvFile['Title'][0]) except: title = None try: album = str(wvFile['Album'][0]) except: album = None try: artist = str(wvFile['Artist'][0]) except: artist = None try: albumArtist = str(wvFile['Album Artist'][0]) except: albumArtist = None try: genre = str(wvFile['genre'][0]) except: genre = None try: trackNumber = str(wvFile['Track'][0]) except: trackNumber = None try: discNumber = str(wvFile['Disc'][0]) except: discNumber = None try: date = str(wvFile['Year'][0]) except: date = None return createFileTrack(filename, -1, length, samplerate, False, title, album, artist, albumArtist, None, genre, trackNumber, date, discNumber)
def getTrack(filename): """ Return a Track created from an mp3 file """ wavFile = wave.open(filename) length = int(round(wavFile.getnframes() / float(wavFile.getframerate()))) bitrate = -1 samplerate = wavFile.getframerate() wavFile.close() date = None isVBR = False title = None album = None genre = None artist = None discNumber = None albumArtist = None trackNumber = None musicbrainzId = None return createFileTrack(filename, bitrate, length, samplerate, isVBR, title, album, artist, albumArtist, musicbrainzId, genre, trackNumber, date, discNumber)
def getTrack(filename): """ Return a Track created from an APE file """ from mutagen.monkeysaudio import MonkeysAudio mFile = MonkeysAudio(filename) length = int(round(mFile.info.length)) samplerate = int(mFile.info.sample_rate) try: trackNumber = str(mFile['Track'][0]) except: trackNumber = None try: date = str(mFile['Year'][0]) except: date = None try: title = str(mFile['Title'][0]) except: title = None try: album = str(mFile['Album'][0]) except: album = None try: artist = str(mFile['Artist'][0]) except: artist = None try: genre = str(mFile['Genre'][0]) except: genre = None return createFileTrack(filename, -1, length, samplerate, False, title, album, artist, None, None, genre, trackNumber, date, None)
def getTrack(filename): """ Return a Track created from an mp3 file """ from mutagen.mp3 import MP3 from mutagen.id3 import ID3 mp3File = MP3(filename) length = int(round(mp3File.info.length)) bitrate = int(mp3File.info.bitrate) samplerate = int(mp3File.info.sample_rate) if mp3File.info.mode == 1: isVBR = True else: isVBR = False try: id3 = ID3(filename) except: return createFileTrack(filename, bitrate, length, samplerate, isVBR) try: title = str(id3['TIT2']) except: title = None try: album = str(id3['TALB']) except: album = None try: artist = str(id3['TPE1']) except: artist = None try: albumArtist = str(id3['TPE2']) except: albumArtist = None try: musicbrainzId = id3['UFID:http://musicbrainz.org'].data except: musicbrainzId = None try: genre = str(id3['TCON']) except: genre = None try: trackNumber = str(id3['TRCK']) except: trackNumber = None try: date = str(id3['TDRC'][0].year) except: date = None try: discNumber = str(id3['TPOS']) except: discNumber = None return createFileTrack(filename, bitrate, length, samplerate, isVBR, title, album, artist, albumArtist, musicbrainzId, genre, trackNumber, date, discNumber)
def getTrack(filename): """ Return a Track created from an asf file """ from mutagen.asf import ASF asfFile = ASF(filename) length = int(round(asfFile.info.length)) bitrate = int(asfFile.info.bitrate) samplerate = int(asfFile.info.sample_rate) try: trackNumber = str(asfFile['WM/TrackNumber'][0]) except: trackNumber = None try: discNumber = str(asfFile['WM/PartOfSet'][0]) except: discNumber = None try: date = str(asfFile['WM/Year'][0]) except: date = None try: title = str(asfFile['Title'][0]) except: title = None try: album = str(asfFile['WM/AlbumTitle'][0]) except: album = None try: artist = str(asfFile['Author'][0]) except: artist = None try: albumArtist = str(asfFile['WM/AlbumArtist'][0]) except: albumArtist = None try: genre = str(asfFile['WM/Genre'][0]) except: genre = None try: musicbrainzId = str(asfFile['MusicBrainz/Track Id'][0]) except: musicbrainzId = None return createFileTrack(filename, bitrate, length, samplerate, False, title, album, artist, albumArtist, musicbrainzId, genre, trackNumber, date, discNumber)
def getTrack(filename): """ Return a Track created from an Ogg Vorbis file """ from mutagen.oggvorbis import OggVorbis oggFile = OggVorbis(filename) length = int(round(oggFile.info.length)) bitrate = int(oggFile.info.bitrate) samplerate = int(oggFile.info.sample_rate) try: title = str(oggFile['title'][0]) except: title = None try: album = str(oggFile['album'][0]) except: album = None try: artist = str(oggFile['artist'][0]) except: artist = None try: albumArtist = str(oggFile['albumartist'][0]) except: albumArtist = None try: genre = str(oggFile['genre'][0]) except: genre = None try: musicbrainzId = str(oggFile['musicbrainz_trackid'][0]) except: musicbrainzId = None try: trackNumber = str(oggFile['tracknumber'][0]) except: trackNumber = None try: discNumber = str(oggFile['discnumber'][0]) except: discNumber = None try: date = str(oggFile['date'][0]) except: date = None return createFileTrack(filename, bitrate, length, samplerate, True, title, album, artist, albumArtist, musicbrainzId, genre, trackNumber, date, discNumber)
def getTrack(filename): """ Return a Track created from an mpc file """ from mutagen.musepack import Musepack mpcFile = Musepack(filename) length = int(round(mpcFile.info.length)) bitrate = int(mpcFile.info.bitrate * 1000) samplerate = int(mpcFile.info.sample_rate) try: trackNumber = str(mpcFile['Track']) except: trackNumber = None try: discNumber = str(mpcFile['Discnumber']) except: discNumber = None try: date = str(mpcFile['Year']) except: date = None try: title = str(mpcFile['Title']) except: title = None try: genre = str(mpcFile['Genre']) except: genre = None try: musicbrainzId = str(mpcFile['MUSICBRAINZ_TRACKID']) except: musicbrainzId = None try: album = str(mpcFile['Album']) except: album = None try: artist = str(mpcFile['Artist']) except: artist = None try: albumArtist = str(mpcFile['Album Artist']) except: albumArtist = None return createFileTrack(filename, bitrate, length, samplerate, False, title, album, artist, albumArtist, musicbrainzId, genre, trackNumber, date, discNumber)
def getTrack(filename): """ Return a Track created from a FLAC file """ from mutagen.flac import FLAC flacFile = FLAC(filename) length = int(round(flacFile.info.length)) samplerate = int(flacFile.info.sample_rate) try: title = str(flacFile['title'][0]) except: title = None try: album = str(flacFile['album'][0]) except: album = None try: artist = str(flacFile['artist'][0]) except: artist = None try: albumArtist = str(flacFile['albumartist'][0]) except: albumArtist = None try: genre = str(flacFile['genre'][0]) except: genre = None try: musicbrainzId = str(flacFile['musicbrainz_trackid'][0]) except: musicbrainzId = None try: trackNumber = str(flacFile['tracknumber'][0]) except: trackNumber = None try: discNumber = str(flacFile['discnumber'][0]) except: discNumber = None try: date = str(flacFile['date'][0]) except: date = None return createFileTrack(filename, -1, length, samplerate, False, title, album, artist, albumArtist, musicbrainzId, genre, trackNumber, date, discNumber)
def getTrack(filename): """ Return a Track created from an mp4 file """ from mutagen.mp4 import MP4 mp4File = MP4(filename) length = int(round(mp4File.info.length)) bitrate = int(mp4File.info.bitrate) samplerate = int(mp4File.info.sample_rate) try: trackNumber = str(mp4File['trkn'][0][0]) except: trackNumber = None try: discNumber = str(mp4File['disk'][0][0]) except: discNumber = None try: date = str(mp4File['\xa9day'][0][0]) except: date = None try: title = str(mp4File['\xa9nam'][0]) except: title = None try: album = str(mp4File['\xa9alb'][0]) except: album = None try: artist = str(mp4File['\xa9ART'][0]) except: artist = None try: genre = str(mp4File['\xa9gen'][0]) except: genre = None try: albumArtist = str(mp4File['aART'][0]) except: albumArtist = None return createFileTrack(filename, bitrate, length, samplerate, False, title, album, artist, albumArtist, None, genre, trackNumber, date, discNumber)
def getTrack(filename): """ Return a Track created from an mp3 file """ from mutagen.mp3 import MP3 from mutagen.id3 import ID3 mp3File = MP3(filename) length = int(round(mp3File.info.length)) bitrate = int(mp3File.info.bitrate) samplerate = int(mp3File.info.sample_rate) # Don't set VBR information for MP3 files (#1202195) isVBR = False try: id3 = ID3(filename) except: return createFileTrack(filename, bitrate, length, samplerate, isVBR) try: title = str(id3['TIT2']) except: title = None try: album = str(id3['TALB']) except: album = None try: artist = str(id3['TPE1']) except: artist = None try: albumArtist = str(id3['TPE2']) except: albumArtist = None try: musicbrainzId = id3['UFID:http://musicbrainz.org'].data except: musicbrainzId = None try: genre = str(id3['TCON']) except: genre = None try: trackNumber = str(id3['TRCK']) except: trackNumber = None try: date = str(id3['TDRC'][0].year) except: date = None try: discNumber = str(id3['TPOS']) except: discNumber = None return createFileTrack(filename, bitrate, length, samplerate, isVBR, title, album, artist, albumArtist, musicbrainzId, genre, trackNumber, date, discNumber)
def getTrack(filename): """ Return a Track created from an Ogg Vorbis file """ from mutagen.oggvorbis import OggVorbis oggFile = OggVorbis(filename) length = int(round(oggFile.info.length)) bitrate = int(oggFile.info.bitrate) samplerate = int(oggFile.info.sample_rate) try: title = str(oggFile["title"][0]) except: title = None try: album = str(oggFile["album"][0]) except: album = None try: artist = str(oggFile["artist"][0]) except: artist = None try: albumArtist = str(oggFile["albumartist"][0]) except: albumArtist = None try: genre = str(oggFile["genre"][0]) except: genre = None try: musicbrainzId = str(oggFile["musicbrainz_trackid"][0]) except: musicbrainzId = None try: trackNumber = str(oggFile["tracknumber"][0]) except: trackNumber = None try: discNumber = str(oggFile["discnumber"][0]) except: discNumber = None try: date = str(oggFile["date"][0]) except: date = None return createFileTrack( filename, bitrate, length, samplerate, True, title, album, artist, albumArtist, musicbrainzId, genre, trackNumber, date, discNumber, )