logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

lnk.py (3377B)


  1. from .common import InfoExtractor
  2. from ..utils import (
  3. format_field,
  4. int_or_none,
  5. unified_strdate,
  6. )
  7. class LnkIE(InfoExtractor):
  8. _VALID_URL = r'https?://(?:www\.)?lnk\.lt/[^/]+/(?P<id>\d+)'
  9. _TESTS = [{
  10. 'url': 'https://lnk.lt/zinios/79791',
  11. 'info_dict': {
  12. 'id': '79791',
  13. 'ext': 'mp4',
  14. 'title': 'LNK.lt: Viešintų gyventojai sukilo prieš radijo bangų siųstuvą',
  15. 'description': 'Svarbiausios naujienos trumpai, LNK žinios ir Info dienos pokalbiai.',
  16. 'view_count': int,
  17. 'duration': 233,
  18. 'upload_date': '20191123',
  19. 'thumbnail': r're:^https?://.*\.jpg$',
  20. 'episode_number': 13431,
  21. 'series': 'Naujausi žinių reportažai',
  22. 'episode': 'Episode 13431',
  23. },
  24. 'params': {'skip_download': True},
  25. }, {
  26. 'url': 'https://lnk.lt/istorijos-trumpai/152546',
  27. 'info_dict': {
  28. 'id': '152546',
  29. 'ext': 'mp4',
  30. 'title': 'Radžio koncertas gaisre ',
  31. 'description': 'md5:0666b5b85cb9fc7c1238dec96f71faba',
  32. 'view_count': int,
  33. 'duration': 54,
  34. 'upload_date': '20220105',
  35. 'thumbnail': r're:^https?://.*\.jpg$',
  36. 'episode_number': 1036,
  37. 'series': 'Istorijos trumpai',
  38. 'episode': 'Episode 1036',
  39. },
  40. 'params': {'skip_download': True},
  41. }, {
  42. 'url': 'https://lnk.lt/gyvunu-pasaulis/151549',
  43. 'info_dict': {
  44. 'id': '151549',
  45. 'ext': 'mp4',
  46. 'title': 'Gyvūnų pasaulis',
  47. 'description': '',
  48. 'view_count': int,
  49. 'duration': 1264,
  50. 'upload_date': '20220108',
  51. 'thumbnail': r're:^https?://.*\.jpg$',
  52. 'episode_number': 16,
  53. 'series': 'Gyvūnų pasaulis',
  54. 'episode': 'Episode 16',
  55. },
  56. 'params': {'skip_download': True},
  57. }]
  58. def _real_extract(self, url):
  59. video_id = self._match_id(url)
  60. video_json = self._download_json(f'https://lnk.lt/api/video/video-config/{video_id}', video_id)['videoInfo']
  61. formats, subtitles = [], {}
  62. if video_json.get('videoUrl'):
  63. fmts, subs = self._extract_m3u8_formats_and_subtitles(video_json['videoUrl'], video_id)
  64. formats.extend(fmts)
  65. subtitles = self._merge_subtitles(subtitles, subs)
  66. if video_json.get('videoFairplayUrl') and not video_json.get('drm'):
  67. fmts, subs = self._extract_m3u8_formats_and_subtitles(video_json['videoFairplayUrl'], video_id)
  68. formats.extend(fmts)
  69. subtitles = self._merge_subtitles(subtitles, subs)
  70. return {
  71. 'id': video_id,
  72. 'title': video_json.get('title'),
  73. 'description': video_json.get('description'),
  74. 'view_count': video_json.get('viewsCount'),
  75. 'duration': video_json.get('duration'),
  76. 'upload_date': unified_strdate(video_json.get('airDate')),
  77. 'thumbnail': format_field(video_json, 'posterImage', 'https://lnk.lt/all-images/%s'),
  78. 'episode_number': int_or_none(video_json.get('episodeNumber')),
  79. 'series': video_json.get('programTitle'),
  80. 'formats': formats,
  81. 'subtitles': subtitles,
  82. }