cc-4241: Tweaked metadata handling again

This commit is contained in:
Rudi Grinberg 2012-09-05 10:59:56 -04:00
parent d12833a71e
commit f4848a8306
2 changed files with 12 additions and 17 deletions

View File

@ -300,6 +300,8 @@ def organized_path(old_path, root_path, orig_md):
# MDATA_KEY_BITRATE is in bytes/second i.e. (256000) we want to turn this # MDATA_KEY_BITRATE is in bytes/second i.e. (256000) we want to turn this
# into 254kbps # into 254kbps
# Some metadata elements cannot be empty, hence we default them to some
# value just so that we can create a correct path
normal_md = default_to_f(orig_md, path_md, unicode_unknown, default_f) normal_md = default_to_f(orig_md, path_md, unicode_unknown, default_f)
try: try:
formatted = str(int(normal_md['MDATA_KEY_BITRATE']) / 1000) formatted = str(int(normal_md['MDATA_KEY_BITRATE']) / 1000)
@ -308,10 +310,11 @@ def organized_path(old_path, root_path, orig_md):
normal_md['MDATA_KEY_BITRATE'] = unicode_unknown 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>.+)-(?P<date>\d+-\d+-\d+-\d+:\d+:\d+)$", # normal_md['MDATA_KEY_TITLE'] = 'show_name-yyyy-mm-dd-hh:mm:ss'
normal_md['MDATA_KEY_TITLE']) r = "(?P<show>.+)-(?P<date>\d+-\d+-\d+)-(?P<time>\d+:\d+:\d+)$"
title_re = re.match(r, 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')
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' % \
(date, show_name, normal_md['MDATA_KEY_BITRATE'], ext) (date, show_name, normal_md['MDATA_KEY_BITRATE'], ext)

View File

@ -141,27 +141,19 @@ class ShowRecorder(Thread):
self.start_time, self.show_name, self.show_instance self.start_time, self.show_name, self.show_instance
""" """
try: try:
date = self.start_time full_date, full_time = self.start_time.split(" ",1)
md = date.split(" ") # No idea why we translated - to : before
#full_time = full_time.replace(":","-")
record_time = md[1].replace(":", "-") self.logger.info("time: %s" % full_time)
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'] = record_time + "-" + self.show_name
recorded_file['artist'] = artist recorded_file['artist'] = artist
recorded_file['date'] = md[0] recorded_file['date'] = full_date
recorded_file['title'] = "%s-%s-%s" % (self.show_name, recorded_file['title'] = "%s-%s-%s" % (self.show_name,
recorded_file['date'], md[1]) full_date, full_time)
#recorded_file['date'] = md[0].split("-")[0]
#You cannot pass ints into the metadata of a file. Even tracknumber needs to be a string #You cannot pass ints into the metadata of a file. Even tracknumber needs to be a string
recorded_file['tracknumber'] = unicode(self.show_instance) recorded_file['tracknumber'] = unicode(self.show_instance)
self.logger.info("self.start_time: %s" % self.start_time)
self.logger.info("title:(%s).date:(%s)" % (recorded_file['title'],
recorded_file['date']) )
recorded_file.save() recorded_file.save()
except Exception, e: except Exception, e: