[weboob] [PATCH 2/2] Implements ICapCollection to let Nihon no Oto to appear in radioob ls command. PS: I hate cargo cult.

Thomas Lecavelier thomas at lecavelier.name
Tue Aug 13 13:39:16 CEST 2013


From: Thomas Lecavelier <tl at pierlis.com>

---
 modules/nihonnooto/backend.py |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/modules/nihonnooto/backend.py b/modules/nihonnooto/backend.py
index 873ff70..0c3d5f9 100644
--- a/modules/nihonnooto/backend.py
+++ b/modules/nihonnooto/backend.py
@@ -17,12 +17,13 @@
 # along with weboob. If not, see <http://www.gnu.org/licenses/>.
 
 from weboob.capabilities.radio import ICapRadio, Radio
+from weboob.capabilities.collection import ICapCollection
 from weboob.tools.backend import BaseBackend
 from .browser import NihonNoOtoBrowser
 
 __all__ = ['NihonNoOtoBackend']
 
-class NihonNoOtoBackend(BaseBackend, ICapRadio):
+class NihonNoOtoBackend(BaseBackend, ICapRadio, ICapCollection):
     NAME = 'nihonnooto'
     MAINTAINER = u'Thomas Lecavelier'
     EMAIL = 'thomas-weboob at lecavelier.name'
@@ -34,6 +35,14 @@ class NihonNoOtoBackend(BaseBackend, ICapRadio):
     BROWSER = NihonNoOtoBrowser
     _RADIOS = {'nihonnooto': (u'Nihon no OTO', True) }
 
+    def iter_resources(self, objs, split_path):
+        if Radio in objs:
+            self._restrict_level(split_path)
+        for radio in self.browser.iter_radios_list():
+            self.browser.get_current_emission()
+            radio.current = self.browser.get_current_emission()
+            yield radio
+
     def iter_radios_search(self, pattern):
         for radio in self.browser.iter_radios_list():
             if pattern.lower() in radio.title.lower() or pattern.lower() in radio.description.lower():
-- 
1.7.10.2 (Apple Git-33)




More information about the weboob mailing list