Support fetching the current FIP song
Sadly the weird encoding stuff is required.
This commit is contained in:
parent
3c9c2c7490
commit
7ca156116e
2 changed files with 28 additions and 2 deletions
|
|
@ -99,6 +99,7 @@ class RadioFranceBackend(BaseBackend, ICapRadio, ICapCollection):
|
||||||
|
|
||||||
_DIRECTJSON_RADIOS = ('lemouv', 'franceinter', )
|
_DIRECTJSON_RADIOS = ('lemouv', 'franceinter', )
|
||||||
_RSS_RADIOS = ('francemusique', )
|
_RSS_RADIOS = ('francemusique', )
|
||||||
|
_ANTENNA_RADIOS = ('fip', )
|
||||||
|
|
||||||
def iter_resources(self, split_path):
|
def iter_resources(self, split_path):
|
||||||
if len(split_path) == 1 and split_path[0] == 'francebleu':
|
if len(split_path) == 1 and split_path[0] == 'francebleu':
|
||||||
|
|
@ -160,6 +161,8 @@ class RadioFranceBackend(BaseBackend, ICapRadio, ICapCollection):
|
||||||
title = 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 radio.id in self._ANTENNA_RADIOS:
|
||||||
|
artist, title = self.browser.get_current_antenna(radio.id)
|
||||||
if title:
|
if title:
|
||||||
if not radio.current or radio.current is NotLoaded:
|
if not radio.current or radio.current is NotLoaded:
|
||||||
radio.current = Emission(0)
|
radio.current = Emission(0)
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from weboob.tools.browser import BaseBrowser, BasePage
|
from weboob.tools.browser import BaseBrowser, BasePage, BrokenPageError
|
||||||
|
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
from time import time
|
from time import time
|
||||||
|
|
@ -52,11 +52,26 @@ class RssPage(BasePage):
|
||||||
return ' '.join(titles)
|
return ' '.join(titles)
|
||||||
|
|
||||||
|
|
||||||
|
class RssAntennaPage(BasePage):
|
||||||
|
ENCODING = 'ISO-8859-1'
|
||||||
|
def get_track(self):
|
||||||
|
# This information is not always available
|
||||||
|
try:
|
||||||
|
marquee = self.parser.select(self.document.getroot(), 'marquee', 1)
|
||||||
|
track = self.parser.select(marquee, 'font b', 2)
|
||||||
|
artist = unicode(track[0].text).strip() or None
|
||||||
|
title = unicode(track[1].text).strip() or None
|
||||||
|
return (artist, title)
|
||||||
|
except BrokenPageError:
|
||||||
|
return (None, None)
|
||||||
|
|
||||||
|
|
||||||
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'/playerjs/direct/donneesassociees/html\?guid=$': 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,
|
||||||
|
r'http://players.tv-radio.com/radiofrance/metadatas/([a-z]+)RSS_a_lantenne.html': RssAntennaPage}
|
||||||
|
|
||||||
def get_current_playerjs(self, _id):
|
def get_current_playerjs(self, _id):
|
||||||
self.location('http://www.%s.fr/playerjs/direct/donneesassociees/html?guid=' % _id)
|
self.location('http://www.%s.fr/playerjs/direct/donneesassociees/html?guid=' % _id)
|
||||||
|
|
@ -80,3 +95,11 @@ class RadioFranceBrowser(BaseBrowser):
|
||||||
artist = unicode(artist) if artist else None
|
artist = unicode(artist) if artist else None
|
||||||
title = unicode(title) if title else None
|
title = unicode(title) if title else None
|
||||||
return (artist, title)
|
return (artist, title)
|
||||||
|
|
||||||
|
def get_current_antenna(self, _id):
|
||||||
|
self.ENCODING = RssAntennaPage.ENCODING
|
||||||
|
self.location('http://players.tv-radio.com/radiofrance/metadatas/%sRSS_a_lantenne.html' % _id)
|
||||||
|
assert self.is_on_page(RssAntennaPage)
|
||||||
|
result = self.page.get_track()
|
||||||
|
self.ENCODING = RadioFranceBrowser.ENCODING
|
||||||
|
return result
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue