CC-2441 : media-monitor exception on import, cancels all importing
checking if file md fails.
This commit is contained in:
parent
4eff714f32
commit
164c06a5e5
3 changed files with 30 additions and 16 deletions
|
@ -104,12 +104,18 @@ class AirtimeMetadata:
|
|||
|
||||
self.logger.info("getting info from filepath %s", filepath)
|
||||
|
||||
try:
|
||||
md = {}
|
||||
md5 = self.get_md5(filepath)
|
||||
md['MDATA_KEY_MD5'] = md5
|
||||
|
||||
file_info = mutagen.File(filepath, easy=True)
|
||||
|
||||
except Exception, e:
|
||||
self.logger.error("failed getting metadata from %s", filepath)
|
||||
return None
|
||||
|
||||
|
||||
self.logger.info(file_info)
|
||||
|
||||
#check if file has any metadata
|
||||
|
|
|
@ -123,6 +123,8 @@ class AirtimeNotifier(Notifier):
|
|||
if (os.path.exists(filepath) and (mode == self.config.MODE_CREATE)):
|
||||
if file_md is None:
|
||||
mutagen = self.md_manager.get_md_from_file(filepath)
|
||||
if mutagen is None:
|
||||
return
|
||||
md.update(mutagen)
|
||||
|
||||
if d['is_recorded_show']:
|
||||
|
@ -132,6 +134,8 @@ class AirtimeNotifier(Notifier):
|
|||
|
||||
elif (os.path.exists(filepath) and (mode == self.config.MODE_MODIFY)):
|
||||
mutagen = self.md_manager.get_md_from_file(filepath)
|
||||
if mutagen is None:
|
||||
return
|
||||
md.update(mutagen)
|
||||
self.api_client.update_media_metadata(md, mode)
|
||||
|
||||
|
@ -163,5 +167,5 @@ class AirtimeNotifier(Notifier):
|
|||
if mm.is_audio_file(full_filepath):
|
||||
self.logger.info("importing %s", full_filepath)
|
||||
event = {'filepath': full_filepath, 'mode': self.config.MODE_CREATE, 'is_recorded_show': False}
|
||||
mm.file_events.put(event)
|
||||
mm.multi_queue.put(event)
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ class AirtimeProcessEvent(ProcessEvent):
|
|||
|
||||
return filepath
|
||||
|
||||
def create_file_path(self, imported_filepath):
|
||||
def create_file_path(self, imported_filepath, orig_md):
|
||||
|
||||
storage_directory = self.config.storage_directory
|
||||
|
||||
|
@ -149,7 +149,6 @@ class AirtimeProcessEvent(ProcessEvent):
|
|||
file_ext = os.path.splitext(imported_filepath)[1]
|
||||
file_ext = file_ext.encode('utf-8')
|
||||
|
||||
orig_md = self.md_manager.get_md_from_file(imported_filepath)
|
||||
path_md = ['MDATA_KEY_TITLE', 'MDATA_KEY_CREATOR', 'MDATA_KEY_SOURCE', 'MDATA_KEY_TRACKNUMBER', 'MDATA_KEY_BITRATE']
|
||||
|
||||
md = {}
|
||||
|
@ -191,7 +190,7 @@ class AirtimeProcessEvent(ProcessEvent):
|
|||
except Exception, e:
|
||||
self.logger.error('Exception: %s', e)
|
||||
|
||||
return filepath, orig_md, is_recorded_show
|
||||
return filepath, is_recorded_show
|
||||
|
||||
def process_IN_CREATE(self, event):
|
||||
|
||||
|
@ -206,7 +205,10 @@ class AirtimeProcessEvent(ProcessEvent):
|
|||
elif self.is_audio_file(event.pathname):
|
||||
if self.is_parent_directory(event.pathname, storage_directory):
|
||||
self.set_needed_file_permissions(event.pathname, event.dir)
|
||||
filepath, file_md, is_recorded_show = self.create_file_path(event.pathname)
|
||||
file_md = self.md_manager.get_md_from_file(event.pathname)
|
||||
|
||||
if file_md is not None:
|
||||
filepath, is_recorded_show = self.create_file_path(event.pathname, file_md)
|
||||
self.move_file(event.pathname, filepath)
|
||||
self.renamed_files[event.pathname] = filepath
|
||||
self.file_events.append({'mode': self.config.MODE_CREATE, 'filepath': filepath, 'data': file_md, 'is_recorded_show': is_recorded_show})
|
||||
|
@ -256,7 +258,9 @@ class AirtimeProcessEvent(ProcessEvent):
|
|||
# show dragged from unwatched folder into a watched folder.
|
||||
storage_directory = self.config.storage_directory
|
||||
if self.is_parent_directory(event.pathname, storage_directory):
|
||||
filepath, file_md, is_recorded_show = self.create_file_path(event.pathname)
|
||||
file_md = self.md_manager.get_md_from_file(event.pathname)
|
||||
if file_md is not None:
|
||||
filepath, is_recorded_show = self.create_file_path(event.pathname)
|
||||
self.move_file(event.pathname, filepath)
|
||||
self.renamed_files[event.pathname] = filepath
|
||||
self.file_events.append({'mode': self.config.MODE_CREATE, 'filepath': filepath, 'data': file_md, 'is_recorded_show': False})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue