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.

64 lines
2.3 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import unified_timestamp
  5. class InternazionaleIE(InfoExtractor):
  6. _VALID_URL = r'https?://(?:www\.)?internazionale\.it/video/(?:[^/]+/)*(?P<id>[^/?#&]+)'
  7. _TEST = {
  8. 'url': 'https://www.internazionale.it/video/2015/02/19/richard-linklater-racconta-una-scena-di-boyhood',
  9. 'md5': '3e39d32b66882c1218e305acbf8348ca',
  10. 'info_dict': {
  11. 'id': '265968',
  12. 'display_id': 'richard-linklater-racconta-una-scena-di-boyhood',
  13. 'ext': 'mp4',
  14. 'title': 'Richard Linklater racconta una scena di Boyhood',
  15. 'description': 'md5:efb7e5bbfb1a54ae2ed5a4a015f0e665',
  16. 'timestamp': 1424354635,
  17. 'upload_date': '20150219',
  18. 'thumbnail': r're:^https?://.*\.jpg$',
  19. },
  20. 'params': {
  21. 'format': 'bestvideo',
  22. },
  23. }
  24. def _real_extract(self, url):
  25. display_id = self._match_id(url)
  26. webpage = self._download_webpage(url, display_id)
  27. DATA_RE = r'data-%s=(["\'])(?P<value>(?:(?!\1).)+)\1'
  28. title = self._search_regex(
  29. DATA_RE % 'video-title', webpage, 'title', default=None,
  30. group='value') or self._og_search_title(webpage)
  31. video_id = self._search_regex(
  32. DATA_RE % 'job-id', webpage, 'video id', group='value')
  33. video_path = self._search_regex(
  34. DATA_RE % 'video-path', webpage, 'video path', group='value')
  35. video_base = 'https://video.internazionale.it/%s/%s.' % (video_path, video_id)
  36. formats = self._extract_m3u8_formats(
  37. video_base + 'm3u8', display_id, 'mp4',
  38. entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)
  39. formats.extend(self._extract_mpd_formats(
  40. video_base + 'mpd', display_id, mpd_id='dash', fatal=False))
  41. self._sort_formats(formats)
  42. timestamp = unified_timestamp(self._html_search_meta(
  43. 'article:published_time', webpage, 'timestamp'))
  44. return {
  45. 'id': video_id,
  46. 'display_id': display_id,
  47. 'title': title,
  48. 'thumbnail': self._og_search_thumbnail(webpage),
  49. 'description': self._og_search_description(webpage),
  50. 'timestamp': timestamp,
  51. 'formats': formats,
  52. }