CC-3470: Smarter way for pypo to recover when it should be playing something.
-check file integrity before adding to library.
This commit is contained in:
parent
b9e840552b
commit
eb8d5ee1d7
|
@ -3,6 +3,7 @@ import grp
|
|||
import pwd
|
||||
import logging
|
||||
import stat
|
||||
import subprocess
|
||||
|
||||
from subprocess import Popen, PIPE
|
||||
from airtimemetadata import AirtimeMetadata
|
||||
|
@ -289,3 +290,16 @@ class MediaMonitorCommon:
|
|||
self.logger.warn("File %s, has invalid metadata", pathname)
|
||||
|
||||
return filepath
|
||||
|
||||
def test_file_playability(pathname):
|
||||
"""
|
||||
Test if the file can be played by Liquidsoap. Return "True" if Liquidsoap
|
||||
can play it, or if Liquidsoap is not found.
|
||||
"""
|
||||
liquidsoap_found = subprocess.call("which liquidsoap", shell=True)
|
||||
if liquidsoap_found == 0:
|
||||
return_code = subprocess.call("liquidsoap -c 'output.dummy(single(\"%s\"))'" % pathname, shell=True)
|
||||
else:
|
||||
return_code = 0
|
||||
|
||||
return (return_code == 0)
|
||||
|
|
|
@ -1,12 +1,20 @@
|
|||
from mediaconfig import AirtimeMediaConfig
|
||||
import mediamonitorcommon
|
||||
|
||||
class MediaMonitorWorkerProcess:
|
||||
|
||||
#this function is run in its own process, and continuously
|
||||
#checks the queue for any new file events.
|
||||
def process_file_events(self, queue, notifier):
|
||||
|
||||
while True:
|
||||
event = queue.get()
|
||||
notifier.logger.info("received event %s", event)
|
||||
notifier.update_airtime(event)
|
||||
|
||||
|
||||
try:
|
||||
event = queue.get()
|
||||
if event['mode'] == AirtimeMediaConfig.MODE_CREATE:
|
||||
filepath = event['filepath']
|
||||
if mediamonitorcommon.test_file_playability(filepath):
|
||||
notifier.logger.info("received event %s", event)
|
||||
notifier.update_airtime(event)
|
||||
else:
|
||||
notifier.logger.warn("Liquidsoap integrity check for file at %s failed. Not adding to media library.", filepath)
|
||||
except Exception, e:
|
||||
notifier.logger.error(e)
|
||||
|
|
Loading…
Reference in New Issue