From b84b9b997ed22282e1351081f6dd78543f54b568 Mon Sep 17 00:00:00 2001 From: sbuser Date: Sat, 6 Aug 2011 16:12:11 -0500 Subject: [PATCH] Added headphones.MEDIA_FORMATS and referenced it in various places. M4A had been left out in scanMusic. Should just have to change the literal in the future. --- headphones/__init__.py | 1 + headphones/importer.py | 2 +- headphones/postprocessor.py | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/headphones/__init__.py b/headphones/__init__.py index 84023254..6b9c91a6 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -99,6 +99,7 @@ NEWZBIN_PASSWORD = None LASTFM_USERNAME = None +MEDIA_FORMATS = ["mp3", "flac", "aac", "ogg", "ape", "m4a"] def CheckSection(sec): """ Check if INI section exists, if not create it """ diff --git a/headphones/importer.py b/headphones/importer.py index a64e959e..aa4a544b 100644 --- a/headphones/importer.py +++ b/headphones/importer.py @@ -24,7 +24,7 @@ def scanMusic(dir=None): for r,d,f in os.walk(dir): for files in f: - if any(files.endswith(x) for x in (".mp3", ".flac", ".aac", ".ogg", ".ape", ".m4a")): + if any(files.endswith('.' + x) for x in headphones.MEDIA_FORMATS): results.append(os.path.join(r, files)) logger.info(u'%i music files found. Reading metadata....' % len(results)) diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index e97d46b1..13b753e3 100644 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -113,7 +113,7 @@ def verify(albumid, albumpath): downloaded_track_list = [] for r,d,f in os.walk(albumpath): for files in f: - if any(files.endswith(x) for x in (".mp3", ".flac", ".aac", ".ogg", ".ape", ".m4a")): + if any(files.endswith('.' + x) for x in headphones.MEDIA_FORMATS): downloaded_track_list.append(os.path.join(r, files)) # test #1: metadata - usually works @@ -240,7 +240,7 @@ def cleanupFiles(albumpath): logger.info('Cleaning up files') for r,d,f in os.walk(albumpath): for files in f: - if not any(files.endswith(x) for x in (".mp3", ".flac", ".aac", ".ogg", ".ape", ".m4a")): + if not any(files.endswith('.' + x) for x in headphones.MEDIA_FORMATS): logger.debug('Removing: %s' % files) try: os.remove(os.path.join(r, files)) @@ -393,7 +393,7 @@ def updateHave(albumpath): for r,d,f in os.walk(albumpath): for files in f: - if any(files.endswith(x) for x in (".mp3", ".flac", ".aac", ".ogg", ".ape")): + if any(files.endswith('.' + x) for x in headphones.MEDIA_FORMATS): results.append(os.path.join(r, files)) if results: