[weboob] [PATCH 2/2] Fix bug francetelevisions latest videos by commenting "latest" feature

Vincent Texier vit at free.fr
Mon Nov 17 20:29:44 CET 2014


The page no longer exists on new website. Feature latest disabled.

Signed-off-by: Vincent Texier <vit at free.fr>
---
 modules/francetelevisions/browser.py |  8 +++++---
 modules/francetelevisions/module.py  | 35 ++++++++++++++++++-----------------
 modules/francetelevisions/pages.py   |  5 +++--
 modules/francetelevisions/test.py    | 15 ++++++++-------
 4 files changed, 34 insertions(+), 29 deletions(-)

diff --git a/modules/francetelevisions/browser.py b/modules/francetelevisions/browser.py
index 5ef4cff..a524f26 100644
--- a/modules/francetelevisions/browser.py
+++ b/modules/francetelevisions/browser.py
@@ -30,7 +30,8 @@ class PluzzBrowser(PagesBrowser):
     BASEURL = 'http://pluzz.francetv.fr'
 
     index_page = URL(r'recherche\?recherche=(?P<pattern>.*)', IndexPage)
-    latest_page = URL(r'lesplusrecents', IndexPage)
+    ## This page no longer exists on new website...
+    #latest_page = URL(r'lesplusrecents', IndexPage)
     video_page = URL(r'http://webservices.francetelevisions.fr/tools/getInfosOeuvre/v2/\?idDiffusion=(?P<id>.*)&catalogue=Pluzz', VideoPage)
 
     def search_videos(self, pattern):
@@ -50,5 +51,6 @@ class PluzzBrowser(PagesBrowser):
         r.close()
         return buf
 
-    def latest_videos(self):
-        return self.latest_page.go().iter_videos()
+    ## This page no longer exists on new website...
+    # def latest_videos(self):
+    #     return self.latest_page.go().iter_videos()
diff --git a/modules/francetelevisions/module.py b/modules/francetelevisions/module.py
index 8619b75..367e8fa 100644
--- a/modules/francetelevisions/module.py
+++ b/modules/francetelevisions/module.py
@@ -19,7 +19,8 @@
 
 
 from weboob.capabilities.video import CapVideo, BaseVideo
-from weboob.capabilities.collection import CapCollection, CollectionNotFound
+#from weboob.capabilities.collection import CapCollection, CollectionNotFound
+from weboob.capabilities.collection import CapCollection
 from weboob.tools.backend import Module
 
 from .browser import PluzzBrowser
@@ -52,21 +53,21 @@ class PluzzModule(Module, CapVideo, CapCollection):
 
         return video
 
-    def iter_resources(self, objs, split_path):
-        if BaseVideo in objs:
-            collection = self.get_collection(objs, split_path)
-            if collection.path_level == 0:
-                yield self.get_collection(objs, [u'latest'])
-            if collection.split_path == [u'latest']:
-                for video in self.browser.latest_videos():
-                    yield video
-
-    def validate_collection(self, objs, collection):
-        if collection.path_level == 0:
-            return
-        if BaseVideo in objs and collection.split_path == [u'latest']:
-            collection.title = u'Latest France Télévisions videos'
-            return
-        raise CollectionNotFound(collection.split_path)
+    # def iter_resources(self, objs, split_path):
+    #     if BaseVideo in objs:
+    #         collection = self.get_collection(objs, split_path)
+    #         if collection.path_level == 0:
+    #             yield self.get_collection(objs, [u'latest'])
+    #         if collection.split_path == [u'latest']:
+    #             for video in self.browser.latest_videos():
+    #                 yield video
+    #
+    # def validate_collection(self, objs, collection):
+    #     if collection.path_level == 0:
+    #         return
+    #     if BaseVideo in objs and collection.split_path == [u'latest']:
+    #         collection.title = u'Latest France Télévisions videos'
+    #         return
+    #     raise CollectionNotFound(collection.split_path)
 
     OBJECTS = {BaseVideo: fill_video}
diff --git a/modules/francetelevisions/pages.py b/modules/francetelevisions/pages.py
index 1118d04..0fe3087 100644
--- a/modules/francetelevisions/pages.py
+++ b/modules/francetelevisions/pages.py
@@ -25,7 +25,8 @@ from datetime import timedelta
 from weboob.browser.pages import HTMLPage, JsonPage
 from weboob.browser.elements import ItemElement, ListElement, method
 from weboob.browser.filters.standard import Filter, CleanText, Regexp, Format, DateTime, Env, Duration
-from weboob.browser.filters.html import Link, Attr, XPath
+#from weboob.browser.filters.html import Link, Attr, XPath
+from weboob.browser.filters.html import Link, Attr
 from weboob.browser.filters.json import Dict
 
 
@@ -47,7 +48,7 @@ class IndexPage(HTMLPage):
 
         class item(ItemElement):
             klass = BaseVideo
-            
+
             obj_title = Format('%s', CleanText('div/div[@class="resultat-titre-diff"]/a'))
             obj_id = Regexp(Link('div/div[@class="resultat-titre-diff"]/a'),
                             '^/videos/.+,(.+).html$')
diff --git a/modules/francetelevisions/test.py b/modules/francetelevisions/test.py
index 568d770..071b3eb 100644
--- a/modules/francetelevisions/test.py
+++ b/modules/francetelevisions/test.py
@@ -19,7 +19,7 @@
 
 
 from weboob.tools.test import BackendTest
-from weboob.capabilities.video import BaseVideo
+#from weboob.capabilities.video import BaseVideo
 
 
 class PluzzTest(BackendTest):
@@ -33,9 +33,10 @@ class PluzzTest(BackendTest):
         self.backend.fillobj(v, ('url',))
         self.assertTrue(v.url, 'URL for video "%s" not found: %s' % (v.id, v.url))
 
-    def test_latest(self):
-        l = list(self.backend.iter_resources([BaseVideo], [u'latest']))
-        assert len(l)
-        v = l[0]
-        self.backend.fillobj(v, ('url',))
-        assert v.url
+    ## page no longer exists on new website
+    # def test_latest(self):
+    #     l = list(self.backend.iter_resources([BaseVideo], [u'latest']))
+    #     assert len(l)
+    #     v = l[0]
+    #     self.backend.fillobj(v, ('url',))
+    #     assert v.url
-- 
1.9.1



More information about the weboob mailing list