From a37382ff50515dcf3d3f4c6369b8d026caf16b90 Mon Sep 17 00:00:00 2001 From: Laurent Bachelier Date: Thu, 2 Feb 2012 15:24:47 +0100 Subject: [PATCH] Move francebleu into a Collection Rationale: * 43 stations for a radio not many people care about * It's still available by cd francebleu; ls * The fact that it exists is displayed on the 'root' ls (though poorly, but it's CapCollection's/ReplApplication fault). --- modules/radiofrance/backend.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/radiofrance/backend.py b/modules/radiofrance/backend.py index f7eed34a..3d1baa11 100644 --- a/modules/radiofrance/backend.py +++ b/modules/radiofrance/backend.py @@ -19,7 +19,7 @@ from weboob.capabilities.radio import ICapRadio, Radio, Stream, Emission -from weboob.capabilities.collection import ICapCollection, CollectionNotFound +from weboob.capabilities.collection import ICapCollection, CollectionNotFound, Collection from weboob.tools.backend import BaseBackend from weboob.tools.browser import BaseBrowser, BasePage @@ -156,12 +156,18 @@ class RadioFranceBackend(BaseBackend, ICapRadio, ICapCollection): _RSS_RADIOS = ('francemusique', ) def iter_resources(self, split_path): - if len(split_path) > 0: + if len(split_path) == 1 and split_path[0] == 'francebleu': + for id in sorted(self._RADIOS.iterkeys()): + if id.startswith('fb'): + yield self.get_radio(id) + elif len(split_path) == 0: + for id in sorted(self._RADIOS.iterkeys()): + if not id.startswith('fb'): + yield self.get_radio(id) + yield Collection('francebleu', self.iter_resources('francebleu')) + else: raise CollectionNotFound() - for id in sorted(self._RADIOS.iterkeys()): - yield self.get_radio(id) - def iter_radios_search(self, pattern): for radio in self.iter_resources([]): if pattern.lower() in radio.title.lower() or pattern.lower() in radio.description.lower():