[radiofrance] fix #1449
This commit is contained in:
parent
8688921e96
commit
0d588e56dd
2 changed files with 16 additions and 30 deletions
|
|
@ -98,10 +98,9 @@ class RadioFranceBackend(BaseBackend, CapRadio, CapCollection, CapVideo):
|
|||
'franceculture',
|
||||
'franceinfo',
|
||||
'lemouv',
|
||||
'fip',
|
||||
)
|
||||
|
||||
_DIRECTJSON_RADIOS = ('lemouv', 'franceinter', )
|
||||
_DIRECTJSON_RADIOS = ('lemouv', )
|
||||
_LARGEDIRECTJSON_RADIOS = ('fip', )
|
||||
_RSS_RADIOS = ('francemusique', )
|
||||
|
||||
|
|
@ -128,7 +127,7 @@ class RadioFranceBackend(BaseBackend, CapRadio, CapCollection, CapVideo):
|
|||
if not isinstance(radio, Radio):
|
||||
radio = Radio(radio)
|
||||
|
||||
if not radio.id in self._RADIOS:
|
||||
if radio.id not in self._RADIOS:
|
||||
return None
|
||||
|
||||
title, hd = self._RADIOS[radio.id]
|
||||
|
|
@ -146,10 +145,10 @@ class RadioFranceBackend(BaseBackend, CapRadio, CapCollection, CapVideo):
|
|||
|
||||
stream = BaseAudioStream(0)
|
||||
if hd:
|
||||
stream.bitrate=128
|
||||
stream.bitrate = 128
|
||||
else:
|
||||
stream.bitrate=32
|
||||
stream.format=u'mp3'
|
||||
stream.bitrate = 32
|
||||
stream.format = u'mp3'
|
||||
stream.title = u'%s kbits/s' % (stream.bitrate)
|
||||
stream.url = url
|
||||
radio.streams = [stream]
|
||||
|
|
@ -205,4 +204,4 @@ class RadioFranceBackend(BaseBackend, CapRadio, CapCollection, CapVideo):
|
|||
return video
|
||||
|
||||
OBJECTS = {Radio: fill_radio,
|
||||
RadioFranceVideo: fill_video}
|
||||
RadioFranceVideo: fill_video}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ from weboob.tools.json import json
|
|||
from weboob.capabilities.video import BaseVideo
|
||||
from weboob.tools.browser.decorators import id2url
|
||||
|
||||
from StringIO import StringIO
|
||||
from time import time
|
||||
import re
|
||||
from urlparse import parse_qs
|
||||
|
|
@ -92,7 +91,7 @@ class ReplayPage(BasePage):
|
|||
class DataPage(BasePage):
|
||||
def get_current(self):
|
||||
document = self.document
|
||||
title = None
|
||||
title = ''
|
||||
for metas in self.parser.select(document.getroot(), 'div.metas'):
|
||||
ftitle = unicode(metas.text_content()).strip()
|
||||
if ftitle:
|
||||
|
|
@ -104,7 +103,7 @@ class DataPage(BasePage):
|
|||
ftitle = document.findtext('//div[@class="subtitle"]')
|
||||
title = unicode(ftitle).strip() if ftitle else title
|
||||
else:
|
||||
artist = None
|
||||
artist = ''
|
||||
|
||||
return (artist, title)
|
||||
|
||||
|
|
@ -125,7 +124,7 @@ class RssPage(BasePage):
|
|||
class RadioFranceBrowser(BaseBrowser):
|
||||
DOMAIN = None
|
||||
ENCODING = 'UTF-8'
|
||||
PAGES = {r'/playerjs/direct/donneesassociees/html\?guid=$': DataPage,
|
||||
PAGES = {r'http://.*/player/direct': DataPage,
|
||||
r'http://players.tv-radio.com/radiofrance/metadatas/([a-z]+)RSS.html': RssPage,
|
||||
PlayerPage.URL: PlayerPage,
|
||||
ReplayPage.URL: ReplayPage,
|
||||
|
|
@ -141,7 +140,7 @@ class RadioFranceBrowser(BaseBrowser):
|
|||
return 'www.%s.fr' % _id
|
||||
|
||||
def get_current_playerjs(self, _id):
|
||||
self.location('http://%s/playerjs/direct/donneesassociees/html?guid=' % self.id2domain(_id))
|
||||
self.location('http://%s/player/direct' % self.id2domain(_id))
|
||||
assert self.is_on_page(DataPage)
|
||||
|
||||
return self.page.get_current()
|
||||
|
|
@ -155,28 +154,16 @@ class RadioFranceBrowser(BaseBrowser):
|
|||
def get_current_direct(self, _id):
|
||||
json_data = self.openurl('http://%s/sites/default/files/direct.json?_=%s' % (self.id2domain(_id), int(time())))
|
||||
data = json.load(json_data)
|
||||
|
||||
document = self.parser.parse(StringIO(data.get('html')))
|
||||
artist = document.findtext('//span[@class="artiste"]')
|
||||
title = document.findtext('//span[@class="titre"]')
|
||||
artist = unicode(artist) if artist else None
|
||||
title = unicode(title) if title else None
|
||||
title = unicode(data['rf_titre_antenne']['titre'])
|
||||
artist = unicode(data['rf_titre_antenne']['interprete'])
|
||||
return (artist, title)
|
||||
|
||||
def get_current_direct_large(self, _id):
|
||||
json_data = self.openurl('http://%s/sites/default/files/direct-large.json?_=%s' % (self.id2domain(_id), int(time())))
|
||||
json_data = self.openurl('http://%s/sites/default/files/import_si/si_titre_antenne/FIP_player_current.json'
|
||||
% self.id2domain(_id))
|
||||
data = json.load(json_data)
|
||||
|
||||
document = self.parser.parse(StringIO(data.get('html')))
|
||||
current = document.find('//div[@class="direct-current"]')
|
||||
if current is not None:
|
||||
artist = current.findtext('.//div[@class="artiste"]')
|
||||
title = current.findtext('.//div[@class="titre"]')
|
||||
artist = unicode(artist) if artist else None
|
||||
title = unicode(title) if title else None
|
||||
else:
|
||||
artist = None
|
||||
title = None
|
||||
artist = unicode(data['current']['song']['interpreteMorceau'])
|
||||
title = unicode(data['current']['song']['titre'])
|
||||
return (artist, title)
|
||||
|
||||
@id2url(RadioFranceVideo.id2url)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue