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,11 +104,17 @@ class AirtimeMetadata:
|
||||||
|
|
||||||
self.logger.info("getting info from filepath %s", filepath)
|
self.logger.info("getting info from filepath %s", filepath)
|
||||||
|
|
||||||
md = {}
|
try:
|
||||||
md5 = self.get_md5(filepath)
|
md = {}
|
||||||
md['MDATA_KEY_MD5'] = md5
|
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
|
||||||
|
|
||||||
file_info = mutagen.File(filepath, easy=True)
|
|
||||||
|
|
||||||
self.logger.info(file_info)
|
self.logger.info(file_info)
|
||||||
|
|
||||||
|
|
|
@ -123,6 +123,8 @@ class AirtimeNotifier(Notifier):
|
||||||
if (os.path.exists(filepath) and (mode == self.config.MODE_CREATE)):
|
if (os.path.exists(filepath) and (mode == self.config.MODE_CREATE)):
|
||||||
if file_md is None:
|
if file_md is None:
|
||||||
mutagen = self.md_manager.get_md_from_file(filepath)
|
mutagen = self.md_manager.get_md_from_file(filepath)
|
||||||
|
if mutagen is None:
|
||||||
|
return
|
||||||
md.update(mutagen)
|
md.update(mutagen)
|
||||||
|
|
||||||
if d['is_recorded_show']:
|
if d['is_recorded_show']:
|
||||||
|
@ -132,6 +134,8 @@ class AirtimeNotifier(Notifier):
|
||||||
|
|
||||||
elif (os.path.exists(filepath) and (mode == self.config.MODE_MODIFY)):
|
elif (os.path.exists(filepath) and (mode == self.config.MODE_MODIFY)):
|
||||||
mutagen = self.md_manager.get_md_from_file(filepath)
|
mutagen = self.md_manager.get_md_from_file(filepath)
|
||||||
|
if mutagen is None:
|
||||||
|
return
|
||||||
md.update(mutagen)
|
md.update(mutagen)
|
||||||
self.api_client.update_media_metadata(md, mode)
|
self.api_client.update_media_metadata(md, mode)
|
||||||
|
|
||||||
|
@ -163,5 +167,5 @@ class AirtimeNotifier(Notifier):
|
||||||
if mm.is_audio_file(full_filepath):
|
if mm.is_audio_file(full_filepath):
|
||||||
self.logger.info("importing %s", full_filepath)
|
self.logger.info("importing %s", full_filepath)
|
||||||
event = {'filepath': full_filepath, 'mode': self.config.MODE_CREATE, 'is_recorded_show': False}
|
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
|
return filepath
|
||||||
|
|
||||||
def create_file_path(self, imported_filepath):
|
def create_file_path(self, imported_filepath, orig_md):
|
||||||
|
|
||||||
storage_directory = self.config.storage_directory
|
storage_directory = self.config.storage_directory
|
||||||
|
|
||||||
|
@ -149,7 +149,6 @@ class AirtimeProcessEvent(ProcessEvent):
|
||||||
file_ext = os.path.splitext(imported_filepath)[1]
|
file_ext = os.path.splitext(imported_filepath)[1]
|
||||||
file_ext = file_ext.encode('utf-8')
|
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']
|
path_md = ['MDATA_KEY_TITLE', 'MDATA_KEY_CREATOR', 'MDATA_KEY_SOURCE', 'MDATA_KEY_TRACKNUMBER', 'MDATA_KEY_BITRATE']
|
||||||
|
|
||||||
md = {}
|
md = {}
|
||||||
|
@ -191,7 +190,7 @@ class AirtimeProcessEvent(ProcessEvent):
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
self.logger.error('Exception: %s', 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):
|
def process_IN_CREATE(self, event):
|
||||||
|
|
||||||
|
@ -206,10 +205,13 @@ class AirtimeProcessEvent(ProcessEvent):
|
||||||
elif self.is_audio_file(event.pathname):
|
elif self.is_audio_file(event.pathname):
|
||||||
if self.is_parent_directory(event.pathname, storage_directory):
|
if self.is_parent_directory(event.pathname, storage_directory):
|
||||||
self.set_needed_file_permissions(event.pathname, event.dir)
|
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)
|
||||||
self.move_file(event.pathname, filepath)
|
|
||||||
self.renamed_files[event.pathname] = filepath
|
if file_md is not None:
|
||||||
self.file_events.append({'mode': self.config.MODE_CREATE, 'filepath': filepath, 'data': file_md, 'is_recorded_show': is_recorded_show})
|
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})
|
||||||
else:
|
else:
|
||||||
self.file_events.append({'mode': self.config.MODE_CREATE, 'filepath': event.pathname, 'is_recorded_show': False})
|
self.file_events.append({'mode': self.config.MODE_CREATE, 'filepath': event.pathname, 'is_recorded_show': False})
|
||||||
|
|
||||||
|
@ -256,10 +258,12 @@ class AirtimeProcessEvent(ProcessEvent):
|
||||||
# show dragged from unwatched folder into a watched folder.
|
# show dragged from unwatched folder into a watched folder.
|
||||||
storage_directory = self.config.storage_directory
|
storage_directory = self.config.storage_directory
|
||||||
if self.is_parent_directory(event.pathname, 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)
|
||||||
self.move_file(event.pathname, filepath)
|
if file_md is not None:
|
||||||
self.renamed_files[event.pathname] = filepath
|
filepath, is_recorded_show = self.create_file_path(event.pathname)
|
||||||
self.file_events.append({'mode': self.config.MODE_CREATE, 'filepath': filepath, 'data': file_md, 'is_recorded_show': False})
|
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})
|
||||||
else:
|
else:
|
||||||
self.file_events.append({'mode': self.config.MODE_CREATE, 'filepath': event.pathname, 'is_recorded_show': False})
|
self.file_events.append({'mode': self.config.MODE_CREATE, 'filepath': event.pathname, 'is_recorded_show': False})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue