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.

50 lines
2.1 KiB

11 years ago
11 years ago
11 years ago
10 years ago
10 years ago
11 years ago
11 years ago
11 years ago
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. class TF1IE(InfoExtractor):
  5. """TF1 uses the wat.tv player."""
  6. _VALID_URL = r'http://(?:videos\.tf1|www\.tfou|www\.tf1)\.fr/.*?-(?P<id>\d+)(?:-\d+)?\.html'
  7. _TESTS = [{
  8. 'url': 'http://videos.tf1.fr/auto-moto/citroen-grand-c4-picasso-2013-presentation-officielle-8062060.html',
  9. 'info_dict': {
  10. 'id': '10635995',
  11. 'ext': 'mp4',
  12. 'title': 'Citroën Grand C4 Picasso 2013 : présentation officielle',
  13. 'description': 'Vidéo officielle du nouveau Citroën Grand C4 Picasso, lancé à l\'automne 2013.',
  14. },
  15. 'params': {
  16. # Sometimes wat serves the whole file with the --test option
  17. 'skip_download': True,
  18. },
  19. }, {
  20. 'url': 'http://www.tfou.fr/chuggington/videos/le-grand-mysterioso-chuggington-7085291-739.html',
  21. 'info_dict': {
  22. 'id': '12043945',
  23. 'ext': 'mp4',
  24. 'title': 'Le grand Mystérioso - Chuggington',
  25. 'description': 'Le grand Mystérioso - Emery rêve qu\'un article lui soit consacré dans le journal.',
  26. 'upload_date': '20150103',
  27. },
  28. 'params': {
  29. # Sometimes wat serves the whole file with the --test option
  30. 'skip_download': True,
  31. },
  32. }, {
  33. 'url': 'http://www.tf1.fr/tf1/koh-lanta/videos/replay-koh-lanta-22-mai-2015.html',
  34. 'only_matching': True,
  35. }]
  36. def _real_extract(self, url):
  37. video_id = self._match_id(url)
  38. webpage = self._download_webpage(url, video_id)
  39. embed_url = self._html_search_regex(
  40. r'["\'](https?://www.wat.tv/embedframe/.*?)["\']', webpage, 'embed url')
  41. embed_page = self._download_webpage(embed_url, video_id,
  42. 'Downloading embed player page')
  43. wat_id = self._search_regex(r'UVID=(.*?)&', embed_page, 'wat id')
  44. wat_info = self._download_json(
  45. 'http://www.wat.tv/interface/contentv3/%s' % wat_id, video_id)
  46. return self.url_result(wat_info['media']['url'], 'Wat')