diff --git a/tabellio/pcfviews/comevent.py b/tabellio/pcfviews/comevent.py index 21aab2a..0e400dd 100644 --- a/tabellio/pcfviews/comevent.py +++ b/tabellio/pcfviews/comevent.py @@ -1,8 +1,29 @@ from five import grok +from Products.CMFCore.utils import getToolByName from parlevent import ParlEventBaseView from tabellio.agenda.comevent import IComEvent +import tabellio.config.utils -class View(grok.View, ParlEventBaseView): +class CommissionView(ParlEventBaseView): + def get_stream_name(self): + com_id = self.context.commission.to_path.split('/')[-1] + com_audio_code = tabellio.config.utils.get_com_audio_code(com_id) + filename = '%04d%02d%02d%02d-%s.mp3' % ( + self.context.start.year, self.context.start.month, + self.context.start.day, self.context.start.hour, + com_audio_code) + return filename + +class View(grok.View, CommissionView): grok.context(IComEvent) grok.require('zope2.View') +class M3U(grok.View, CommissionView): + grok.context(tabellio.agenda.parlevent.IParlEvent) + grok.require('zope2.View') + grok.name('ecouter.m3u') + + def render(self): + portal_url = getToolByName(self.context, 'portal_url').getPortalObject().absolute_url() + self.request.response.setHeader('Content-type', 'audio/x-mpegurl') + return portal_url + '/mp3/' + self.get_stream_name() + '\n' diff --git a/tabellio/pcfviews/comevent_templates/view.pt b/tabellio/pcfviews/comevent_templates/view.pt index 2d39a0e..4e0313d 100644 --- a/tabellio/pcfviews/comevent_templates/view.pt +++ b/tabellio/pcfviews/comevent_templates/view.pt @@ -41,7 +41,7 @@