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.

116 lines
3.8 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': r'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': r're:^https?://.*\.jpg$'
  37. },
  38. 'params': {
  39. 'skip_download': True, # HLS download
  40. },
  41. }, {
  42. 'url': 'http://www.lnkgo.lt/visi-video/aktualai-pratesimas/ziurek-putka-trys-klausimai',
  43. 'only_matching': True,
  44. }]
  45. _AGE_LIMITS = {
  46. 'N-7': 7,
  47. 'N-14': 14,
  48. 'S': 18,
  49. }
  50. def _real_extract(self, url):
  51. display_id = self._match_id(url)
  52. webpage = self._download_webpage(
  53. url, display_id, 'Downloading player webpage')
  54. video_id = self._search_regex(
  55. r'data-ep="([^"]+)"', webpage, 'video ID')
  56. title = self._og_search_title(webpage)
  57. description = self._og_search_description(webpage)
  58. upload_date = unified_strdate(self._search_regex(
  59. r'class="[^"]*meta-item[^"]*air-time[^"]*">.*?<strong>([^<]+)</strong>', webpage, 'upload date', fatal=False))
  60. thumbnail_w = int_or_none(
  61. self._og_search_property('image:width', webpage, 'thumbnail width', fatal=False))
  62. thumbnail_h = int_or_none(
  63. self._og_search_property('image:height', webpage, 'thumbnail height', fatal=False))
  64. thumbnail = {
  65. 'url': self._og_search_thumbnail(webpage),
  66. }
  67. if thumbnail_w and thumbnail_h:
  68. thumbnail.update({
  69. 'width': thumbnail_w,
  70. 'height': thumbnail_h,
  71. })
  72. config = self._parse_json(self._search_regex(
  73. r'episodePlayer\((\{.*?\}),\s*\{', webpage, 'sources'), video_id)
  74. if config.get('pGeo'):
  75. self.report_warning(
  76. 'This content might not be available in your country due to copyright reasons')
  77. formats = [{
  78. 'format_id': 'hls',
  79. 'ext': 'mp4',
  80. 'url': config['EpisodeVideoLink_HLS'],
  81. }]
  82. m = re.search(r'^(?P<url>rtmp://[^/]+/(?P<app>[^/]+))/(?P<play_path>.+)$', config['EpisodeVideoLink'])
  83. if m:
  84. formats.append({
  85. 'format_id': 'rtmp',
  86. 'ext': 'flv',
  87. 'url': m.group('url'),
  88. 'play_path': m.group('play_path'),
  89. 'page_url': url,
  90. })
  91. self._sort_formats(formats)
  92. return {
  93. 'id': video_id,
  94. 'display_id': display_id,
  95. 'title': title,
  96. 'formats': formats,
  97. 'thumbnails': [thumbnail],
  98. 'duration': int_or_none(config.get('VideoTime')),
  99. 'description': description,
  100. 'age_limit': self._AGE_LIMITS.get(config.get('PGRating'), 0),
  101. 'upload_date': upload_date,
  102. }