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.

113 lines
3.7 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. int_or_none,
  7. unified_strdate,
  8. )
  9. class LnkGoIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?lnkgo\.alfa\.lt/visi-video/(?P<show>[^/]+)/ziurek-(?P<id>[A-Za-z0-9-]+)'
  11. _TESTS = [{
  12. 'url': 'http://lnkgo.alfa.lt/visi-video/yra-kaip-yra/ziurek-yra-kaip-yra-162',
  13. 'info_dict': {
  14. 'id': '46712',
  15. 'ext': 'mp4',
  16. 'title': 'Yra kaip yra',
  17. 'upload_date': '20150107',
  18. 'description': 'md5:d82a5e36b775b7048617f263a0e3475e',
  19. 'age_limit': 7,
  20. 'duration': 3019,
  21. 'thumbnail': 're:^https?://.*\.jpg$'
  22. },
  23. 'params': {
  24. 'skip_download': True, # HLS download
  25. },
  26. }, {
  27. 'url': 'http://lnkgo.alfa.lt/visi-video/aktualai-pratesimas/ziurek-nerdas-taiso-kompiuteri-2',
  28. 'info_dict': {
  29. 'id': '47289',
  30. 'ext': 'mp4',
  31. 'title': 'Nėrdas: Kompiuterio Valymas',
  32. 'upload_date': '20150113',
  33. 'description': 'md5:7352d113a242a808676ff17e69db6a69',
  34. 'age_limit': 18,
  35. 'duration': 346,
  36. 'thumbnail': 're:^https?://.*\.jpg$'
  37. },
  38. 'params': {
  39. 'skip_download': True, # HLS download
  40. },
  41. }]
  42. _AGE_LIMITS = {
  43. 'N-7': 7,
  44. 'N-14': 14,
  45. 'S': 18,
  46. }
  47. def _real_extract(self, url):
  48. display_id = self._match_id(url)
  49. webpage = self._download_webpage(
  50. url, display_id, 'Downloading player webpage')
  51. video_id = self._search_regex(
  52. r'data-ep="([^"]+)"', webpage, 'video ID')
  53. title = self._og_search_title(webpage)
  54. description = self._og_search_description(webpage)
  55. upload_date = unified_strdate(self._search_regex(
  56. r'class="[^"]*meta-item[^"]*air-time[^"]*">.*?<strong>([^<]+)</strong>', webpage, 'upload date', fatal=False))
  57. thumbnail_w = int_or_none(
  58. self._og_search_property('image:width', webpage, 'thumbnail width', fatal=False))
  59. thumbnail_h = int_or_none(
  60. self._og_search_property('image:height', webpage, 'thumbnail height', fatal=False))
  61. thumbnail = {
  62. 'url': self._og_search_thumbnail(webpage),
  63. }
  64. if thumbnail_w and thumbnail_h:
  65. thumbnail.update({
  66. 'width': thumbnail_w,
  67. 'height': thumbnail_h,
  68. })
  69. config = self._parse_json(self._search_regex(
  70. r'episodePlayer\((\{.*?\}),\s*\{', webpage, 'sources'), video_id)
  71. if config.get('pGeo'):
  72. self.report_warning(
  73. 'This content might not be available in your country due to copyright reasons')
  74. formats = [{
  75. 'format_id': 'hls',
  76. 'ext': 'mp4',
  77. 'url': config['EpisodeVideoLink_HLS'],
  78. }]
  79. m = re.search(r'^(?P<url>rtmp://[^/]+/(?P<app>[^/]+))/(?P<play_path>.+)$', config['EpisodeVideoLink'])
  80. if m:
  81. formats.append({
  82. 'format_id': 'rtmp',
  83. 'ext': 'flv',
  84. 'url': m.group('url'),
  85. 'play_path': m.group('play_path'),
  86. 'page_url': url,
  87. })
  88. self._sort_formats(formats)
  89. return {
  90. 'id': video_id,
  91. 'display_id': display_id,
  92. 'title': title,
  93. 'formats': formats,
  94. 'thumbnails': [thumbnail],
  95. 'duration': int_or_none(config.get('VideoTime')),
  96. 'description': description,
  97. 'age_limit': self._AGE_LIMITS.get(config.get('PGRating'), 0),
  98. 'upload_date': upload_date,
  99. }