From d3776f4ea90c94be4dba6ea12f609aaa6b263536 Mon Sep 17 00:00:00 2001 From: Naomi Aro Date: Fri, 22 Jul 2011 12:54:42 +0200 Subject: [PATCH] CC-2582 : Files with a tracknumber that isn't actually a tracknumber don't get imported properly adding more metadata checks so it won't have a database insertion issue. --- .../application/controllers/ApiController.php | 15 --------------- airtime_mvc/application/models/StoredFile.php | 14 +++++++------- .../airtimefilemonitor/airtimemetadata.py | 13 ++++++++----- .../airtimefilemonitor/airtimeprocessevent.py | 3 --- 4 files changed, 15 insertions(+), 30 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 112fdf575..028b43e86 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -454,21 +454,6 @@ class ApiController extends Zend_Controller_Action return; } - - //Martin Konecny July 14th, 2011: The following commented out code is the way - //we used to check for duplicates (by md5). Why are we checking by md5 and - //not by filepath? - /* - $md5 = $md['MDATA_KEY_MD5']; - $file = StoredFile::RecallByMd5($md5); - if (is_null($file)) { - $file = StoredFile::Insert($md); - } - else { - $this->view->error = "File already exists in Airtime."; - return; - } - */ } else if ($mode == "modify") { $filepath = $md['MDATA_KEY_FILEPATH']; diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 0068d146e..1f6f905bd 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -91,13 +91,6 @@ class StoredFile { } } - public static function getFileCount() - { - global $CC_CONFIG, $CC_DBC; - $sql = "SELECT count(*) as cnt FROM ".$CC_CONFIG["filesTable"]; - return $CC_DBC->GetOne($sql); - } - /** * Set multiple metadata values using database columns as indexes. * @@ -826,6 +819,13 @@ class StoredFile { } + public static function getFileCount() + { + global $CC_CONFIG, $CC_DBC; + $sql = "SELECT count(*) as cnt FROM ".$CC_CONFIG["filesTable"]; + return $CC_DBC->GetOne($sql); + } + public static function listAllFiles($dir_id){ global $CC_DBC; diff --git a/python_apps/media-monitor/airtimefilemonitor/airtimemetadata.py b/python_apps/media-monitor/airtimefilemonitor/airtimemetadata.py index 43bc2c90c..af709b17d 100644 --- a/python_apps/media-monitor/airtimefilemonitor/airtimemetadata.py +++ b/python_apps/media-monitor/airtimefilemonitor/airtimemetadata.py @@ -139,15 +139,18 @@ class AirtimeMetadata: if isinstance(md['MDATA_KEY_TRACKNUMBER'], basestring): match = re.search('^(\d*/\d*)?', md['MDATA_KEY_TRACKNUMBER']) - self.logger.debug('match is') - self.logger.debug(match.group(0)) - if match.group(0) is not u'': md['MDATA_KEY_TRACKNUMBER'] = md['MDATA_KEY_TRACKNUMBER'].split("/")[0] - self.logger.debug(md['MDATA_KEY_TRACKNUMBER']) else: del md['MDATA_KEY_TRACKNUMBER'] - self.logger.debug("deleting tracknumber") + + #make sure bpm is valid, need to check more types of formats for this tag to assure correct parsing. + if 'MDATA_KEY_BPM' in md: + if isinstance(md['MDATA_KEY_BPM'], basestring): + try: + md['MDATA_KEY_BPM'] = int(md['MDATA_KEY_BPM']) + except Exception, e: + del md['MDATA_KEY_BPM'] md['MDATA_KEY_BITRATE'] = file_info.info.bitrate md['MDATA_KEY_SAMPLERATE'] = file_info.info.sample_rate diff --git a/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py b/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py index 9b76b156a..a9279f6b5 100644 --- a/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py +++ b/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py @@ -67,14 +67,11 @@ class AirtimeProcessEvent(ProcessEvent): new_filepath = self.mmc.organize_new_file(pathname) return new_filepath else: - self.logger.debug("setting file permissions") self.mmc.set_needed_file_permissions(pathname, dir) - self.logger.debug("checking if recorded") if self.mmc.is_parent_directory(pathname, self.config.recorded_directory): is_recorded = True else : is_recorded = False - self.logger.debug("appending event") self.file_events.append({'mode': self.config.MODE_CREATE, 'filepath': pathname, 'is_recorded_show': is_recorded}) else: