CC-2505 : Media monitor doesn't delete some tracks from the Airtime server due to weird characters in file names
seems to fix unicode problems I was having.
This commit is contained in:
parent
c74af05f18
commit
e369ab8dee
2 changed files with 59 additions and 52 deletions
|
@ -120,45 +120,52 @@ class AirtimeNotifier(Notifier):
|
|||
# -data
|
||||
# -is_recorded_show
|
||||
def update_airtime(self, d):
|
||||
filepath = d['filepath']
|
||||
mode = d['mode']
|
||||
|
||||
md = {}
|
||||
md['MDATA_KEY_FILEPATH'] = filepath.encode("utf_8")
|
||||
try:
|
||||
self.logger.info("updating filepath: %s ", d['filepath'])
|
||||
filepath = d['filepath']
|
||||
mode = d['mode']
|
||||
|
||||
if 'data' in d:
|
||||
file_md = d['data']
|
||||
md.update(file_md)
|
||||
else:
|
||||
file_md = None
|
||||
data = None
|
||||
md = {}
|
||||
md['MDATA_KEY_FILEPATH'] = filepath
|
||||
|
||||
if 'data' in d:
|
||||
file_md = d['data']
|
||||
md.update(file_md)
|
||||
else:
|
||||
file_md = None
|
||||
data = None
|
||||
|
||||
|
||||
if (os.path.exists(filepath) and (mode == self.config.MODE_CREATE)):
|
||||
if file_md is None:
|
||||
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']:
|
||||
self.api_client.update_media_metadata(md, mode, True)
|
||||
else:
|
||||
self.api_client.update_media_metadata(md, mode)
|
||||
|
||||
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)
|
||||
|
||||
if d['is_recorded_show']:
|
||||
self.api_client.update_media_metadata(md, mode, True)
|
||||
else:
|
||||
self.api_client.update_media_metadata(md, mode)
|
||||
|
||||
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)
|
||||
elif (mode == self.config.MODE_MOVED):
|
||||
md['MDATA_KEY_MD5'] = self.md_manager.get_md5(filepath)
|
||||
self.api_client.update_media_metadata(md, mode)
|
||||
|
||||
elif (mode == self.config.MODE_MOVED):
|
||||
md['MDATA_KEY_MD5'] = self.md_manager.get_md5(filepath)
|
||||
self.api_client.update_media_metadata(md, mode)
|
||||
elif (mode == self.config.MODE_DELETE):
|
||||
self.api_client.update_media_metadata(md, mode)
|
||||
|
||||
elif (mode == self.config.MODE_DELETE):
|
||||
self.api_client.update_media_metadata(md, mode)
|
||||
except Exception, e:
|
||||
self.logger.error("failed updating filepath: %s ", d['filepath'])
|
||||
self.logger.error('Exception: %s', e)
|
||||
|
||||
#define which directories the pyinotify WatchManager should watch.
|
||||
def watch_directory(self, directory):
|
||||
|
|
|
@ -228,7 +228,7 @@ class MediaMonitorCommon:
|
|||
open(self.timestamp_file, "w")
|
||||
|
||||
def organize_new_file(self, pathname):
|
||||
self.logger.info(u"Organizing new file: %s", pathname)
|
||||
self.logger.info("Organizing new file: %s", pathname)
|
||||
file_md = self.md_manager.get_md_from_file(pathname)
|
||||
|
||||
if file_md is not None:
|
||||
|
@ -236,7 +236,7 @@ class MediaMonitorCommon:
|
|||
# file_md['MDATA_KEY_CREATOR'] == "AIRTIMERECORDERSOURCEFABRIC".encode('utf-8')
|
||||
filepath = self.create_file_path(pathname, file_md)
|
||||
|
||||
self.logger.debug(u"Moving from %s to %s", pathname, filepath)
|
||||
self.logger.debug("Moving from %s to %s", pathname, filepath)
|
||||
self.move_file(pathname, filepath)
|
||||
else:
|
||||
filepath = None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue