rename AudioStreamInfo into StreamInfo
Allowing future use with upcoming VideoStream Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
parent
d34f8f2e40
commit
e7805cec12
10 changed files with 72 additions and 40 deletions
|
|
@ -19,7 +19,8 @@
|
||||||
|
|
||||||
|
|
||||||
from weboob.capabilities.radio import ICapRadio, Radio
|
from weboob.capabilities.radio import ICapRadio, Radio
|
||||||
from weboob.capabilities.audiostream import BaseAudioStream, AudioStreamInfo
|
from weboob.capabilities.audiostream import BaseAudioStream
|
||||||
|
from weboob.tools.capabilities.streaminfo import StreamInfo
|
||||||
from weboob.capabilities.collection import ICapCollection, Collection
|
from weboob.capabilities.collection import ICapCollection, Collection
|
||||||
from weboob.tools.backend import BaseBackend, BackendConfig
|
from weboob.tools.backend import BaseBackend, BackendConfig
|
||||||
from weboob.tools.value import Value
|
from weboob.tools.value import Value
|
||||||
|
|
@ -236,7 +237,7 @@ class AudioAddictBackend(BaseBackend, ICapRadio, ICapCollection):
|
||||||
radio.description = radio_dict['description']
|
radio.description = radio_dict['description']
|
||||||
|
|
||||||
artist, title = self.get_current(network, radioName)
|
artist, title = self.get_current(network, radioName)
|
||||||
current = AudioStreamInfo(0)
|
current = StreamInfo(0)
|
||||||
current.who = artist
|
current.who = artist
|
||||||
current.what = title
|
current.what = title
|
||||||
radio.current = current
|
radio.current = current
|
||||||
|
|
@ -268,7 +269,7 @@ class AudioAddictBackend(BaseBackend, ICapRadio, ICapCollection):
|
||||||
def fill_radio(self, radio, fields):
|
def fill_radio(self, radio, fields):
|
||||||
if 'current' in fields:
|
if 'current' in fields:
|
||||||
radioName, network = radio.id.split('.', 1)
|
radioName, network = radio.id.split('.', 1)
|
||||||
radio.current = AudioStreamInfo(0)
|
radio.current = StreamInfo(0)
|
||||||
radio.current.who, radio.current.what = self.get_current(network, radioName)
|
radio.current.who, radio.current.what = self.get_current(network, radioName)
|
||||||
return radio
|
return radio
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,8 @@
|
||||||
|
|
||||||
from weboob.tools.browser import BasePage
|
from weboob.tools.browser import BasePage
|
||||||
from weboob.capabilities.radio import Radio
|
from weboob.capabilities.radio import Radio
|
||||||
from weboob.capabilities.audiostream import BaseAudioStream, AudioStreamInfo
|
from weboob.capabilities.audiostream import BaseAudioStream
|
||||||
|
from weboob.tools.capabilities.streaminfo import StreamInfo
|
||||||
|
|
||||||
__all__ = ['LivePage', 'StreamsPage']
|
__all__ = ['LivePage', 'StreamsPage']
|
||||||
|
|
||||||
|
|
@ -51,7 +52,7 @@ class StreamsPage(BasePage):
|
||||||
|
|
||||||
class LivePage(BasePage):
|
class LivePage(BasePage):
|
||||||
def get_current_emission(self):
|
def get_current_emission(self):
|
||||||
current = AudioStreamInfo(0)
|
current = StreamInfo(0)
|
||||||
current.who = unicode(self.document.xpath('//playlist/now/entry/artist')[0].text)
|
current.who = unicode(self.document.xpath('//playlist/now/entry/artist')[0].text)
|
||||||
current.what = unicode(self.document.xpath('//playlist/now/entry/song')[0].text)
|
current.what = unicode(self.document.xpath('//playlist/now/entry/song')[0].text)
|
||||||
return current
|
return current
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,8 @@
|
||||||
|
|
||||||
from weboob.tools.browser import BasePage
|
from weboob.tools.browser import BasePage
|
||||||
from weboob.capabilities.radio import Radio
|
from weboob.capabilities.radio import Radio
|
||||||
from weboob.capabilities.audiostream import BaseAudioStream, AudioStreamInfo
|
from weboob.capabilities.audiostream import BaseAudioStream
|
||||||
|
from weboob.tools.capabilities.streaminfo import StreamInfo
|
||||||
|
|
||||||
__all__ = ['LivePage', 'ProgramPage']
|
__all__ = ['LivePage', 'ProgramPage']
|
||||||
|
|
||||||
|
|
@ -52,7 +53,7 @@ class LivePage(BasePage):
|
||||||
|
|
||||||
class ProgramPage(BasePage):
|
class ProgramPage(BasePage):
|
||||||
def get_current_emission(self):
|
def get_current_emission(self):
|
||||||
current = AudioStreamInfo(0)
|
current = StreamInfo(0)
|
||||||
two_or_more = unicode(self.document.xpath('//p')[0].text).split('/////')[0].split(' - ')
|
two_or_more = unicode(self.document.xpath('//p')[0].text).split('/////')[0].split(' - ')
|
||||||
# Consider that if String(' - ') appears it'll be in title rather in the artist name
|
# Consider that if String(' - ') appears it'll be in title rather in the artist name
|
||||||
if len(two_or_more) > 2:
|
if len(two_or_more) > 2:
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,8 @@
|
||||||
from cStringIO import StringIO
|
from cStringIO import StringIO
|
||||||
|
|
||||||
from weboob.capabilities.radio import ICapRadio, Radio
|
from weboob.capabilities.radio import ICapRadio, Radio
|
||||||
from weboob.capabilities.audiostream import BaseAudioStream, AudioStreamInfo
|
from weboob.capabilities.audiostream import BaseAudioStream
|
||||||
|
from weboob.tools.capabilities.streaminfo import StreamInfo
|
||||||
from weboob.capabilities.collection import ICapCollection
|
from weboob.capabilities.collection import ICapCollection
|
||||||
from weboob.tools.backend import BaseBackend
|
from weboob.tools.backend import BaseBackend
|
||||||
from weboob.tools.browser import StandardBrowser
|
from weboob.tools.browser import StandardBrowser
|
||||||
|
|
@ -70,7 +71,7 @@ class NovaBackend(BaseBackend, ICapRadio, ICapCollection):
|
||||||
radio.description = description
|
radio.description = description
|
||||||
|
|
||||||
artist, title = self.get_current()
|
artist, title = self.get_current()
|
||||||
current = AudioStreamInfo(0)
|
current = StreamInfo(0)
|
||||||
current.who = artist
|
current.who = artist
|
||||||
current.what = title
|
current.what = title
|
||||||
radio.current = current
|
radio.current = current
|
||||||
|
|
@ -95,7 +96,7 @@ class NovaBackend(BaseBackend, ICapRadio, ICapCollection):
|
||||||
def fill_radio(self, radio, fields):
|
def fill_radio(self, radio, fields):
|
||||||
if 'current' in fields:
|
if 'current' in fields:
|
||||||
if not radio.current:
|
if not radio.current:
|
||||||
radio.current = AudioStreamInfo(0)
|
radio.current = StreamInfo(0)
|
||||||
radio.current.who, radio.current.what = self.get_current()
|
radio.current.who, radio.current.what = self.get_current()
|
||||||
return radio
|
return radio
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,8 @@
|
||||||
|
|
||||||
|
|
||||||
from weboob.capabilities.radio import ICapRadio, Radio
|
from weboob.capabilities.radio import ICapRadio, Radio
|
||||||
from weboob.capabilities.audiostream import BaseAudioStream, AudioStreamInfo
|
from weboob.capabilities.audiostream import BaseAudioStream
|
||||||
|
from weboob.tools.capabilities.streaminfo import StreamInfo
|
||||||
from weboob.capabilities.collection import ICapCollection
|
from weboob.capabilities.collection import ICapCollection
|
||||||
from weboob.tools.backend import BaseBackend
|
from weboob.tools.backend import BaseBackend
|
||||||
from weboob.tools.browser import StandardBrowser
|
from weboob.tools.browser import StandardBrowser
|
||||||
|
|
@ -86,7 +87,7 @@ class OuiFMBackend(BaseBackend, ICapRadio, ICapCollection):
|
||||||
radio.description = description
|
radio.description = description
|
||||||
|
|
||||||
artist, title = self.get_current(radio.id)
|
artist, title = self.get_current(radio.id)
|
||||||
current = AudioStreamInfo(0)
|
current = StreamInfo(0)
|
||||||
current.who = artist
|
current.who = artist
|
||||||
current.what = title
|
current.what = title
|
||||||
radio.current = current
|
radio.current = current
|
||||||
|
|
@ -102,7 +103,7 @@ class OuiFMBackend(BaseBackend, ICapRadio, ICapCollection):
|
||||||
def fill_radio(self, radio, fields):
|
def fill_radio(self, radio, fields):
|
||||||
if 'current' in fields:
|
if 'current' in fields:
|
||||||
if not radio.current:
|
if not radio.current:
|
||||||
radio.current = AudioStreamInfo(0)
|
radio.current = StreamInfo(0)
|
||||||
radio.current.who, radio.current.what = self.get_current(radio.id)
|
radio.current.who, radio.current.what = self.get_current(radio.id)
|
||||||
return radio
|
return radio
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,8 @@
|
||||||
from weboob.capabilities.base import NotLoaded
|
from weboob.capabilities.base import NotLoaded
|
||||||
from weboob.capabilities.video import ICapVideo
|
from weboob.capabilities.video import ICapVideo
|
||||||
from weboob.capabilities.radio import ICapRadio, Radio
|
from weboob.capabilities.radio import ICapRadio, Radio
|
||||||
from weboob.capabilities.audiostream import BaseAudioStream, AudioStreamInfo
|
from weboob.capabilities.audiostream import BaseAudioStream
|
||||||
|
from weboob.tools.capabilities.streaminfo import StreamInfo
|
||||||
from weboob.capabilities.collection import ICapCollection, CollectionNotFound, Collection
|
from weboob.capabilities.collection import ICapCollection, CollectionNotFound, Collection
|
||||||
from weboob.tools.backend import BaseBackend
|
from weboob.tools.backend import BaseBackend
|
||||||
|
|
||||||
|
|
@ -180,7 +181,7 @@ class RadioFranceBackend(BaseBackend, ICapRadio, ICapCollection, ICapVideo):
|
||||||
title = self.browser.get_current_rss(radio.id)
|
title = self.browser.get_current_rss(radio.id)
|
||||||
if title:
|
if title:
|
||||||
if not radio.current or radio.current is NotLoaded:
|
if not radio.current or radio.current is NotLoaded:
|
||||||
radio.current = AudioStreamInfo(0)
|
radio.current = StreamInfo(0)
|
||||||
radio.current.what = title
|
radio.current.what = title
|
||||||
radio.current.who = artist
|
radio.current.who = artist
|
||||||
return radio
|
return radio
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,8 @@
|
||||||
|
|
||||||
import lxml.etree
|
import lxml.etree
|
||||||
from weboob.capabilities.radio import ICapRadio, Radio
|
from weboob.capabilities.radio import ICapRadio, Radio
|
||||||
from weboob.capabilities.audiostream import BaseAudioStream, AudioStreamInfo
|
from weboob.capabilities.audiostream import BaseAudioStream
|
||||||
|
from weboob.tools.capabilities.streaminfo import StreamInfo
|
||||||
from weboob.capabilities.collection import ICapCollection
|
from weboob.capabilities.collection import ICapCollection
|
||||||
from weboob.tools.backend import BaseBackend
|
from weboob.tools.backend import BaseBackend
|
||||||
from weboob.tools.browser import StandardBrowser
|
from weboob.tools.browser import StandardBrowser
|
||||||
|
|
@ -69,7 +70,7 @@ class SomaFMBackend(BaseBackend, ICapRadio, ICapCollection):
|
||||||
radio.description = channel.findtext('description')
|
radio.description = channel.findtext('description')
|
||||||
|
|
||||||
current_data = channel.findtext('lastPlaying')
|
current_data = channel.findtext('lastPlaying')
|
||||||
current = AudioStreamInfo(0)
|
current = StreamInfo(0)
|
||||||
current.what, current.who = self._parse_current(current_data)
|
current.what, current.who = self._parse_current(current_data)
|
||||||
radio.current = current
|
radio.current = current
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,37 +18,20 @@
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
from .base import CapBaseObject, Field, StringField
|
from weboob.tools.capabilities.streaminfo import StreamInfo
|
||||||
|
from .base import CapBaseObject, Field
|
||||||
from .file import ICapFile
|
from .file import ICapFile
|
||||||
from .audio import ICapAudio, BaseAudio
|
from .audio import ICapAudio, BaseAudio
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['AudioStreamInfo', 'BaseAudioStream', 'ICapAudioStream']
|
__all__ = ['BaseAudioStream', 'ICapAudioStream']
|
||||||
|
|
||||||
|
|
||||||
class AudioStreamInfo(CapBaseObject):
|
|
||||||
"""
|
|
||||||
AudioStream related information.
|
|
||||||
"""
|
|
||||||
who = StringField('Who is currently on air')
|
|
||||||
what = StringField('What is currently on air')
|
|
||||||
|
|
||||||
def __iscomplete__(self):
|
|
||||||
# This volatile information may be reloaded everytimes.
|
|
||||||
return False
|
|
||||||
|
|
||||||
def __unicode__(self):
|
|
||||||
if self.who:
|
|
||||||
return u'%s - %s' % (self.who, self.what)
|
|
||||||
else:
|
|
||||||
return self.what
|
|
||||||
|
|
||||||
|
|
||||||
class BaseAudioStream(BaseAudio):
|
class BaseAudioStream(BaseAudio):
|
||||||
"""
|
"""
|
||||||
Audio stream object
|
Audio stream object
|
||||||
"""
|
"""
|
||||||
current = Field('Information related to current broadcast', AudioStreamInfo)
|
current = Field('Information related to current broadcast', StreamInfo)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return u'%s (%s)' % (self.title, self.url)
|
return u'%s (%s)' % (self.title, self.url)
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
|
|
||||||
from .base import IBaseCap, CapBaseObject, Field, StringField
|
from .base import IBaseCap, CapBaseObject, Field, StringField
|
||||||
from .audiostream import AudioStreamInfo
|
from weboob.tools.capabilities.streaminfo import StreamInfo
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['Radio', 'ICapRadio']
|
__all__ = ['Radio', 'ICapRadio']
|
||||||
|
|
@ -32,7 +32,7 @@ class Radio(CapBaseObject):
|
||||||
"""
|
"""
|
||||||
title = StringField('Title of radio')
|
title = StringField('Title of radio')
|
||||||
description = StringField('Description of radio')
|
description = StringField('Description of radio')
|
||||||
current = Field('Current emission', AudioStreamInfo)
|
current = Field('Current emission', StreamInfo)
|
||||||
streams = Field('List of streams', list)
|
streams = Field('List of streams', list)
|
||||||
|
|
||||||
class ICapRadio(IBaseCap):
|
class ICapRadio(IBaseCap):
|
||||||
|
|
|
||||||
42
weboob/tools/capabilities/streaminfo.py
Normal file
42
weboob/tools/capabilities/streaminfo.py
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright(C) 2013 Pierre Mazière
|
||||||
|
#
|
||||||
|
# This file is part of weboob.
|
||||||
|
#
|
||||||
|
# weboob is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# weboob is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
from weboob.capabilities.base import CapBaseObject, StringField
|
||||||
|
|
||||||
|
__all__ = ['StreamInfo']
|
||||||
|
|
||||||
|
|
||||||
|
class StreamInfo(CapBaseObject):
|
||||||
|
"""
|
||||||
|
Stream related information.
|
||||||
|
"""
|
||||||
|
who = StringField('Who is currently on air')
|
||||||
|
what = StringField('What is currently on air')
|
||||||
|
|
||||||
|
def __iscomplete__(self):
|
||||||
|
# This volatile information may be reloaded everytimes.
|
||||||
|
return False
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
if self.who:
|
||||||
|
return u'%s - %s' % (self.who, self.what)
|
||||||
|
else:
|
||||||
|
return self.what
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue