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