From a276e1c2c6b60c1bd7ed351635ac5b0be905b1ce Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 28 Aug 2012 11:54:35 -0400 Subject: [PATCH] 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)