diff --git a/weboob/backends/canalplus/__init__.py b/weboob/backends/canalplus/__init__.py
index e9f8cf40..f0039816 100644
--- a/weboob/backends/canalplus/__init__.py
+++ b/weboob/backends/canalplus/__init__.py
@@ -1,21 +1,19 @@
# -*- coding: utf-8 -*-
-# Copyright(C) 2010-2011 Romain Bignon
+# Copyright(C) 2010 Romain Bignon
#
-# This file is part of weboob.
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 3 of the License.
#
-# weboob is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# weboob is distributed in the hope that it will be useful,
+# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-# You should have received a copy of the GNU Affero General Public License
-# along with weboob. If not, see .
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
from .backend import CanalplusBackend
diff --git a/weboob/backends/canalplus/backend.py b/weboob/backends/canalplus/backend.py
index 0e220703..06bced28 100644
--- a/weboob/backends/canalplus/backend.py
+++ b/weboob/backends/canalplus/backend.py
@@ -1,21 +1,19 @@
# -*- coding: utf-8 -*-
-# Copyright(C) 2010-2011 Nicolas Duhamel
+# Copyright(C) 2010 Nicolas Duhamel
#
-# This file is part of weboob.
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 3 of the License.
#
-# weboob is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# weboob is distributed in the hope that it will be useful,
+# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-# You should have received a copy of the GNU Affero General Public License
-# along with weboob. If not, see .
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
from __future__ import with_statement
@@ -27,17 +25,19 @@ from weboob.tools.value import ValuesDict, Value
from .browser import CanalplusBrowser
from .pages import CanalplusVideo
+from weboob.capabilities.collection import ICapCollection
+
__all__ = ['CanalplusBackend']
-class CanalplusBackend(BaseBackend, ICapVideo):
+class CanalplusBackend(BaseBackend, ICapVideo, ICapCollection):
NAME = 'canalplus'
MAINTAINER = 'Nicolas Duhamel'
EMAIL = 'nicolas@jombi.fr'
VERSION = '0.8'
DESCRIPTION = 'Canal plus french TV'
- LICENSE = 'AGPLv3+'
+ LICENSE = 'GPLv3'
CONFIG = ValuesDict(Value('quality', label='Quality of videos', choices=['hd', 'sd'], default='hd'))
BROWSER = CanalplusBrowser
@@ -63,3 +63,16 @@ class CanalplusBackend(BaseBackend, ICapVideo):
return video
OBJECTS = {CanalplusVideo: fill_video}
+
+ working_coll = []
+
+ def get_working_collection(self):
+ return self.working_coll
+
+ def change_working_collection(self, splited_path):
+ self.working_coll = self.browser.change_working_collection(splited_path)
+ return self.working_coll
+
+ def iter_resources(self):
+ rep = self.browser.iter_resources(self.working_coll)
+ return rep
diff --git a/weboob/backends/canalplus/browser.py b/weboob/backends/canalplus/browser.py
index 3fb70e9a..0409b17b 100644
--- a/weboob/backends/canalplus/browser.py
+++ b/weboob/backends/canalplus/browser.py
@@ -1,21 +1,19 @@
# -*- coding: utf-8 -*-
-# Copyright(C) 2010-2011 Nicolas Duhamel
+# Copyright(C) 2010 Nicolas Duhamel
#
-# This file is part of weboob.
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 3 of the License.
#
-# weboob is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# weboob is distributed in the hope that it will be useful,
+# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-# You should have received a copy of the GNU Affero General Public License
-# along with weboob. If not, see .
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import urllib
@@ -27,6 +25,7 @@ from weboob.tools.browser.decorators import id2url
from .pages import InitPage, CanalplusVideo, VideoPage
+from weboob.capabilities.collection import Collection, CollectionNotFound
__all__ = ['CanalplusBrowser']
@@ -47,6 +46,7 @@ class CanalplusBrowser(BaseBrowser):
r'http://service.canal-plus.com/video/rest/initPlayer/cplus/': InitPage,
r'http://service.canal-plus.com/video/rest/search/cplus/.*': VideoPage,
r'http://service.canal-plus.com/video/rest/getVideosLiees/cplus/(?P.+)': VideoPage,
+ r'http://service.canal-plus.com/video/rest/getMEAs/cplus/.*': VideoPage,
}
#We need lxml.etree.XMLParser for read CDATA
@@ -74,3 +74,38 @@ class CanalplusBrowser(BaseBrowser):
def get_video(self, url, video=None):
self.location(url)
return self.page.get_video(video, self.quality)
+
+ def change_working_collection(self, splited_path):
+ self.home()
+ collections = self.page.collections
+
+ def walk(path, collections, final=[]):
+ if len(path) == 0: return final
+ i = path.pop(0)
+ if i in [collection.title for collection in collections if isinstance(collection, Collection)]:
+ final.append(i)
+ else:
+ print "Error path %s unknow, %s , %s " % (i,final,[collection.title for collection in collections if isinstance(collection, Collection)] )
+ raise CollectionNotFound()
+
+ return walk(path, [collection.children for collection in collections if isinstance(collection, Collection) and collection.title == i][0], final)
+
+ return walk(splited_path, collections)
+
+ def iter_resources(self, cur_coll):
+ self.home()
+ collections = self.page.collections
+
+ def walk_res(path, collections):
+ if not isinstance(collections, (list, Collection)):
+ return collections
+ if len(path) == 0:
+ return [collection.title for collection in collections ]
+ i = path[0]
+ if i not in [collection.title for collection in collections]:
+ print "Error path %s unknow" % i
+ raise CollectionNotFound()
+
+ return walk_res(path[1:], [collection.children for collection in collections if collection.title == i][0])
+
+ return walk_res(cur_coll, collections)
diff --git a/weboob/backends/canalplus/pages/__init__.py b/weboob/backends/canalplus/pages/__init__.py
index c4277bc3..f5c04598 100644
--- a/weboob/backends/canalplus/pages/__init__.py
+++ b/weboob/backends/canalplus/pages/__init__.py
@@ -1,21 +1,19 @@
# -*- coding: utf-8 -*-
-# Copyright(C) 2010-2011 Nicolas Duhamel
+# Copyright(C) 2010 Nicolas Duhamel
#
-# This file is part of weboob.
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 3 of the License.
#
-# weboob is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# weboob is distributed in the hope that it will be useful,
+# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-# You should have received a copy of the GNU Affero General Public License
-# along with weboob. If not, see .
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
from .initpage import InitPage
from .video import CanalplusVideo
diff --git a/weboob/backends/canalplus/pages/initpage.py b/weboob/backends/canalplus/pages/initpage.py
index 385a2bc9..8ce722bf 100644
--- a/weboob/backends/canalplus/pages/initpage.py
+++ b/weboob/backends/canalplus/pages/initpage.py
@@ -1,44 +1,47 @@
# -*- coding: utf-8 -*-
-# Copyright(C) 2010-2011 Nicolas Duhamel
+# Copyright(C) 2010 Nicolas Duhamel
#
-# This file is part of weboob.
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 3 of the License.
#
-# weboob is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# weboob is distributed in the hope that it will be useful,
+# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-# You should have received a copy of the GNU Affero General Public License
-# along with weboob. If not, see .
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
from weboob.tools.browser import BasePage
+from weboob.capabilities.collection import Collection
__all__ = ['InitPage']
class InitPage(BasePage):
+
def on_loaded(self):
- channels = []
+ self.collections = []
+
+ def do(id):
+ self.browser.location("http://service.canal-plus.com/video/rest/getMEAs/cplus/" + id)
+ return self.browser.page.iter_channel()
+
### Parse liste des channels
for elem in self.document[2].getchildren():
- channel = {}
+ coll = Collection()
for e in elem.getchildren():
- subchannels = []
if e.tag == "NOM":
- channel['nom'] = e.text
+ coll.title = e.text.strip().encode('utf-8')
elif e.tag == "SELECTIONS":
for select in e:
- subchannel = {}
- subchannel['id'] = select[0].text
- subchannel['nom'] = select[1].text
- subchannels.append(subchannel)
- channel['subchannels'] = subchannels
- channels.append(channel)
+ sub = Collection(title=select[1].text.strip().encode('utf-8'))
+ sub.id = select[0].text
+ sub.children = do
+ coll.appendchild(sub)
+ self.collections.append(coll)
diff --git a/weboob/backends/canalplus/pages/video.py b/weboob/backends/canalplus/pages/video.py
index febbfcd6..1cdec78d 100644
--- a/weboob/backends/canalplus/pages/video.py
+++ b/weboob/backends/canalplus/pages/video.py
@@ -1,21 +1,19 @@
# -*- coding: utf-8 -*-
-# Copyright(C) 2010-2011 Nicolas Duhamel
+# Copyright(C) 2010 Nicolas Duhamel
#
-# This file is part of weboob.
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 3 of the License.
#
-# weboob is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# weboob is distributed in the hope that it will be useful,
+# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-# You should have received a copy of the GNU Affero General Public License
-# along with weboob. If not, see .
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
from weboob.capabilities.video import BaseVideo
@@ -25,6 +23,7 @@ __all__ = ['CanalplusVideo']
class CanalplusVideo(BaseVideo):
+ swf_player = False
@classmethod
def id2url(cls, _id):
return 'http://service.canal-plus.com/video/rest/getVideosLiees/cplus/%s' % _id
diff --git a/weboob/backends/canalplus/pages/videopage.py b/weboob/backends/canalplus/pages/videopage.py
index 02883ecd..4f08ffa3 100644
--- a/weboob/backends/canalplus/pages/videopage.py
+++ b/weboob/backends/canalplus/pages/videopage.py
@@ -1,21 +1,19 @@
# -*- coding: utf-8 -*-
-# Copyright(C) 2010-2011 Nicolas Duhamel
+# Copyright(C) 2010 Nicolas Duhamel
#
-# This file is part of weboob.
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 3 of the License.
#
-# weboob is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# weboob is distributed in the hope that it will be useful,
+# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-# You should have received a copy of the GNU Affero General Public License
-# along with weboob. If not, see .
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
from datetime import datetime
@@ -70,7 +68,19 @@ class VideoPage(BasePage):
def iter_results(self):
for vid in self.document.getchildren():
yield self.parse_video(vid)
-
+
+ def iter_channel(self):
+ for vid in self.document.getchildren():
+ yield self.parse_video_channel(vid)
+
+ def parse_video_channel(self,el):
+ _id = el[0].text
+ video = CanalplusVideo(_id)
+ video.title = el[2][3][0].text
+ video.date = datetime.now()
+ return video
+
+
def get_video(self, video, quality):
_id = self.group_dict['id']
for vid in self.document.getchildren():
diff --git a/weboob/backends/canalplus/test.py b/weboob/backends/canalplus/test.py
index 507de9f3..326c1a51 100644
--- a/weboob/backends/canalplus/test.py
+++ b/weboob/backends/canalplus/test.py
@@ -1,21 +1,19 @@
# -*- coding: utf-8 -*-
-# Copyright(C) 2010-2011 Romain Bignon
+# Copyright(C) 2010 Romain Bignon
#
-# This file is part of weboob.
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 3 of the License.
#
-# weboob is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# weboob is distributed in the hope that it will be useful,
+# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-# You should have received a copy of the GNU Affero General Public License
-# along with weboob. If not, see .
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
from weboob.tools.test import BackendTest