Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
2d21250eed
|
@ -290,10 +290,11 @@ def organized_path(old_path, root_path, orig_md):
|
||||||
normal_md['MDATA_KEY_BITRATE'] = formatted + 'kbps'
|
normal_md['MDATA_KEY_BITRATE'] = formatted + 'kbps'
|
||||||
else: normal_md['MDATA_KEY_BITRATE'] = unicode_unknown
|
else: normal_md['MDATA_KEY_BITRATE'] = unicode_unknown
|
||||||
|
|
||||||
|
|
||||||
if is_airtime_recorded(normal_md):
|
if is_airtime_recorded(normal_md):
|
||||||
title_re = re.match("(?P<show>\w+)-(?P<date>\d+-\d+-\d+-\d+:\d+:\d+)$",
|
title_re = re.match("(?P<show>.+)-(?P<date>\d+-\d+-\d+-\d+:\d+:\d+)$",
|
||||||
normal_md['MDATA_KEY_TITLE'])
|
normal_md['MDATA_KEY_TITLE'])
|
||||||
show_name, = title_re.group('show'),
|
show_name = title_re.group('show')
|
||||||
date = title_re.group('date').replace(':','-')
|
date = title_re.group('date').replace(':','-')
|
||||||
yyyy, mm, _ = normal_md['MDATA_KEY_YEAR'].split('-',2)
|
yyyy, mm, _ = normal_md['MDATA_KEY_YEAR'].split('-',2)
|
||||||
fname_base = '%s-%s-%s.%s' % \
|
fname_base = '%s-%s-%s.%s' % \
|
||||||
|
|
|
@ -35,7 +35,7 @@ class TestMMP(unittest.TestCase):
|
||||||
for k in def_keys: self.assertEqual( sd[k], 'DEF' )
|
for k in def_keys: self.assertEqual( sd[k], 'DEF' )
|
||||||
|
|
||||||
def test_normalized_metadata(self):
|
def test_normalized_metadata(self):
|
||||||
# Recorded show test first
|
#Recorded show test first
|
||||||
orig = Metadata.airtime_dict({
|
orig = Metadata.airtime_dict({
|
||||||
'date' : [u'2012-08-21'],
|
'date' : [u'2012-08-21'],
|
||||||
'tracknumber' : [u'2'],
|
'tracknumber' : [u'2'],
|
||||||
|
@ -62,6 +62,24 @@ class TestMMP(unittest.TestCase):
|
||||||
organized_path = mmp.organized_path(old_path,base, normalized)
|
organized_path = mmp.organized_path(old_path,base, normalized)
|
||||||
self.assertEqual(os.path.basename(organized_path), organized_base_name)
|
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):
|
def test_file_md5(self):
|
||||||
p = os.path.realpath(__file__)
|
p = os.path.realpath(__file__)
|
||||||
m1 = mmp.file_md5(p)
|
m1 = mmp.file_md5(p)
|
||||||
|
|
|
@ -134,21 +134,22 @@ class ShowRecorder(Thread):
|
||||||
self.api_client.upload_recorded_show(datagen, headers)
|
self.api_client.upload_recorded_show(datagen, headers)
|
||||||
|
|
||||||
def set_metadata_and_save(self, filepath):
|
def set_metadata_and_save(self, filepath):
|
||||||
|
"""
|
||||||
|
Writes song to 'filepath'. Uses metadata from:
|
||||||
|
self.start_time, self.show_name, self.show_instance
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
date = self.start_time
|
date = self.start_time
|
||||||
md = date.split(" ")
|
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)
|
||||||
|
|
||||||
artist = "Airtime Show Recorder"
|
artist = "Airtime Show Recorder"
|
||||||
|
|
||||||
#set some metadata for our file daemon
|
#set some metadata for our file daemon
|
||||||
recorded_file = mutagen.File(filepath, easy = True)
|
recorded_file = mutagen.File(filepath, easy = True)
|
||||||
recorded_file['title'] = name
|
recorded_file['title'] = record_time + "-" + self.show_name
|
||||||
recorded_file['artist'] = artist
|
recorded_file['artist'] = artist
|
||||||
recorded_file['date'] = md[0]
|
recorded_file['date'] = md[0]
|
||||||
#recorded_file['date'] = md[0].split("-")[0]
|
#recorded_file['date'] = md[0].split("-")[0]
|
||||||
|
|
Loading…
Reference in New Issue