Add support for current France Musique info
This commit is contained in:
parent
3c20c95891
commit
365247bd63
1 changed files with 23 additions and 1 deletions
|
|
@ -42,11 +42,24 @@ class DataPage(BasePage):
|
||||||
if len(title):
|
if len(title):
|
||||||
return title
|
return title
|
||||||
|
|
||||||
|
class RssPage(BasePage):
|
||||||
|
def get_title(self):
|
||||||
|
titles = []
|
||||||
|
for heading in self.parser.select(self.document.getroot(), 'h1, h2, h3, h4'):
|
||||||
|
# Remove newlines/multiple spaces
|
||||||
|
words = heading.text_content()
|
||||||
|
if words:
|
||||||
|
for word in unicode(words).split():
|
||||||
|
titles.append(word)
|
||||||
|
if len(titles):
|
||||||
|
return ' '.join(titles)
|
||||||
|
|
||||||
|
|
||||||
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}
|
||||||
|
|
||||||
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)
|
||||||
|
|
@ -54,6 +67,12 @@ class RadioFranceBrowser(BaseBrowser):
|
||||||
|
|
||||||
return self.page.get_title()
|
return self.page.get_title()
|
||||||
|
|
||||||
|
def get_current_rss(self, id):
|
||||||
|
self.location('http://players.tv-radio.com/radiofrance/metadatas/%sRSS.html' % id)
|
||||||
|
assert self.is_on_page(RssPage)
|
||||||
|
|
||||||
|
return self.page.get_title()
|
||||||
|
|
||||||
def get_current_direct(self, id):
|
def get_current_direct(self, id):
|
||||||
json_data = self.openurl('http://www.%s.fr/sites/default/files/direct.json?_=%s' % (id, int(time())))
|
json_data = self.openurl('http://www.%s.fr/sites/default/files/direct.json?_=%s' % (id, int(time())))
|
||||||
data = json.load(json_data)
|
data = json.load(json_data)
|
||||||
|
|
@ -134,6 +153,7 @@ class RadioFranceBackend(BaseBackend, ICapRadio, ICapCollection):
|
||||||
)
|
)
|
||||||
|
|
||||||
_DIRECTJSON_RADIOS = ('lemouv', 'franceinter', )
|
_DIRECTJSON_RADIOS = ('lemouv', 'franceinter', )
|
||||||
|
_RSS_RADIOS = ('francemusique', )
|
||||||
|
|
||||||
def iter_resources(self, splited_path):
|
def iter_resources(self, splited_path):
|
||||||
if len(splited_path) > 0:
|
if len(splited_path) > 0:
|
||||||
|
|
@ -188,6 +208,8 @@ class RadioFranceBackend(BaseBackend, ICapRadio, ICapCollection):
|
||||||
radio.current.title = "%s [%s]" % (title, radio.current.title)
|
radio.current.title = "%s [%s]" % (title, radio.current.title)
|
||||||
else:
|
else:
|
||||||
radio.current.title = title
|
radio.current.title = title
|
||||||
|
if radio.id in self._RSS_RADIOS:
|
||||||
|
radio.current.title = self.browser.get_current_rss(radio.id)
|
||||||
return radio
|
return radio
|
||||||
|
|
||||||
OBJECTS = {Radio: fill_radio}
|
OBJECTS = {Radio: fill_radio}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue