[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',
|
'franceculture',
|
||||||
'franceinfo',
|
'franceinfo',
|
||||||
'lemouv',
|
'lemouv',
|
||||||
'fip',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
_DIRECTJSON_RADIOS = ('lemouv', 'franceinter', )
|
_DIRECTJSON_RADIOS = ('lemouv', )
|
||||||
_LARGEDIRECTJSON_RADIOS = ('fip', )
|
_LARGEDIRECTJSON_RADIOS = ('fip', )
|
||||||
_RSS_RADIOS = ('francemusique', )
|
_RSS_RADIOS = ('francemusique', )
|
||||||
|
|
||||||
|
|
@ -128,7 +127,7 @@ class RadioFranceBackend(BaseBackend, CapRadio, CapCollection, CapVideo):
|
||||||
if not isinstance(radio, Radio):
|
if not isinstance(radio, Radio):
|
||||||
radio = Radio(radio)
|
radio = Radio(radio)
|
||||||
|
|
||||||
if not radio.id in self._RADIOS:
|
if radio.id not in self._RADIOS:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
title, hd = self._RADIOS[radio.id]
|
title, hd = self._RADIOS[radio.id]
|
||||||
|
|
@ -146,10 +145,10 @@ class RadioFranceBackend(BaseBackend, CapRadio, CapCollection, CapVideo):
|
||||||
|
|
||||||
stream = BaseAudioStream(0)
|
stream = BaseAudioStream(0)
|
||||||
if hd:
|
if hd:
|
||||||
stream.bitrate=128
|
stream.bitrate = 128
|
||||||
else:
|
else:
|
||||||
stream.bitrate=32
|
stream.bitrate = 32
|
||||||
stream.format=u'mp3'
|
stream.format = u'mp3'
|
||||||
stream.title = u'%s kbits/s' % (stream.bitrate)
|
stream.title = u'%s kbits/s' % (stream.bitrate)
|
||||||
stream.url = url
|
stream.url = url
|
||||||
radio.streams = [stream]
|
radio.streams = [stream]
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ from weboob.tools.json import json
|
||||||
from weboob.capabilities.video import BaseVideo
|
from weboob.capabilities.video import BaseVideo
|
||||||
from weboob.tools.browser.decorators import id2url
|
from weboob.tools.browser.decorators import id2url
|
||||||
|
|
||||||
from StringIO import StringIO
|
|
||||||
from time import time
|
from time import time
|
||||||
import re
|
import re
|
||||||
from urlparse import parse_qs
|
from urlparse import parse_qs
|
||||||
|
|
@ -92,7 +91,7 @@ class ReplayPage(BasePage):
|
||||||
class DataPage(BasePage):
|
class DataPage(BasePage):
|
||||||
def get_current(self):
|
def get_current(self):
|
||||||
document = self.document
|
document = self.document
|
||||||
title = None
|
title = ''
|
||||||
for metas in self.parser.select(document.getroot(), 'div.metas'):
|
for metas in self.parser.select(document.getroot(), 'div.metas'):
|
||||||
ftitle = unicode(metas.text_content()).strip()
|
ftitle = unicode(metas.text_content()).strip()
|
||||||
if ftitle:
|
if ftitle:
|
||||||
|
|
@ -104,7 +103,7 @@ class DataPage(BasePage):
|
||||||
ftitle = document.findtext('//div[@class="subtitle"]')
|
ftitle = document.findtext('//div[@class="subtitle"]')
|
||||||
title = unicode(ftitle).strip() if ftitle else title
|
title = unicode(ftitle).strip() if ftitle else title
|
||||||
else:
|
else:
|
||||||
artist = None
|
artist = ''
|
||||||
|
|
||||||
return (artist, title)
|
return (artist, title)
|
||||||
|
|
||||||
|
|
@ -125,7 +124,7 @@ class RssPage(BasePage):
|
||||||
class RadioFranceBrowser(BaseBrowser):
|
class RadioFranceBrowser(BaseBrowser):
|
||||||
DOMAIN = None
|
DOMAIN = None
|
||||||
ENCODING = 'UTF-8'
|
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,
|
r'http://players.tv-radio.com/radiofrance/metadatas/([a-z]+)RSS.html': RssPage,
|
||||||
PlayerPage.URL: PlayerPage,
|
PlayerPage.URL: PlayerPage,
|
||||||
ReplayPage.URL: ReplayPage,
|
ReplayPage.URL: ReplayPage,
|
||||||
|
|
@ -141,7 +140,7 @@ class RadioFranceBrowser(BaseBrowser):
|
||||||
return 'www.%s.fr' % _id
|
return 'www.%s.fr' % _id
|
||||||
|
|
||||||
def get_current_playerjs(self, _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)
|
assert self.is_on_page(DataPage)
|
||||||
|
|
||||||
return self.page.get_current()
|
return self.page.get_current()
|
||||||
|
|
@ -155,28 +154,16 @@ class RadioFranceBrowser(BaseBrowser):
|
||||||
def get_current_direct(self, _id):
|
def get_current_direct(self, _id):
|
||||||
json_data = self.openurl('http://%s/sites/default/files/direct.json?_=%s' % (self.id2domain(_id), int(time())))
|
json_data = self.openurl('http://%s/sites/default/files/direct.json?_=%s' % (self.id2domain(_id), int(time())))
|
||||||
data = json.load(json_data)
|
data = json.load(json_data)
|
||||||
|
title = unicode(data['rf_titre_antenne']['titre'])
|
||||||
document = self.parser.parse(StringIO(data.get('html')))
|
artist = unicode(data['rf_titre_antenne']['interprete'])
|
||||||
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
|
|
||||||
return (artist, title)
|
return (artist, title)
|
||||||
|
|
||||||
def get_current_direct_large(self, _id):
|
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)
|
data = json.load(json_data)
|
||||||
|
artist = unicode(data['current']['song']['interpreteMorceau'])
|
||||||
document = self.parser.parse(StringIO(data.get('html')))
|
title = unicode(data['current']['song']['titre'])
|
||||||
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
|
|
||||||
return (artist, title)
|
return (artist, title)
|
||||||
|
|
||||||
@id2url(RadioFranceVideo.id2url)
|
@id2url(RadioFranceVideo.id2url)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue