use URL.id2url to parse url if any, and ignore unwanted urls
This commit is contained in:
parent
686a3b77e8
commit
b4bdb1fc92
2 changed files with 10 additions and 11 deletions
|
|
@ -17,7 +17,6 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import requests
|
||||
|
||||
from weboob.tools.browser2 import PagesBrowser, URL
|
||||
from .pages import IndexPage, VideoPage
|
||||
|
|
@ -30,23 +29,23 @@ class PluzzBrowser(PagesBrowser):
|
|||
|
||||
BASEURL = 'http://pluzz.francetv.fr'
|
||||
|
||||
index_page = URL('recherche\?recherche=(?P<pattern>.*)', IndexPage)
|
||||
latest_page = URL('lesplusrecents', IndexPage)
|
||||
video_page = URL('http://webservices.francetelevisions.fr/tools/getInfosOeuvre/v2/\?idDiffusion=(?P<_id>.*)&catalogue=Pluzz', VideoPage)
|
||||
index_page = URL(r'recherche\?recherche=(?P<pattern>.*)', IndexPage)
|
||||
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):
|
||||
return self.index_page.go(pattern=pattern).iter_videos()
|
||||
|
||||
def get_video(self, _id, video=None):
|
||||
video = self.video_page.go(_id=_id).get_video(obj=video)
|
||||
@video_page.id2url
|
||||
def get_video(self, url, video=None):
|
||||
self.location(url)
|
||||
video = self.page.get_video(obj=video)
|
||||
for item in self.read_url(video.url):
|
||||
pass
|
||||
|
||||
video.url = u'%s' % item
|
||||
video.url = u'%s' % item
|
||||
return video
|
||||
|
||||
def read_url(self, url):
|
||||
r = requests.get(url, stream=True)
|
||||
r = self.open(url, stream=True)
|
||||
buf = r.iter_lines()
|
||||
r.close()
|
||||
return buf
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class VideoPage(JsonPage):
|
|||
|
||||
self.env['url'] = video['url']
|
||||
|
||||
obj_id = Env('_id')
|
||||
obj_id = Env('id')
|
||||
obj_title = Format(u'%s - %s', Dict('titre'), Dict('sous_titre'))
|
||||
obj_url = Env('url')
|
||||
obj_date = DateTime(Dict('diffusion/date_debut'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue