diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index 5f43443ce..c69014689 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -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'); diff --git a/python_apps/api_clients/api_client.py b/python_apps/api_clients/api_client.py index 348cb6b53..62feb1ee0 100755 --- a/python_apps/api_clients/api_client.py +++ b/python_apps/api_clients/api_client.py @@ -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'])) diff --git a/python_apps/media-monitor/airtimefilemonitor/airtimemetadata.py b/python_apps/media-monitor/airtimefilemonitor/airtimemetadata.py index 8214aadf8..18edbc7c5 100644 --- a/python_apps/media-monitor/airtimefilemonitor/airtimemetadata.py +++ b/python_apps/media-monitor/airtimefilemonitor/airtimemetadata.py @@ -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) diff --git a/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py b/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py index 189eed7ec..fd121c725 100644 --- a/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py +++ b/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py @@ -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: