mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-03-10 05:34:36 +00:00
[#123 state:fixed] Updated codebase to use hsaudiotag v1.1.0 (which fixed the AIFF bug) and made it use the new auto.File wrapper.
This commit is contained in:
parent
95efac187b
commit
f1b4db368e
2
README
2
README
@ -27,7 +27,7 @@ General dependencies
|
|||||||
- Python 3.1 (http://www.python.org)
|
- Python 3.1 (http://www.python.org)
|
||||||
- Send2Trash3k (http://hg.hardcoded.net/send2trash)
|
- Send2Trash3k (http://hg.hardcoded.net/send2trash)
|
||||||
- hsutil3k (http://hg.hardcoded.net/hsutil)
|
- hsutil3k (http://hg.hardcoded.net/hsutil)
|
||||||
- hsaudiotag3k (for ME) (http://hg.hardcoded.net/hsaudiotag)
|
- hsaudiotag3k 1.1.0 (for ME) (http://hg.hardcoded.net/hsaudiotag)
|
||||||
- jobprogress (http://hg.hardcoded.net/jobprogress)
|
- jobprogress (http://hg.hardcoded.net/jobprogress)
|
||||||
- Markdown, to generate help files. (http://pypi.python.org/pypi/Markdown)
|
- Markdown, to generate help files. (http://pypi.python.org/pypi/Markdown)
|
||||||
- PyYaml, for help files and the build system. (http://pyyaml.org/)
|
- PyYaml, for help files and the build system. (http://pyyaml.org/)
|
||||||
|
@ -28,7 +28,7 @@ class DupeGuruME(DupeGuruBase):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
DupeGuruBase.__init__(self, data, 'dupeGuru Music Edition')
|
DupeGuruBase.__init__(self, data, 'dupeGuru Music Edition')
|
||||||
self.scanner = scanner.ScannerME()
|
self.scanner = scanner.ScannerME()
|
||||||
self.directories.fileclasses = [fs.Mp3File, fs.Mp4File, fs.WmaFile, fs.OggFile, fs.FlacFile, fs.AiffFile]
|
self.directories.fileclasses = [fs.MusicFile]
|
||||||
self.dead_tracks = []
|
self.dead_tracks = []
|
||||||
|
|
||||||
def remove_dead_tracks(self):
|
def remove_dead_tracks(self):
|
||||||
|
165
core_me/fs.py
165
core_me/fs.py
@ -1,4 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Created By: Virgil Dupras
|
# Created By: Virgil Dupras
|
||||||
# Created On: 2009-10-23
|
# Created On: 2009-10-23
|
||||||
# Copyright 2010 Hardcoded Software (http://www.hardcoded.net)
|
# Copyright 2010 Hardcoded Software (http://www.hardcoded.net)
|
||||||
@ -7,12 +6,12 @@
|
|||||||
# which should be included with this package. The terms are also available at
|
# which should be included with this package. The terms are also available at
|
||||||
# http://www.hardcoded.net/licenses/bsd_license
|
# http://www.hardcoded.net/licenses/bsd_license
|
||||||
|
|
||||||
from hsaudiotag import mpeg, wma, mp4, ogg, flac, aiff
|
from hsaudiotag import auto
|
||||||
from hsutil.str import get_file_ext
|
from hsutil.str import get_file_ext
|
||||||
from core import fs
|
from core import fs
|
||||||
|
|
||||||
TAG_FIELDS = ['audiosize', 'duration', 'bitrate', 'samplerate', 'title', 'artist',
|
TAG_FIELDS = {'audiosize', 'duration', 'bitrate', 'samplerate', 'title', 'artist',
|
||||||
'album', 'genre', 'year', 'track', 'comment']
|
'album', 'genre', 'year', 'track', 'comment'}
|
||||||
|
|
||||||
class MusicFile(fs.File):
|
class MusicFile(fs.File):
|
||||||
INITIAL_INFO = fs.File.INITIAL_INFO.copy()
|
INITIAL_INFO = fs.File.INITIAL_INFO.copy()
|
||||||
@ -29,154 +28,30 @@ class MusicFile(fs.File):
|
|||||||
'year' : '',
|
'year' : '',
|
||||||
'track' : 0,
|
'track' : 0,
|
||||||
})
|
})
|
||||||
HANDLED_EXTS = set()
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def can_handle(cls, path):
|
def can_handle(cls, path):
|
||||||
if not fs.File.can_handle(path):
|
if not fs.File.can_handle(path):
|
||||||
return False
|
return False
|
||||||
return get_file_ext(path[-1]) in cls.HANDLED_EXTS
|
return get_file_ext(path[-1]) in auto.EXT2CLASS
|
||||||
|
|
||||||
|
|
||||||
class Mp3File(MusicFile):
|
|
||||||
HANDLED_EXTS = set(['mp3'])
|
|
||||||
def _read_info(self, field):
|
def _read_info(self, field):
|
||||||
if field == 'md5partial':
|
if field == 'md5partial':
|
||||||
fileinfo = mpeg.Mpeg(str(self.path))
|
f = auto.File(str(self.path))
|
||||||
self._md5partial_offset = fileinfo.audio_offset
|
self._md5partial_offset = f.audio_offset
|
||||||
self._md5partial_size = fileinfo.audio_size
|
self._md5partial_size = f.audio_size
|
||||||
MusicFile._read_info(self, field)
|
fs.File._read_info(self, field)
|
||||||
if field in TAG_FIELDS:
|
if field in TAG_FIELDS:
|
||||||
fileinfo = mpeg.Mpeg(str(self.path))
|
f = auto.File(str(self.path))
|
||||||
self.audiosize = fileinfo.audio_size
|
self.audiosize = f.audio_size
|
||||||
self.bitrate = fileinfo.bitrate
|
self.bitrate = f.bitrate
|
||||||
self.duration = fileinfo.duration
|
self.duration = f.duration
|
||||||
self.samplerate = fileinfo.sample_rate
|
self.samplerate = f.sample_rate
|
||||||
i1 = fileinfo.id3v1
|
self.artist = f.artist
|
||||||
# id3v1, even when non-existant, gives empty values. not id3v2. if id3v2 don't exist,
|
self.album = f.album
|
||||||
# just replace it with id3v1
|
self.title = f.title
|
||||||
i2 = fileinfo.id3v2
|
self.genre = f.genre
|
||||||
if not i2.exists:
|
self.comment = f.comment
|
||||||
i2 = i1
|
self.year = f.year
|
||||||
self.artist = i2.artist or i1.artist
|
self.track = f.track
|
||||||
self.album = i2.album or i1.album
|
|
||||||
self.title = i2.title or i1.title
|
|
||||||
self.genre = i2.genre or i1.genre
|
|
||||||
self.comment = i2.comment or i1.comment
|
|
||||||
self.year = i2.year or i1.year
|
|
||||||
self.track = i2.track or i1.track
|
|
||||||
|
|
||||||
class WmaFile(MusicFile):
|
|
||||||
HANDLED_EXTS = set(['wma'])
|
|
||||||
def _read_info(self, field):
|
|
||||||
if field == 'md5partial':
|
|
||||||
dec = wma.WMADecoder(str(self.path))
|
|
||||||
self._md5partial_offset = dec.audio_offset
|
|
||||||
self._md5partial_size = dec.audio_size
|
|
||||||
MusicFile._read_info(self, field)
|
|
||||||
if field in TAG_FIELDS:
|
|
||||||
dec = wma.WMADecoder(str(self.path))
|
|
||||||
self.audiosize = dec.audio_size
|
|
||||||
self.bitrate = dec.bitrate
|
|
||||||
self.duration = dec.duration
|
|
||||||
self.samplerate = dec.sample_rate
|
|
||||||
self.artist = dec.artist
|
|
||||||
self.album = dec.album
|
|
||||||
self.title = dec.title
|
|
||||||
self.genre = dec.genre
|
|
||||||
self.comment = dec.comment
|
|
||||||
self.year = dec.year
|
|
||||||
self.track = dec.track
|
|
||||||
|
|
||||||
class Mp4File(MusicFile):
|
|
||||||
HANDLED_EXTS = set(['m4a', 'm4p'])
|
|
||||||
def _read_info(self, field):
|
|
||||||
if field == 'md5partial':
|
|
||||||
dec = mp4.File(str(self.path))
|
|
||||||
self._md5partial_offset = dec.audio_offset
|
|
||||||
self._md5partial_size = dec.audio_size
|
|
||||||
dec.close()
|
|
||||||
MusicFile._read_info(self, field)
|
|
||||||
if field in TAG_FIELDS:
|
|
||||||
dec = mp4.File(str(self.path))
|
|
||||||
self.audiosize = dec.audio_size
|
|
||||||
self.bitrate = dec.bitrate
|
|
||||||
self.duration = dec.duration
|
|
||||||
self.samplerate = dec.sample_rate
|
|
||||||
self.artist = dec.artist
|
|
||||||
self.album = dec.album
|
|
||||||
self.title = dec.title
|
|
||||||
self.genre = dec.genre
|
|
||||||
self.comment = dec.comment
|
|
||||||
self.year = dec.year
|
|
||||||
self.track = dec.track
|
|
||||||
dec.close()
|
|
||||||
|
|
||||||
class OggFile(MusicFile):
|
|
||||||
HANDLED_EXTS = set(['ogg'])
|
|
||||||
def _read_info(self, field):
|
|
||||||
if field == 'md5partial':
|
|
||||||
dec = ogg.Vorbis(str(self.path))
|
|
||||||
self._md5partial_offset = dec.audio_offset
|
|
||||||
self._md5partial_size = dec.audio_size
|
|
||||||
MusicFile._read_info(self, field)
|
|
||||||
if field in TAG_FIELDS:
|
|
||||||
dec = ogg.Vorbis(str(self.path))
|
|
||||||
self.audiosize = dec.audio_size
|
|
||||||
self.bitrate = dec.bitrate
|
|
||||||
self.duration = dec.duration
|
|
||||||
self.samplerate = dec.sample_rate
|
|
||||||
self.artist = dec.artist
|
|
||||||
self.album = dec.album
|
|
||||||
self.title = dec.title
|
|
||||||
self.genre = dec.genre
|
|
||||||
self.comment = dec.comment
|
|
||||||
self.year = dec.year
|
|
||||||
self.track = dec.track
|
|
||||||
|
|
||||||
class FlacFile(MusicFile):
|
|
||||||
HANDLED_EXTS = set(['flac'])
|
|
||||||
def _read_info(self, field):
|
|
||||||
if field == 'md5partial':
|
|
||||||
dec = flac.FLAC(str(self.path))
|
|
||||||
self._md5partial_offset = dec.audio_offset
|
|
||||||
self._md5partial_size = dec.audio_size
|
|
||||||
MusicFile._read_info(self, field)
|
|
||||||
if field in TAG_FIELDS:
|
|
||||||
dec = flac.FLAC(str(self.path))
|
|
||||||
self.audiosize = dec.audio_size
|
|
||||||
self.bitrate = dec.bitrate
|
|
||||||
self.duration = dec.duration
|
|
||||||
self.samplerate = dec.sample_rate
|
|
||||||
self.artist = dec.artist
|
|
||||||
self.album = dec.album
|
|
||||||
self.title = dec.title
|
|
||||||
self.genre = dec.genre
|
|
||||||
self.comment = dec.comment
|
|
||||||
self.year = dec.year
|
|
||||||
self.track = dec.track
|
|
||||||
|
|
||||||
class AiffFile(MusicFile):
|
|
||||||
HANDLED_EXTS = set(['aif', 'aiff', 'aifc'])
|
|
||||||
def _read_info(self, field):
|
|
||||||
if field == 'md5partial':
|
|
||||||
dec = aiff.File(str(self.path))
|
|
||||||
self._md5partial_offset = dec.audio_offset
|
|
||||||
self._md5partial_size = dec.audio_size
|
|
||||||
MusicFile._read_info(self, field)
|
|
||||||
if field in TAG_FIELDS:
|
|
||||||
dec = aiff.File(str(self.path))
|
|
||||||
self.audiosize = dec.audio_size
|
|
||||||
self.bitrate = dec.bitrate
|
|
||||||
self.duration = dec.duration
|
|
||||||
self.samplerate = dec.sample_rate
|
|
||||||
tag = dec.tag
|
|
||||||
if tag is not None:
|
|
||||||
self.artist = tag.artist
|
|
||||||
self.album = tag.album
|
|
||||||
self.title = tag.title
|
|
||||||
self.genre = tag.genre
|
|
||||||
self.comment = tag.comment
|
|
||||||
self.year = tag.year
|
|
||||||
self.track = tag.track
|
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ class DupeGuru(DupeGuruBase):
|
|||||||
|
|
||||||
def _setup(self):
|
def _setup(self):
|
||||||
self.scanner = scanner.ScannerME()
|
self.scanner = scanner.ScannerME()
|
||||||
self.directories.fileclasses = [fs.Mp3File, fs.Mp4File, fs.WmaFile, fs.OggFile, fs.FlacFile, fs.AiffFile]
|
self.directories.fileclasses = [fs.MusicFile]
|
||||||
DupeGuruBase._setup(self)
|
DupeGuruBase._setup(self)
|
||||||
|
|
||||||
def _update_options(self):
|
def _update_options(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user