tf1.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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|www\.tfou)\.fr/.*?-(?P<id>\d+)(?:-\d+)?\.html'
  8. _TESTS = {
  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. 'url': 'http://www.tfou.fr/chuggington/videos/le-grand-mysterioso-chuggington-7085291-739.html',
  22. 'info_dict': {
  23. 'id': '12043945',
  24. 'ext': 'mp4',
  25. 'title': 'Le grand Mystérioso - Chuggington',
  26. 'description': 'Le grand Mystérioso - Emery rêve qu\'un article lui soit consacré dans le journal.',
  27. 'upload_date': '20150103',
  28. },
  29. 'params': {
  30. # Sometimes wat serves the whole file with the --test option
  31. 'skip_download': True,
  32. },
  33. }
  34. def _real_extract(self, url):
  35. video_id = self._match_id(url)
  36. webpage = self._download_webpage(url, video_id)
  37. embed_url = self._html_search_regex(
  38. r'["\'](https?://www.wat.tv/embedframe/.*?)["\']', webpage, 'embed url')
  39. embed_page = self._download_webpage(embed_url, video_id,
  40. 'Downloading embed player page')
  41. wat_id = self._search_regex(r'UVID=(.*?)&', embed_page, 'wat id')
  42. wat_info = self._download_json(
  43. 'http://www.wat.tv/interface/contentv3/%s' % wat_id, video_id)
  44. return self.url_result(wat_info['media']['url'], 'Wat')