Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
ae08c54689
|
@ -221,11 +221,14 @@ class AirtimeMetadata:
|
||||||
md['MDATA_KEY_COPYRIGHT'] = self.truncate_to_length(md['MDATA_KEY_COPYRIGHT'], 512)
|
md['MDATA_KEY_COPYRIGHT'] = self.truncate_to_length(md['MDATA_KEY_COPYRIGHT'], 512)
|
||||||
#end of db truncation checks.
|
#end of db truncation checks.
|
||||||
|
|
||||||
|
md['MDATA_KEY_BITRATE'] = getattr(file_info.info, "bitrate", None)
|
||||||
|
md['MDATA_KEY_SAMPLERATE'] = getattr(file_info.info, "sample_rate", None)
|
||||||
|
self.logger.info( "Bitrate: %s , Samplerate: %s", md['MDATA_KEY_BITRATE'], md['MDATA_KEY_SAMPLERATE'] )
|
||||||
|
try: md['MDATA_KEY_DURATION'] = self.format_length(file_info.info.length)
|
||||||
|
except Exception as e: self.logger.warn("File: '%s' raises: %s", filepath, str(e))
|
||||||
|
|
||||||
md['MDATA_KEY_BITRATE'] = file_info.info.bitrate
|
try: md['MDATA_KEY_MIME'] = file_info.mime[0]
|
||||||
md['MDATA_KEY_SAMPLERATE'] = file_info.info.sample_rate
|
except Exception as e: self.logger.warn("File: '%s' has no mime type", filepath, str(e))
|
||||||
md['MDATA_KEY_DURATION'] = self.format_length(file_info.info.length)
|
|
||||||
md['MDATA_KEY_MIME'] = file_info.mime[0]
|
|
||||||
|
|
||||||
if "mp3" in md['MDATA_KEY_MIME']:
|
if "mp3" in md['MDATA_KEY_MIME']:
|
||||||
md['MDATA_KEY_FTYPE'] = "audioclip"
|
md['MDATA_KEY_FTYPE'] = "audioclip"
|
||||||
|
|
|
@ -191,6 +191,7 @@ class AirtimeNotifier(Notifier):
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
self.logger.error("failed updating filepath: %s ", event['filepath'])
|
self.logger.error("failed updating filepath: %s ", event['filepath'])
|
||||||
self.logger.error('Exception: %s', e)
|
self.logger.error('Exception: %s', e)
|
||||||
|
self.logger.error('Traceback: %s', traceback.format_exc())
|
||||||
|
|
||||||
#define which directories the pyinotify WatchManager should watch.
|
#define which directories the pyinotify WatchManager should watch.
|
||||||
def watch_directory(self, directory):
|
def watch_directory(self, directory):
|
||||||
|
|
|
@ -35,20 +35,13 @@ class MediaMonitorCommon:
|
||||||
# if file doesn't have any extension, info[-2] throws exception
|
# if file doesn't have any extension, info[-2] throws exception
|
||||||
# Hence, checking length of info before we do anything
|
# Hence, checking length of info before we do anything
|
||||||
if(len(info) >= 2):
|
if(len(info) >= 2):
|
||||||
if(info[-2].lower() in self.supported_file_formats):
|
return info[-2].lower() in self.supported_file_formats
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def is_audio_file(self, filename):
|
def is_audio_file(self, filename):
|
||||||
info = filename.split(".")
|
info = filename.split(".")
|
||||||
|
return info[-1].lower() in self.supported_file_formats
|
||||||
if(info[-1].lower() in self.supported_file_formats):
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
#check if file is readable by "nobody"
|
#check if file is readable by "nobody"
|
||||||
def is_user_readable(self, filepath, euid='nobody', egid='nogroup'):
|
def is_user_readable(self, filepath, euid='nobody', egid='nogroup'):
|
||||||
|
|
|
@ -117,9 +117,9 @@ try:
|
||||||
|
|
||||||
notifier = AirtimeNotifier(wm, pe, read_freq=0, timeout=0, airtime_config=config, api_client=api_client, bootstrap=bootstrap, mmc=mmc)
|
notifier = AirtimeNotifier(wm, pe, read_freq=0, timeout=0, airtime_config=config, api_client=api_client, bootstrap=bootstrap, mmc=mmc)
|
||||||
notifier.coalesce_events()
|
notifier.coalesce_events()
|
||||||
|
|
||||||
#create 5 worker threads
|
#create 5 worker threads
|
||||||
wp = MediaMonitorWorkerProcess(config, mmc)
|
wp = MediaMonitorWorkerProcess(config, mmc)
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
threadName = "Thread #%d" % i
|
threadName = "Thread #%d" % i
|
||||||
t = Thread(target=wp.process_file_events, name=threadName, args=(multi_queue, notifier))
|
t = Thread(target=wp.process_file_events, name=threadName, args=(multi_queue, notifier))
|
||||||
|
|
Loading…
Reference in New Issue