More logging + proper exception catching.

This commit is contained in:
Bas Stottelaar
2014-09-14 14:03:56 +02:00
parent a1e2042315
commit a1bc3617a4
+6 -7
View File
@@ -15,10 +15,10 @@
import os import os
import glob import glob
from beets.mediafile import MediaFile
import headphones import headphones
from beets.mediafile import MediaFile, FileTypeError, UnreadableFileError
from headphones import db, logger, helpers, importer, lastfm from headphones import db, logger, helpers, importer, lastfm
# You can scan a single directory and append it to the current library by specifying append=True, ArtistID & ArtistName # You can scan a single directory and append it to the current library by specifying append=True, ArtistID & ArtistName
@@ -84,8 +84,8 @@ def libraryScan(dir=None, append=False, ArtistID=None, ArtistName=None, cron=Fal
for directory in d[:]: for directory in d[:]:
if directory.startswith("."): if directory.startswith("."):
d.remove(directory) d.remove(directory)
for files in f:
for files in f:
# MEDIA_FORMATS = music file extensions, e.g. mp3, flac, etc # MEDIA_FORMATS = music file extensions, e.g. mp3, flac, etc
if any(files.lower().endswith('.' + x.lower()) for x in headphones.MEDIA_FORMATS): if any(files.lower().endswith('.' + x.lower()) for x in headphones.MEDIA_FORMATS):
@@ -104,9 +104,8 @@ def libraryScan(dir=None, append=False, ArtistID=None, ArtistName=None, cron=Fal
# Try to read the metadata # Try to read the metadata
try: try:
f = MediaFile(song) f = MediaFile(song)
except (FileTypeError, UnreadableFileError):
except: logger.error("Cannot read file media file '%s'. It may be corrupted or not a media file.", unicode_song_path)
logger.error('Cannot read file: ' + unicode_song_path)
continue continue
# Grab the bitrates for the auto detect bit rate option # Grab the bitrates for the auto detect bit rate option