new backend CanalPlus

This commit is contained in:
Nicolas Duhamel 2010-11-09 11:45:24 +01:00 committed by Romain Bignon
commit 47432020a3
8 changed files with 313 additions and 0 deletions

View file

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# Copyright(C) 2010 Nicolas Duhamel
#
# 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.
#
# 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 General Public License for more details.
#
# 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 .searchresultpage import SearchResultPage
from .video import CanalplusVideo
from .videopage import VideoPage
__all__ = ['InitPage', 'SearchResultPage', 'VideoPage', 'CanalplusVideo']

View file

@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
# Copyright(C) 2010 Nicolas Duhamel
#
# 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.
#
# 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 General Public License for more details.
#
# 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
__all__ = ['InitPage']
class InitPage(BasePage):
def on_loaded(self):
channels = []
### Parse liste des channels
for elem in self.document[2].getchildren():
channel = {}
for e in elem.getchildren():
subchannels = []
if e.tag == "NOM":
channel['nom'] = e.text
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)

View file

@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# Copyright(C) 2010 Nicolas Duhamel
#
# 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.
#
# 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 General Public License for more details.
#
# 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 .video import CanalplusVideo
__all__ = ['SearchResultPage']
class SearchResultPage(BasePage):
def iter_results(self):
for vid in self.document.getchildren():
#id
_id = vid[0].text
#Titre
titre = vid[2][9][0].text
#Sous titre
titre = titre + " " + vid[2][9][1].text
yield CanalplusVideo(_id, title=titre)

View file

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# Copyright(C) 2010 Nicolas Duhamel
#
# 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.
#
# 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 General Public License for more details.
#
# 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
__all__ = ['CanalplusVideo']
class CanalplusVideo(BaseVideo):
@classmethod
def id2url(cls, _id):
return 'http://service.canal-plus.com/video/rest/getVideosLiees/cplus/%s' % _id

View file

@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
# Copyright(C) 2010 Nicolas Duhamel
#
# 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.
#
# 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 General Public License for more details.
#
# 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 .video import CanalplusVideo
__all__ = ['VideoPage']
class VideoPage(BasePage):
def on_loaded(self):
pass
def get_video(self, video, quality):
if not video:
video = CanalplusVideo(self.group_dict['id'])
print quality
print video.id
for vid in self.document.getchildren():
url = None
lastest = None
for format in vid[5][1].getchildren():
if format.tag == quality:
url = format.text
if format.text:
lastest = format
if url == None:
url = lastest.text
video.url = url
return video