Fix some failures with badly set 'current' field.
This commit is contained in:
parent
a37382ff50
commit
8d15911d67
2 changed files with 19 additions and 14 deletions
|
|
@ -18,6 +18,7 @@
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
from weboob.capabilities.base import NotLoaded
|
||||||
from weboob.capabilities.radio import ICapRadio, Radio, Stream, Emission
|
from weboob.capabilities.radio import ICapRadio, Radio, Stream, Emission
|
||||||
from weboob.capabilities.collection import ICapCollection, CollectionNotFound, Collection
|
from weboob.capabilities.collection import ICapCollection, CollectionNotFound, Collection
|
||||||
from weboob.tools.backend import BaseBackend
|
from weboob.tools.backend import BaseBackend
|
||||||
|
|
@ -42,6 +43,7 @@ class DataPage(BasePage):
|
||||||
if len(title):
|
if len(title):
|
||||||
return title
|
return title
|
||||||
|
|
||||||
|
|
||||||
class RssPage(BasePage):
|
class RssPage(BasePage):
|
||||||
def get_title(self):
|
def get_title(self):
|
||||||
titles = []
|
titles = []
|
||||||
|
|
@ -189,6 +191,8 @@ class RadioFranceBackend(BaseBackend, ICapRadio, ICapCollection):
|
||||||
else:
|
else:
|
||||||
url = self._MP3_URL % (radio.id, radio.id)
|
url = self._MP3_URL % (radio.id, radio.id)
|
||||||
|
|
||||||
|
# This should be asked demand, but is required for now as Radioob
|
||||||
|
# does not require it.
|
||||||
self.fillobj(radio, ('current', ))
|
self.fillobj(radio, ('current', ))
|
||||||
|
|
||||||
stream = Stream(0)
|
stream = Stream(0)
|
||||||
|
|
@ -199,23 +203,24 @@ class RadioFranceBackend(BaseBackend, ICapRadio, ICapCollection):
|
||||||
|
|
||||||
def fill_radio(self, radio, fields):
|
def fill_radio(self, radio, fields):
|
||||||
if 'current' in fields:
|
if 'current' in fields:
|
||||||
if not radio.current:
|
artist = None
|
||||||
radio.current = Emission(0)
|
title = None
|
||||||
radio.current.artist = None
|
|
||||||
radio.current.title = None
|
|
||||||
if radio.id in self._PLAYERJS_RADIOS:
|
if radio.id in self._PLAYERJS_RADIOS:
|
||||||
radio.current.title = self.browser.get_current_playerjs(radio.id)
|
title = self.browser.get_current_playerjs(radio.id)
|
||||||
if radio.id in self._DIRECTJSON_RADIOS:
|
if radio.id in self._DIRECTJSON_RADIOS:
|
||||||
artist, title = self.browser.get_current_direct(radio.id)
|
artist, dtitle = self.browser.get_current_direct(radio.id)
|
||||||
if artist:
|
if dtitle:
|
||||||
radio.current.artist = artist
|
|
||||||
if title:
|
if title:
|
||||||
if radio.current.title:
|
title = "%s [%s]" % (dtitle, title)
|
||||||
radio.current.title = "%s [%s]" % (title, radio.current.title)
|
|
||||||
else:
|
else:
|
||||||
radio.current.title = title
|
title = dtitle
|
||||||
if radio.id in self._RSS_RADIOS:
|
if radio.id in self._RSS_RADIOS:
|
||||||
radio.current.title = self.browser.get_current_rss(radio.id)
|
title = self.browser.get_current_rss(radio.id)
|
||||||
|
if title:
|
||||||
|
if not radio.current or radio.current is NotLoaded:
|
||||||
|
radio.current = Emission(0)
|
||||||
|
radio.current.title = title
|
||||||
|
radio.current.arist = artist
|
||||||
return radio
|
return radio
|
||||||
|
|
||||||
OBJECTS = {Radio: fill_radio}
|
OBJECTS = {Radio: fill_radio}
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ class Radioob(ReplApplication):
|
||||||
print >>sys.stderr, 'This command takes an argument: %s' % self.get_command_help('info', short=True)
|
print >>sys.stderr, 'This command takes an argument: %s' % self.get_command_help('info', short=True)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
radio = self.get_object(_id, 'get_radio')
|
radio = self.get_object(_id, 'get_radio', ['streams', 'current'])
|
||||||
if not radio:
|
if not radio:
|
||||||
print >>sys.stderr, 'Radio not found:', _id
|
print >>sys.stderr, 'Radio not found:', _id
|
||||||
return 3
|
return 3
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue