publish m3u
This commit is contained in:
parent
665bed735c
commit
1c95903ca9
|
@ -1,5 +1,7 @@
|
|||
import os
|
||||
|
||||
from five import grok
|
||||
from zope import schema
|
||||
from zope import schema, component
|
||||
from zope.interface import implements
|
||||
from z3c.relationfield.schema import RelationChoice
|
||||
from Products.CMFCore.utils import getToolByName
|
||||
|
@ -11,6 +13,8 @@ from themis.fields import LegisSession
|
|||
from plone.app.textfield import RichText
|
||||
|
||||
from themis.datatypes.commission import ICommission
|
||||
from plone.registry.interfaces import IRegistry
|
||||
from tabellio.config.interfaces import ITabellioSettings
|
||||
|
||||
from tabellio.agenda.interfaces import MessageFactory as _
|
||||
from event import IBaseEvent, BaseEvent, EventBaseView
|
||||
|
@ -42,11 +46,28 @@ class ParlEventBaseView(EventBaseView):
|
|||
portal_type=('tabellio.agenda.parlevent',
|
||||
'tabellio.agenda.comevent'))
|
||||
|
||||
def get_stream_name(self):
|
||||
filename = '%04d%02d%02d%02d-SEAN.mp3' % (
|
||||
self.context.start.year, self.context.start.month,
|
||||
self.context.start.day, self.context.start.hour)
|
||||
return filename
|
||||
|
||||
def has_stream(self):
|
||||
# XXX
|
||||
return False
|
||||
settings = component.getUtility(IRegistry).forInterface(ITabellioSettings, False)
|
||||
if not settings.audiofiles_path:
|
||||
return False
|
||||
return os.path.exists(os.path.join(settings.audiofiles_path, self.get_stream_name()))
|
||||
|
||||
class View(grok.View, ParlEventBaseView):
|
||||
grok.context(IParlEvent)
|
||||
grok.require('zope2.View')
|
||||
|
||||
class M3U(grok.View, ParlEventBaseView):
|
||||
grok.context(IParlEvent)
|
||||
grok.require('zope2.View')
|
||||
grok.name('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()
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
<li><a href="#" class="cri" tal:condition="python: context.cri and context.cri.to_object"
|
||||
tal:attributes="href context/cri/to_object/absolute_url">Compte-rendu intégral</a>
|
||||
<span class="cri" tal:condition="python: not(context.cri and context.cri.to_object)">Compte-rendu intégral (non disponible)</span></li>
|
||||
<li><a href="#" class="streaming" tal:condition="view/has_stream">Streaming</a>
|
||||
<li><a tal:attributes="href string:${context/absolute_url}/m3u" class="streaming" tal:condition="view/has_stream">Streaming</a>
|
||||
<span class="streaming" tal:condition="not: view/has_stream">Streaming (non disponible)</span></li>
|
||||
</ul>
|
||||
|
||||
|
|
Reference in New Issue