1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2025-05-10 18:59:49 +00:00

Compare commits

..

No commits in common. "16df882481018fd95dee4d45fe734a318eac4a22" and "6b8f85e39a271ad12a5c0708a5ab162319db4a0f" have entirely different histories.

2 changed files with 17 additions and 22 deletions

View File

@ -6,7 +6,7 @@
# 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.gnu.org/licenses/gpl-3.0.html # http://www.gnu.org/licenses/gpl-3.0.html
import mutagen from hsaudiotag import auto
from hscommon.util import get_file_ext, format_size, format_time from hscommon.util import get_file_ext, format_size, format_time
from core.util import format_timestamp, format_perc, format_words, format_dupe_count from core.util import format_timestamp, format_perc, format_words, format_dupe_count
@ -26,9 +26,6 @@ TAG_FIELDS = {
"comment", "comment",
} }
# This is a temporary workaround for migration from hsaudiotag for the can_handle method
SUPPORTED_EXTS = {"mp3", "wma", "m4a", "m4p", "ogg", "flac", "aif", "aiff", "aifc"}
class MusicFile(fs.File): class MusicFile(fs.File):
INITIAL_INFO = fs.File.INITIAL_INFO.copy() INITIAL_INFO = fs.File.INITIAL_INFO.copy()
@ -53,7 +50,7 @@ class MusicFile(fs.File):
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.name) in SUPPORTED_EXTS return get_file_ext(path.name) in auto.EXT2CLASS
def get_display_info(self, group, delta): def get_display_info(self, group, delta):
size = self.size size = self.size
@ -98,23 +95,21 @@ class MusicFile(fs.File):
} }
def _get_md5partial_offset_and_size(self): def _get_md5partial_offset_and_size(self):
# No longer calculating the offset and audio size, just whole file f = auto.File(str(self.path))
size = self.path.stat().st_size return (f.audio_offset, f.audio_size)
return (0, size)
def _read_info(self, field): def _read_info(self, field):
fs.File._read_info(self, field) fs.File._read_info(self, field)
if field in TAG_FIELDS: if field in TAG_FIELDS:
# The various conversions here are to make this look like the previous implementation f = auto.File(str(self.path))
file = mutagen.File(str(self.path), easy=True) self.audiosize = f.audio_size
self.audiosize = self.path.stat().st_size self.bitrate = f.bitrate
self.bitrate = file.info.bitrate / 1000 self.duration = f.duration
self.duration = file.info.length self.samplerate = f.sample_rate
self.samplerate = file.info.sample_rate self.artist = f.artist
self.artist = ", ".join(file.tags.get("artist") or []) self.album = f.album
self.album = ", ".join(file.tags.get("album") or []) self.title = f.title
self.title = ", ".join(file.tags.get("title") or []) self.genre = f.genre
self.genre = ", ".join(file.tags.get("genre") or []) self.comment = f.comment
self.comment = ", ".join(file.tags.get("comment") or [""]) self.year = f.year
self.year = ", ".join(file.tags.get("date") or []) self.track = f.track
self.track = (file.tags.get("tracknumber") or [""])[0]

View File

@ -1,7 +1,7 @@
Send2Trash>=1.3.0 Send2Trash>=1.3.0
sphinx>=3.0.0 sphinx>=3.0.0
polib>=1.1.0 polib>=1.1.0
mutagen>=1.45.1 hsaudiotag3k>=1.1.3*
distro>=1.5.0 distro>=1.5.0
PyQt5 >=5.14.1,<6.0; sys_platform != 'linux' PyQt5 >=5.14.1,<6.0; sys_platform != 'linux'
pywin32>=228; sys_platform == 'win32' pywin32>=228; sys_platform == 'win32'