CC-2919: Media Monitor: recorded show doesn't show on library after

recording is done

- fixed
- extra fix: Airtime wasn't updating file when updating metadata
This commit is contained in:
James 2011-10-03 14:10:47 -04:00
parent 7e3d25eeaa
commit 5e9aec93a8
4 changed files with 23 additions and 4 deletions

View File

@ -213,7 +213,10 @@ class LibraryController extends Zend_Controller_Action
$file->setDbColMetadata($formdata);
$data = $file->getMetadata();
// set MDATA_KEY_FILEPATH
$data['MDATA_KEY_FILEPATH'] = $file->getFilePath();
Logging::log($data['MDATA_KEY_FILEPATH']);
Application_Model_RabbitMq::SendMessageToMediaMonitor("md_update", $data);
$this->_helper->redirector('index');

View File

@ -422,7 +422,7 @@ class AirTimeApiClient(ApiClientInterface):
elapsed = (time.time() - start)
logger.info("time taken to get response %s", elapsed)
if(is_record):
if("error" not in response and is_record):
url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["upload_recorded"])
url = url.replace("%%fileid%%", str(response[u'id']))
url = url.replace("%%showinstanceid%%", str(md['MDATA_KEY_TRACKNUMBER']))

View File

@ -125,7 +125,7 @@ class AirtimeMetadata:
self.logger.debug("Saving %s to file", key)
self.logger.debug(value)
if isinstance(value, basestring) and (len(value) > 0):
airtime_file[self.airtime2mutagen[key]] = unicode(value, "utf-8")
airtime_file[self.airtime2mutagen[key]] = api_client.encode_to(value, 'utf-8')
elif isinstance(value, int):
airtime_file[self.airtime2mutagen[key]] = str(value)

View File

@ -36,6 +36,7 @@ class AirtimeProcessEvent(ProcessEvent):
self.md_manager = AirtimeMetadata()
self.mmc = mmc
self.api_client = api_client
self.create_dict = {}
def add_filepath_to_ignore(self, filepath):
self.ignore_event.add(filepath)
@ -87,6 +88,14 @@ class AirtimeProcessEvent(ProcessEvent):
else:
self.logger.info("Removing the watch folder failed: %s", res['msg']['error'])
def process_IN_CREATE(self, event):
self.logger.info("event: %s", event)
if not event.dir:
if self.mmc.is_parent_directory(event.pathname, self.config.recorded_directory):
self.file_events.append({'mode': self.config.MODE_CREATE, 'filepath': event.pathname, 'is_recorded_show': True})
self.create_dict[event.pathname] = time.time()
#event.dir: True if the event was raised against a directory.
#event.name: filename
#event.pathname: pathname (str): Concatenation of 'path' and 'name'.
@ -94,7 +103,10 @@ class AirtimeProcessEvent(ProcessEvent):
# copy was done. Hence, IN_CLOSE_WRITE is the correct one to handle.
def process_IN_CLOSE_WRITE(self, event):
self.logger.info("event: %s", event)
self.handle_created_file(event.dir, event.pathname, event.name)
self.logger.info("create_dict: %s", self.create_dict)
if event.pathname in self.create_dict:
self.create_dict.pop(event.pathname)
self.handle_created_file(event.dir, event.pathname, event.name)
def handle_created_file(self, dir, pathname, name):
if not dir:
@ -255,6 +267,10 @@ class AirtimeProcessEvent(ProcessEvent):
del self.cookies_IN_MOVED_FROM[k]
self.handle_removed_file(False, event.pathname)
for k, t in self.create_dict.items():
now = time.time()
if now - t > 5:
del self.create_dict[k]
#check for any events received from Airtime.
try: