From 8a490c3aa4691ca87bd42c7a5938859bbe733d0d Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 28 Aug 2012 10:52:20 -0400 Subject: [PATCH 1/7] cc-4305: removed extra commas that don't do anything --- python_apps/media-monitor2/media/monitor/pure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python_apps/media-monitor2/media/monitor/pure.py b/python_apps/media-monitor2/media/monitor/pure.py index f52871dc0..9e447a47a 100644 --- a/python_apps/media-monitor2/media/monitor/pure.py +++ b/python_apps/media-monitor2/media/monitor/pure.py @@ -293,7 +293,7 @@ def organized_path(old_path, root_path, orig_md): if is_airtime_recorded(normal_md): title_re = re.match("(?P\w+)-(?P\d+-\d+-\d+-\d+:\d+:\d+)$", normal_md['MDATA_KEY_TITLE']) - show_name, = title_re.group('show'), + show_name = title_re.group('show') date = title_re.group('date').replace(':','-') yyyy, mm, _ = normal_md['MDATA_KEY_YEAR'].split('-',2) fname_base = '%s-%s-%s.%s' % \ From 52b24235967fb3512a49cf2ff17db8708c4d5a0e Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 28 Aug 2012 10:54:55 -0400 Subject: [PATCH 2/7] cc-4305: documented set_metadata_and_save --- python_apps/pypo/recorder.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python_apps/pypo/recorder.py b/python_apps/pypo/recorder.py index f5601fa6c..dcf74fa04 100644 --- a/python_apps/pypo/recorder.py +++ b/python_apps/pypo/recorder.py @@ -134,6 +134,10 @@ class ShowRecorder(Thread): self.api_client.upload_recorded_show(datagen, headers) def set_metadata_and_save(self, filepath): + """ + Writes song to 'filepath'. Uses metadata from: + self.start_time, self.show_name, self.show_instance + """ try: date = self.start_time md = date.split(" ") From 7a926edd8f8d3295788e6c754b57c8e66661b311 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 28 Aug 2012 11:07:32 -0400 Subject: [PATCH 3/7] cc-4305: renamed time variable not to interefere with time module --- python_apps/pypo/recorder.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/python_apps/pypo/recorder.py b/python_apps/pypo/recorder.py index dcf74fa04..1bba9596c 100644 --- a/python_apps/pypo/recorder.py +++ b/python_apps/pypo/recorder.py @@ -141,18 +141,16 @@ class ShowRecorder(Thread): try: date = self.start_time md = date.split(" ") - # TODO : rename 'time' variable to something better so that there - # is no naming conflicts with the time module that is being - # imported - time = md[1].replace(":", "-") - self.logger.info("time: %s" % time) - name = time + "-" + self.show_name + record_time = md[1].replace(":", "-") + self.logger.info("time: %s" % record_time) + + show_title = time + "-" + self.show_name artist = "Airtime Show Recorder" #set some metadata for our file daemon recorded_file = mutagen.File(filepath, easy = True) - recorded_file['title'] = name + recorded_file['title'] = show_title recorded_file['artist'] = artist recorded_file['date'] = md[0] #recorded_file['date'] = md[0].split("-")[0] From 03015ac89c16cc20a6ca1a2c83147769d2159870 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 28 Aug 2012 11:11:01 -0400 Subject: [PATCH 4/7] cc-4305: removed unnecessary temporary variable --- python_apps/pypo/recorder.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/python_apps/pypo/recorder.py b/python_apps/pypo/recorder.py index 1bba9596c..4acff83e7 100644 --- a/python_apps/pypo/recorder.py +++ b/python_apps/pypo/recorder.py @@ -145,12 +145,11 @@ class ShowRecorder(Thread): record_time = md[1].replace(":", "-") self.logger.info("time: %s" % record_time) - show_title = time + "-" + self.show_name artist = "Airtime Show Recorder" #set some metadata for our file daemon recorded_file = mutagen.File(filepath, easy = True) - recorded_file['title'] = show_title + recorded_file['title'] = record_time + "-" + self.show_name recorded_file['artist'] = artist recorded_file['date'] = md[0] #recorded_file['date'] = md[0].split("-")[0] From 98ab38ff54bd58ce6f27c8e5b7708db4c959ebcc Mon Sep 17 00:00:00 2001 From: denise Date: Tue, 28 Aug 2012 11:22:41 -0400 Subject: [PATCH 5/7] CC-4295: Smart Block: Please deal with the float value when criteria likes 'length is' -fixed --- airtime_mvc/application/models/Block.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/airtime_mvc/application/models/Block.php b/airtime_mvc/application/models/Block.php index 005fc18f8..13b7396f9 100644 --- a/airtime_mvc/application/models/Block.php +++ b/airtime_mvc/application/models/Block.php @@ -1187,6 +1187,16 @@ EOT; if (isset($criteria['extra'])) { $spCriteriaExtra = $criteria['extra']*1000; } + /* + * If user is searching for an exact match of length we need to + * search as if it starts with the specified length because the + * user only sees the rounded version (i.e. 4:02.7 is 4:02.761625 + * in the database) + */ + } else if ($spCriteria == 'length' && $spCriteriaModifier == "is") { + $spCriteriaModifier = "starts with"; + $spCriteria = $spCriteria.'::text'; + $spCriteriaValue = $criteria['value']; } else { /* Propel does not escape special characters properly when using LIKE/ILIKE * We have to add extra slashes in these cases @@ -1214,6 +1224,7 @@ EOT; } $spCriteriaModifier = self::$modifier2CriteriaMap[$spCriteriaModifier]; + try { if ($i > 0) { $qry->addOr($spCriteria, $spCriteriaValue, $spCriteriaModifier); From a276e1c2c6b60c1bd7ed351635ac5b0be905b1ce Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 28 Aug 2012 11:54:35 -0400 Subject: [PATCH 6/7] cc-4305: Fixed bug + added test. --- .../media-monitor2/media/monitor/pure.py | 3 ++- python_apps/media-monitor2/tests/test_pure.py | 20 ++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/python_apps/media-monitor2/media/monitor/pure.py b/python_apps/media-monitor2/media/monitor/pure.py index 9e447a47a..97645a15b 100644 --- a/python_apps/media-monitor2/media/monitor/pure.py +++ b/python_apps/media-monitor2/media/monitor/pure.py @@ -290,8 +290,9 @@ def organized_path(old_path, root_path, orig_md): normal_md['MDATA_KEY_BITRATE'] = formatted + 'kbps' else: normal_md['MDATA_KEY_BITRATE'] = unicode_unknown + if is_airtime_recorded(normal_md): - title_re = re.match("(?P\w+)-(?P\d+-\d+-\d+-\d+:\d+:\d+)$", + title_re = re.match("(?P.+)-(?P\d+-\d+-\d+-\d+:\d+:\d+)$", normal_md['MDATA_KEY_TITLE']) show_name = title_re.group('show') date = title_re.group('date').replace(':','-') diff --git a/python_apps/media-monitor2/tests/test_pure.py b/python_apps/media-monitor2/tests/test_pure.py index b4e870023..69a920ecc 100644 --- a/python_apps/media-monitor2/tests/test_pure.py +++ b/python_apps/media-monitor2/tests/test_pure.py @@ -35,7 +35,7 @@ class TestMMP(unittest.TestCase): for k in def_keys: self.assertEqual( sd[k], 'DEF' ) def test_normalized_metadata(self): - # Recorded show test first + #Recorded show test first orig = Metadata.airtime_dict({ 'date' : [u'2012-08-21'], 'tracknumber' : [u'2'], @@ -62,6 +62,24 @@ class TestMMP(unittest.TestCase): organized_path = mmp.organized_path(old_path,base, normalized) self.assertEqual(os.path.basename(organized_path), organized_base_name) + def test_normalized_metadata2(self): + """ + cc-4305 + """ + orig = Metadata.airtime_dict({ + 'date' : [u'2012-08-27'], + 'tracknumber' : [u'3'], + 'title' : [u'18-11-00-Untitled Show'], + 'artist' : [u'Airtime Show Recorder'] + }) + old_path = "/home/rudi/recorded/doesnt_really_matter.ogg" + normalized = mmp.normalized_metadata(orig, old_path) + normalized['MDATA_KEY_BITRATE'] = u'256000' + opath = mmp.organized_path(old_path, "/srv/airtime/stor/", + normalized) + self.assertTrue( len(opath) > 0 ) + + def test_file_md5(self): p = os.path.realpath(__file__) m1 = mmp.file_md5(p) From 69b61c4cfe6be4cc9e9f51f571e7e9e002c6a733 Mon Sep 17 00:00:00 2001 From: denise Date: Tue, 28 Aug 2012 12:13:58 -0400 Subject: [PATCH 7/7] CC-4285: Playlists-> Smart Block - displays that certain amount meets the criteria while no criteria is specified -fixed --- .../controllers/PlaylistController.php | 11 ++-- .../application/forms/SmartBlockCriteria.php | 13 ++++- .../scripts/form/smart-block-criteria.phtml | 55 ++++++++++--------- 3 files changed, 45 insertions(+), 34 deletions(-) diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php index 9e3ea0380..d1dcd1386 100644 --- a/airtime_mvc/application/controllers/PlaylistController.php +++ b/airtime_mvc/application/controllers/PlaylistController.php @@ -64,7 +64,7 @@ class PlaylistController extends Zend_Controller_Action unset($this->view->obj); } - private function createFullResponse($obj = null, $isJson = false) + private function createFullResponse($obj = null, $isJson = false, $formIsValid = false) { $isBlock = false; $viewPath = 'playlist/playlist.phtml'; @@ -80,11 +80,12 @@ class PlaylistController extends Zend_Controller_Action if ($isBlock) { $form = new Application_Form_SmartBlockCriteria(); $form->removeDecorator('DtDdWrapper'); - $form->startForm($obj->getId()); - + $form->startForm($obj->getId(), $formIsValid); + $this->view->form = $form; $this->view->obj = $obj; $this->view->id = $obj->getId(); + if ($isJson) { return $this->view->render($viewPath); } else { @@ -460,7 +461,7 @@ class PlaylistController extends Zend_Controller_Action $bl = new Application_Model_Block($params['obj_id']); if ($form->isValid($params)) { $bl->saveSmartBlockCriteria($params['data']); - $result['html'] = $this->createFullResponse($bl, true); + $result['html'] = $this->createFullResponse($bl, true, true); $result['result'] = 0; } else { $this->view->obj = $bl; @@ -486,7 +487,7 @@ class PlaylistController extends Zend_Controller_Action if ($form->isValid($params)) { $result = $bl->generateSmartBlock($params['data']); try { - die(json_encode(array("result"=>0, "html"=>$this->createFullResponse($bl, true)))); + die(json_encode(array("result"=>0, "html"=>$this->createFullResponse($bl, true, true)))); } catch (PlaylistNotFoundException $e) { $this->playlistNotFound('block'); } catch (Exception $e) { diff --git a/airtime_mvc/application/forms/SmartBlockCriteria.php b/airtime_mvc/application/forms/SmartBlockCriteria.php index 8d2e9683d..bbc751593 100644 --- a/airtime_mvc/application/forms/SmartBlockCriteria.php +++ b/airtime_mvc/application/forms/SmartBlockCriteria.php @@ -88,7 +88,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm } - public function startForm($p_blockId) + public function startForm($p_blockId, $p_isValid = false) { // load type $out = CcBlockQuery::create()->findPk($p_blockId); @@ -236,7 +236,13 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm //getting block content candidate count that meets criteria $bl = new Application_Model_Block($p_blockId); - $files = $bl->getListofFilesMeetCriteria(); + if ($p_isValid) { + $files = $bl->getListofFilesMeetCriteria(); + $showPoolCount = true; + } else { + $files = null; + $showPoolCount = false; + } $generate = new Zend_Form_Element_Button('generate_button'); $generate->setAttrib('class', 'ui-button ui-state-default sp-button'); @@ -256,7 +262,8 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm $this->setDecorators(array( array('ViewScript', array('viewScript' => 'form/smart-block-criteria.phtml', "openOption"=> $openSmartBlockOption, - 'criteriasLength' => count($this->criteriaOptions), 'poolCount' => $files['count'], 'modRowMap' => $modRowMap)) + 'criteriasLength' => count($this->criteriaOptions), 'poolCount' => $files['count'], 'modRowMap' => $modRowMap, + 'showPoolCount' => $showPoolCount)) )); } diff --git a/airtime_mvc/application/views/scripts/form/smart-block-criteria.phtml b/airtime_mvc/application/views/scripts/form/smart-block-criteria.phtml index 8bd96a93e..445832e2f 100644 --- a/airtime_mvc/application/views/scripts/form/smart-block-criteria.phtml +++ b/airtime_mvc/application/views/scripts/form/smart-block-criteria.phtml @@ -66,32 +66,35 @@
-
- - poolCount > 1) { - echo $this->poolCount; - ?> - files meet the criteria - - - poolCount == 1) { - echo $this->poolCount; - ?> - file meets the criteria - - - - 0 files meet the criteria - - - -
+ + showPoolCount) { ?> +
+ + poolCount > 1) { + echo $this->poolCount; + ?> + files meet the criteria + + + poolCount == 1) { + echo $this->poolCount; + ?> + file meets the criteria + + + + 0 files meet the criteria + + + +
+