logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

la7.py (2264B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. js_to_json,
  6. smuggle_url,
  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': '8b613ffc0c4bf9b9e377169fc19c214c',
  18. 'info_dict': {
  19. 'id': '0_42j6wd36',
  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. 'uploader_id': 'kdla7pillole@iltrovatore.it',
  25. 'timestamp': 1443814869,
  26. 'upload_date': '20151002',
  27. },
  28. }, {
  29. # 'src' is a dictionary
  30. 'url': 'http://tg.la7.it/repliche-tgla7?id=189080',
  31. 'md5': '6b0d8888d286e39870208dfeceaf456b',
  32. 'info_dict': {
  33. 'id': '189080',
  34. 'ext': 'mp4',
  35. 'title': 'TG LA7',
  36. },
  37. }, {
  38. 'url': 'http://www.la7.it/omnibus/rivedila7/omnibus-news-02-07-2016-189077',
  39. 'only_matching': True,
  40. }]
  41. def _real_extract(self, url):
  42. video_id = self._match_id(url)
  43. webpage = self._download_webpage(url, video_id)
  44. player_data = self._parse_json(
  45. self._search_regex(
  46. [r'(?s)videoParams\s*=\s*({.+?});', r'videoLa7\(({[^;]+})\);'],
  47. webpage, 'player data'),
  48. video_id, transform_source=js_to_json)
  49. return {
  50. '_type': 'url_transparent',
  51. 'url': smuggle_url('kaltura:103:%s' % player_data['vid'], {
  52. 'service_url': 'http://nkdam.iltrovatore.it',
  53. }),
  54. 'id': video_id,
  55. 'title': player_data['title'],
  56. 'description': self._og_search_description(webpage, default=None),
  57. 'thumbnail': player_data.get('poster'),
  58. 'ie_key': 'Kaltura',
  59. }