tf1.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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|www|lci)\.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. 'url': 'http://www.tf1.fr/tf1/koh-lanta/videos/replay-koh-lanta-22-mai-2015.html',
  34. 'only_matching': True,
  35. }, {
  36. 'url': 'http://lci.tf1.fr/sept-a-huit/videos/sept-a-huit-du-24-mai-2015-8611550.html',
  37. 'only_matching': True,
  38. }]
  39. def _real_extract(self, url):
  40. video_id = self._match_id(url)
  41. webpage = self._download_webpage(url, video_id)
  42. embed_url = self._html_search_regex(
  43. r'["\'](https?://www.wat.tv/embedframe/.*?)["\']', webpage, 'embed url')
  44. embed_page = self._download_webpage(embed_url, video_id,
  45. 'Downloading embed player page')
  46. wat_id = self._search_regex(r'UVID=(.*?)&', embed_page, 'wat id')
  47. wat_info = self._download_json(
  48. 'http://www.wat.tv/interface/contentv3/%s' % wat_id, video_id)
  49. return self.url_result(wat_info['media']['url'], 'Wat')