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.

74 lines
2.4 KiB

11 years ago
11 years ago
11 years ago
10 years ago
11 years ago
10 years ago
11 years ago
11 years ago
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. determine_ext,
  6. js_to_json,
  7. )
  8. class LA7IE(InfoExtractor):
  9. IE_NAME = 'la7.it'
  10. _VALID_URL = r'''(?x)(https?://)?(?:
  11. (?:www\.)?la7\.it/([^/]+)/(?:rivedila7|video)/|
  12. tg\.la7\.it/repliche-tgla7\?id=
  13. )(?P<id>.+)'''
  14. _TESTS = [{
  15. # 'src' is a plain URL
  16. 'url': 'http://www.la7.it/crozza/video/inccool8-02-10-2015-163722',
  17. 'md5': '6054674766e7988d3e02f2148ff92180',
  18. 'info_dict': {
  19. 'id': 'inccool8-02-10-2015-163722',
  20. 'ext': 'mp4',
  21. 'title': 'Inc.Cool8',
  22. 'description': 'Benvenuti nell\'incredibile mondo della INC. COOL. 8. dove “INC.” sta per “Incorporated” “COOL” sta per “fashion” ed Eight sta per il gesto atletico',
  23. 'thumbnail': 're:^https?://.*',
  24. },
  25. }, {
  26. # 'src' is a dictionary
  27. 'url': 'http://tg.la7.it/repliche-tgla7?id=189080',
  28. 'md5': '6b0d8888d286e39870208dfeceaf456b',
  29. 'info_dict': {
  30. 'id': '189080',
  31. 'ext': 'mp4',
  32. 'title': 'TG LA7',
  33. },
  34. }, {
  35. 'url': 'http://www.la7.it/omnibus/rivedila7/omnibus-news-02-07-2016-189077',
  36. 'only_matching': True,
  37. }]
  38. def _real_extract(self, url):
  39. video_id = self._match_id(url)
  40. webpage = self._download_webpage(url, video_id)
  41. player_data = self._parse_json(
  42. self._search_regex(r'videoLa7\(({[^;]+})\);', webpage, 'player data'),
  43. video_id, transform_source=js_to_json)
  44. source = player_data['src']
  45. source_urls = source.values() if isinstance(source, dict) else [source]
  46. formats = []
  47. for source_url in source_urls:
  48. ext = determine_ext(source_url)
  49. if ext == 'm3u8':
  50. formats.extend(self._extract_m3u8_formats(
  51. source_url, video_id, ext='mp4',
  52. entry_protocol='m3u8_native', m3u8_id='hls'))
  53. else:
  54. formats.append({
  55. 'url': source_url,
  56. })
  57. self._sort_formats(formats)
  58. return {
  59. 'id': video_id,
  60. 'title': player_data['title'],
  61. 'description': self._og_search_description(webpage, default=None),
  62. 'thumbnail': player_data.get('poster'),
  63. 'formats': formats,
  64. }