[francetelevisions] handle lastest replay videos
This commit is contained in:
parent
d7c483922a
commit
3540bfe2fc
4 changed files with 45 additions and 3 deletions
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
|
||||
from weboob.browser import PagesBrowser, URL
|
||||
from .pages import IndexPage, VideoPage, Programs, VideoListPage
|
||||
from .pages import IndexPage, VideoPage, Programs, VideoListPage, LatestPage
|
||||
|
||||
__all__ = ['PluzzBrowser']
|
||||
|
||||
|
|
@ -30,6 +30,7 @@ class PluzzBrowser(PagesBrowser):
|
|||
BASEURL = 'http://pluzz.francetv.fr'
|
||||
PROGRAMS = None
|
||||
|
||||
latest = URL('http://pluzz.webservices.francetelevisions.fr/pluzz/liste/type/replay', LatestPage)
|
||||
programs_page = URL('http://pluzz.webservices.francetelevisions.fr/pluzz/programme', Programs)
|
||||
index_page = URL(r'recherche\?recherche=(?P<pattern>.*)', IndexPage)
|
||||
video_page = URL(r'http://webservices.francetelevisions.fr/tools/getInfosOeuvre/v2/\?idDiffusion=(?P<id>.*)&catalogue=Pluzz', VideoPage)
|
||||
|
|
@ -69,3 +70,6 @@ class PluzzBrowser(PagesBrowser):
|
|||
r = self.open(url, stream=True)
|
||||
buf = r.iter_lines()
|
||||
return buf
|
||||
|
||||
def latest_videos(self):
|
||||
return self.latest.go().iter_videos()
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
|
||||
from weboob.capabilities.video import CapVideo, BaseVideo
|
||||
from weboob.capabilities.collection import CapCollection
|
||||
from weboob.capabilities.collection import CapCollection, CollectionNotFound
|
||||
from weboob.tools.backend import Module
|
||||
|
||||
from .browser import PluzzBrowser
|
||||
|
|
@ -56,4 +56,22 @@ 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)
|
||||
|
||||
OBJECTS = {BaseVideo: fill_video}
|
||||
|
|
|
|||
|
|
@ -142,3 +142,16 @@ class Programs(JsonPage):
|
|||
|
||||
obj_id = CleanText(Dict('url'))
|
||||
obj__title = CleanText(Dict('titre_programme'))
|
||||
|
||||
|
||||
class LatestPage(JsonPage):
|
||||
@method
|
||||
class iter_videos(DictElement):
|
||||
item_xpath = 'emissions'
|
||||
|
||||
class Item(ItemElement):
|
||||
klass = BaseVideo
|
||||
|
||||
obj_id = Dict('id_diffusion')
|
||||
obj_title = Dict('titre_programme')
|
||||
obj_date = DateTime(Dict('date_diffusion'))
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from weboob.capabilities.video import BaseVideo
|
||||
from weboob.tools.test import BackendTest
|
||||
|
||||
|
||||
|
|
@ -35,3 +35,10 @@ class PluzzTest(BackendTest):
|
|||
def test_video_from_url(self):
|
||||
v = self.backend.get_video('http://pluzz.francetv.fr/videos/faites_entrer_l_accuse.html')
|
||||
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',))
|
||||
self.assertTrue(v.url, 'URL for video "%s" not found' % (v.id))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue