rclaudio needs to output text/plain, because setfield only works with text/plain for now
This commit is contained in:
parent
fe7d5febf4
commit
f978ec46e6
@ -19,7 +19,7 @@ except:
|
|||||||
sys.exit(1);
|
sys.exit(1);
|
||||||
|
|
||||||
|
|
||||||
re_pairnum = re.compile(b'''\(([0-9]+),\s*([0-9]+)\)''')
|
re_pairnum = re.compile(b'''[[(]*([0-9]+),\s*([0-9]+)''')
|
||||||
|
|
||||||
# The 'Easy' mutagen tags conversions are incomplete. We do it ourselves.
|
# The 'Easy' mutagen tags conversions are incomplete. We do it ourselves.
|
||||||
# TPA,TPOS,disc DISCNUMBER/TOTALDISCS
|
# TPA,TPOS,disc DISCNUMBER/TOTALDISCS
|
||||||
@ -230,12 +230,15 @@ class AudioTagExtractor(RclBaseHandler):
|
|||||||
val = time.mktime(pdt.timetuple())
|
val = time.mktime(pdt.timetuple())
|
||||||
return "%d" % val
|
return "%d" % val
|
||||||
|
|
||||||
def html_text(self, filename):
|
|
||||||
|
|
||||||
|
def html_text(self, filename):
|
||||||
if not self.inputmimetype:
|
if not self.inputmimetype:
|
||||||
raise Exception("html_text: input MIME type not set")
|
raise Exception("html_text: input MIME type not set")
|
||||||
mimetype = self.inputmimetype
|
mimetype = self.inputmimetype
|
||||||
|
|
||||||
|
# We actually output text/plain
|
||||||
|
self.outputmimetype = 'text/plain'
|
||||||
|
|
||||||
mutf = File(filename)
|
mutf = File(filename)
|
||||||
if not mutf:
|
if not mutf:
|
||||||
raise Exception("mutagen failed opening %s" % filename)
|
raise Exception("mutagen failed opening %s" % filename)
|
||||||
@ -324,6 +327,7 @@ class AudioTagExtractor(RclBaseHandler):
|
|||||||
#self.em.rclog("minf[%s] = %s" % (k, minf[k]))
|
#self.em.rclog("minf[%s] = %s" % (k, minf[k]))
|
||||||
if l[1] != 0:
|
if l[1] != 0:
|
||||||
minf['total' + what + 's'] = l[1]
|
minf['total' + what + 's'] = l[1]
|
||||||
|
#self.em.rclog("%s finally: %s" %(k,minf[k]))
|
||||||
|
|
||||||
if 'orchestra' in minf:
|
if 'orchestra' in minf:
|
||||||
val = minf['orchestra']
|
val = minf['orchestra']
|
||||||
@ -338,7 +342,6 @@ class AudioTagExtractor(RclBaseHandler):
|
|||||||
#self.em.rclog("Embedded image format: %s" % embdimg)
|
#self.em.rclog("Embedded image format: %s" % embdimg)
|
||||||
minf['embdimg'] = tobytes(embdimg)
|
minf['embdimg'] = tobytes(embdimg)
|
||||||
|
|
||||||
self.em.setmimetype("text/plain")
|
|
||||||
self.em.setfield("charset", 'utf-8')
|
self.em.setfield("charset", 'utf-8')
|
||||||
|
|
||||||
for tag,val in minf.items():
|
for tag,val in minf.items():
|
||||||
|
|||||||
@ -49,7 +49,10 @@ class RclBaseHandler(object):
|
|||||||
else:
|
else:
|
||||||
self.inputmimetype = None
|
self.inputmimetype = None
|
||||||
|
|
||||||
|
self.outputmimetype = 'text/html'
|
||||||
try:
|
try:
|
||||||
|
# Note: "html_text" can change self.outputmimetype and
|
||||||
|
# output text/plain
|
||||||
html = self.html_text(fn)
|
html = self.html_text(fn)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
import traceback
|
import traceback
|
||||||
@ -57,7 +60,7 @@ class RclBaseHandler(object):
|
|||||||
self.em.rclog("RclBaseHandler: %s : %s" % (fn, err))
|
self.em.rclog("RclBaseHandler: %s : %s" % (fn, err))
|
||||||
return (False, "", "", rclexecm.RclExecM.eofnow)
|
return (False, "", "", rclexecm.RclExecM.eofnow)
|
||||||
|
|
||||||
self.em.setmimetype('text/html')
|
self.em.setmimetype(self.outputmimetype)
|
||||||
return (True, html, "", rclexecm.RclExecM.eofnext)
|
return (True, html, "", rclexecm.RclExecM.eofnext)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user