You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.4 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. class TF1IE(InfoExtractor):
  6. """TF1 uses the wat.tv player."""
  7. _VALID_URL = r'http://videos\.tf1\.fr/.*-(?P<id>.*?)\.html'
  8. _TEST = {
  9. 'url': 'http://videos.tf1.fr/auto-moto/citroen-grand-c4-picasso-2013-presentation-officielle-8062060.html',
  10. 'info_dict': {
  11. 'id': '10635995',
  12. 'ext': 'mp4',
  13. 'title': 'Citroën Grand C4 Picasso 2013 : présentation officielle',
  14. 'description': 'Vidéo officielle du nouveau Citroën Grand C4 Picasso, lancé à l\'automne 2013.',
  15. },
  16. 'params': {
  17. # Sometimes wat serves the whole file with the --test option
  18. 'skip_download': True,
  19. },
  20. }
  21. def _real_extract(self, url):
  22. mobj = re.match(self._VALID_URL, url)
  23. video_id = mobj.group('id')
  24. webpage = self._download_webpage(url, video_id)
  25. embed_url = self._html_search_regex(
  26. r'"(https://www.wat.tv/embedframe/.*?)"', webpage, 'embed url')
  27. embed_page = self._download_webpage(embed_url, video_id,
  28. 'Downloading embed player page')
  29. wat_id = self._search_regex(r'UVID=(.*?)&', embed_page, 'wat id')
  30. wat_info = self._download_json(
  31. 'http://www.wat.tv/interface/contentv3/%s' % wat_id, video_id)
  32. return self.url_result(wat_info['media']['url'], 'Wat')