radiofrance: Use a better source for FIP
But sometimes it doesn't work. So, we still have the playerjs method as a fallback.
This commit is contained in:
parent
8080a71751
commit
6b6822f6ec
2 changed files with 24 additions and 2 deletions
|
|
@ -100,6 +100,7 @@ class RadioFranceBackend(BaseBackend, ICapRadio, ICapCollection, ICapVideo):
|
||||||
)
|
)
|
||||||
|
|
||||||
_DIRECTJSON_RADIOS = ('lemouv', 'franceinter', )
|
_DIRECTJSON_RADIOS = ('lemouv', 'franceinter', )
|
||||||
|
_LARGEDIRECTJSON_RADIOS = ('fip', )
|
||||||
_RSS_RADIOS = ('francemusique', )
|
_RSS_RADIOS = ('francemusique', )
|
||||||
|
|
||||||
def iter_resources(self, objs, split_path):
|
def iter_resources(self, objs, split_path):
|
||||||
|
|
@ -149,8 +150,7 @@ class RadioFranceBackend(BaseBackend, ICapRadio, ICapCollection, ICapVideo):
|
||||||
|
|
||||||
def fill_radio(self, radio, fields):
|
def fill_radio(self, radio, fields):
|
||||||
if 'current' in fields:
|
if 'current' in fields:
|
||||||
artist = None
|
artist = title = None
|
||||||
title = None
|
|
||||||
if radio.id in self._PLAYERJS_RADIOS:
|
if radio.id in self._PLAYERJS_RADIOS:
|
||||||
artist, title = self.browser.get_current_playerjs(radio.id)
|
artist, title = self.browser.get_current_playerjs(radio.id)
|
||||||
if title.endswith(u'par %s' % artist):
|
if title.endswith(u'par %s' % artist):
|
||||||
|
|
@ -164,6 +164,12 @@ class RadioFranceBackend(BaseBackend, ICapRadio, ICapCollection, ICapVideo):
|
||||||
title = "%s [%s]" % (dtitle, title)
|
title = "%s [%s]" % (dtitle, title)
|
||||||
else:
|
else:
|
||||||
title = dtitle
|
title = dtitle
|
||||||
|
elif radio.id in self._LARGEDIRECTJSON_RADIOS:
|
||||||
|
dartist, dtitle = self.browser.get_current_direct_large(radio.id)
|
||||||
|
if dartist:
|
||||||
|
artist = dartist
|
||||||
|
if dtitle:
|
||||||
|
title = dtitle
|
||||||
if radio.id in self._RSS_RADIOS:
|
if radio.id in self._RSS_RADIOS:
|
||||||
title = self.browser.get_current_rss(radio.id)
|
title = self.browser.get_current_rss(radio.id)
|
||||||
if title:
|
if title:
|
||||||
|
|
|
||||||
|
|
@ -159,6 +159,22 @@ class RadioFranceBrowser(BaseBrowser):
|
||||||
title = unicode(title) if title else None
|
title = unicode(title) if title else None
|
||||||
return (artist, title)
|
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())))
|
||||||
|
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
|
||||||
|
return (artist, title)
|
||||||
|
|
||||||
@id2url(RadioFranceVideo.id2url)
|
@id2url(RadioFranceVideo.id2url)
|
||||||
def get_video(self, url):
|
def get_video(self, url):
|
||||||
radio_domain = replay_id = None
|
radio_domain = replay_id = None
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue