Permalink
Browse files

Replaced ACCEPTED_FORMATS with VALID_FILE_EXTENSIONS in indexer (refs #…

  • Loading branch information...
1 parent 20a2171 commit 41499f3df88f332d72808219bddead19b1ab2c13 @dbrgn committed Mar 31, 2013
Showing with 22 additions and 6 deletions.
  1. +6 −6 indexer.py
  2. +16 −0 shiva/utils.py
View
@@ -152,18 +152,18 @@ def get_metadata_reader(self):
return self._meta
def is_track(self):
- """Tries to guess whether the file is a valid track or not.
- """
- if os.path.isdir(self.file_path):
+ """Try to guess whether the file is a valid track or not."""
+ if not os.path.isfile(self.file_path):
return False
if '.' not in self.file_path:
return False
- ext = self.file_path[self.file_path.rfind('.') + 1:]
- if ext not in self.config.get('ACCEPTED_FORMATS', []):
+ ext = self.file_path.rsplit('.', 1)[1]
+ if ext not in self.get_metadata_reader().VALID_FILE_EXTENSIONS:
if not self.quiet:
- print(self.file_path + ' is not in ACCEPTED_FORMATS')
+ msg = 'Skipped file with unknown file extension: %s'
+ print msg % self.file_path
return False
return True
View
@@ -60,6 +60,22 @@ def __init__(self, filepath):
self._original_path = filepath
self.reader = mutagen.File(filepath, easy=True)
+ # Static attributes
+
+ VALID_FILE_EXTENSIONS = [
+ 'asf', 'wma', # ASF
+ 'flac', # FLAC
+ 'mp4', 'm4a', 'm4b', 'm4p', # M4A
+ 'ape', # Monkey's Audio
+ 'mp3', # MP3
+ 'mpc', 'mp+', 'mpp', # Musepack
+ 'spx', # Ogg Speex
+ 'ogg', 'oga', # Ogg Vorbis / Theora
+ 'tta', # True Audio
+ 'wv', # WavPack
+ 'ofr', # OptimFROG
+ ]
+
# Metadata properties
@property

1 comment on commit 41499f3

Owner
dbrgn commented on 41499f3 Mar 31, 2013

Supported formats via Mutagen project page, common file extensions via Wikipedia.

Please sign in to comment.