47 lines
2.0 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)\.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. def _real_extract(self, url):
  34. video_id = self._match_id(url)
  35. webpage = self._download_webpage(url, video_id)
  36. embed_url = self._html_search_regex(
  37. r'["\'](https?://www.wat.tv/embedframe/.*?)["\']', webpage, 'embed url')
  38. embed_page = self._download_webpage(embed_url, video_id,
  39. 'Downloading embed player page')
  40. wat_id = self._search_regex(r'UVID=(.*?)&', embed_page, 'wat id')
  41. wat_info = self._download_json(
  42. 'http://www.wat.tv/interface/contentv3/%s' % wat_id, video_id)
  43. return self.url_result(wat_info['media']['url'], 'Wat')