fix franceinter radio
This commit is contained in:
parent
76c54b7ff8
commit
f3b2cea4ea
6 changed files with 26 additions and 22 deletions
|
|
@ -48,7 +48,10 @@ class RadioListFormatter(IFormatter):
|
|||
result = u'%s* (%s) %s%s\n' % (ReplApplication.BOLD, item['id'], item['title'], ReplApplication.NC)
|
||||
result += ' %-30s' % item['description']
|
||||
if item['current'] is not NotLoaded:
|
||||
result += ' (Current: %s - %s)' % (item['current'].artist, item['current'].title)
|
||||
if item['current'].artist:
|
||||
result += ' (Current: %s - %s)' % (item['current'].artist, item['current'].title)
|
||||
else:
|
||||
result += ' (Current: %s)' % item['current'].title
|
||||
return result
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@
|
|||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from .backend import franceinterBackend
|
||||
from .backend import FranceInterBackend
|
||||
|
||||
|
||||
__all__ = ['franceinterBackend']
|
||||
__all__ = ['FranceInterBackend']
|
||||
|
||||
|
|
|
|||
|
|
@ -20,22 +20,22 @@
|
|||
|
||||
from weboob.capabilities.radio import ICapRadio, Radio, Stream, Emission
|
||||
from weboob.tools.backend import BaseBackend
|
||||
from .browser import franceinterBrowser
|
||||
from .browser import FranceInterBrowser
|
||||
|
||||
|
||||
__all__ = ['franceinterBackend']
|
||||
__all__ = ['FranceInterBackend']
|
||||
|
||||
|
||||
class franceinterBackend(BaseBackend, ICapRadio):
|
||||
class FranceInterBackend(BaseBackend, ICapRadio):
|
||||
NAME = 'franceinter'
|
||||
MAINTAINER = 'Johann Broudin'
|
||||
EMAIL = 'johann.broudin@6-8.fr'
|
||||
VERSION = '1'
|
||||
DESCRIPTION = u'The france inter french radio'
|
||||
LICENCE = 'AGPLv3'
|
||||
BROWSER = franceinterBrowser
|
||||
BROWSER = FranceInterBrowser
|
||||
|
||||
_RADIOS = {'france inter': (u'france inter', u'france inter', u'http://mp3.live.tv-radio.com/franceinter/all/franceinterhautdebit.mp3')}
|
||||
_RADIOS = {'franceinter': (u'france inter', u'france inter', u'http://mp3.live.tv-radio.com/franceinter/all/franceinterhautdebit.mp3')}
|
||||
|
||||
def iter_radios(self):
|
||||
for id in self._RADIOS.iterkeys():
|
||||
|
|
@ -59,7 +59,8 @@ class franceinterBackend(BaseBackend, ICapRadio):
|
|||
|
||||
emission = self.browser.get_current(radio.id)
|
||||
current = Emission(0)
|
||||
current.artist = emission
|
||||
current.title = emission
|
||||
current.artist = None
|
||||
radio.current = current
|
||||
|
||||
stream = Stream(0)
|
||||
|
|
@ -72,7 +73,8 @@ class franceinterBackend(BaseBackend, ICapRadio):
|
|||
if 'current' in fields:
|
||||
if not radio.current:
|
||||
radio.current = Emission(0)
|
||||
radio.current.artist, radio.current.title = self.browser.get_current(radio.id)
|
||||
radio.current.artist = self.browser.get_current(radio.id)
|
||||
radio.current.title = None
|
||||
return radio
|
||||
|
||||
OBJECTS = {Radio: fill_radio}
|
||||
|
|
|
|||
|
|
@ -23,11 +23,12 @@ from weboob.tools.browser import BaseBrowser
|
|||
from .pages import XMLinfos
|
||||
|
||||
|
||||
__all__ = ['franceinterBrowser']
|
||||
__all__ = ['FranceInterBrowser']
|
||||
|
||||
|
||||
class franceinterBrowser(BaseBrowser):
|
||||
class FranceInterBrowser(BaseBrowser):
|
||||
DOMAIN = u'metadatas.tv-radio.com'
|
||||
ENCODING = 'iso-8859-1'
|
||||
PAGES = {r'.*metadatas/franceinterRSS\.xml': XMLinfos}
|
||||
|
||||
def get_current(self, radio):
|
||||
|
|
|
|||
|
|
@ -27,12 +27,7 @@ __all__ = ['XMLinfos']
|
|||
|
||||
class XMLinfos(BasePage):
|
||||
def get_current(self):
|
||||
try:
|
||||
for channel in self.parser.select(self.document.getroot(), 'channel'):
|
||||
emission = channel.find('item/song_title').text
|
||||
#artist = channel.find('item/artist_name').text
|
||||
except AttributeError:
|
||||
emission = "Not defined"
|
||||
# artist = "Not defined"
|
||||
|
||||
return unicode(emission).strip()
|
||||
emissions = self.parser.select(self.document.getroot(), 'item')
|
||||
if len(emissions) == 0:
|
||||
return 'No emission'
|
||||
return emissions[0].find('titreemission').text
|
||||
|
|
|
|||
|
|
@ -35,7 +35,10 @@ class Emission(CapBaseObject):
|
|||
return False
|
||||
|
||||
def __unicode__(self):
|
||||
return u'%s - %s' % (self.artist, self.title)
|
||||
if self.artist:
|
||||
return u'%s - %s' % (self.artist, self.title)
|
||||
else:
|
||||
return self.title
|
||||
|
||||
class Stream(CapBaseObject):
|
||||
def __init__(self, id):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue