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

vtv.py (5310B)


  1. from .common import InfoExtractor
  2. from ..utils import extract_attributes, get_element_html_by_class, remove_start
  3. class VTVGoIE(InfoExtractor):
  4. _VALID_URL = [
  5. r'https?://(?:www\.)?vtvgo\.vn/(kho-video|tin-tuc)/[\w.-]*?(?P<id>\d+)(?:\.[a-z]+|/)?(?:$|[?#])',
  6. r'https?://(?:www\.)?vtvgo\.vn/digital/detail\.php\?(?:[^#]+&)?content_id=(?P<id>\d+)',
  7. ]
  8. _TESTS = [{
  9. 'url': 'https://vtvgo.vn/kho-video/bep-vtv-vit-chao-rieng-so-24-888456.html',
  10. 'info_dict': {
  11. 'id': '888456',
  12. 'ext': 'mp4',
  13. 'title': 'Bếp VTV | Vịt chao riềng | Số 24',
  14. 'description': 'md5:2b4e93ec2b954304170d32be288ce2c8',
  15. 'thumbnail': 'https://vtvgo-images.vtvdigital.vn/images/20230201/VIT-CHAO-RIENG_VTV_638108894672812459.jpg',
  16. },
  17. }, {
  18. 'url': 'https://vtvgo.vn/tin-tuc/hot-search-1-zlife-khong-ngo-toi-phai-khong-862074',
  19. 'info_dict': {
  20. 'id': '862074',
  21. 'ext': 'mp4',
  22. 'title': 'Hot Search #1 | Zlife | Không ngờ tới phải không? ',
  23. 'description': 'md5:e967d0e2efbbebbee8814a55799b4d0f',
  24. 'thumbnail': 'https://vtvgo-images.vtvdigital.vn/images/20220504/6b9a8552-e71c-46ce-bc9d-50c9bb506f9c.jpeg',
  25. },
  26. }, {
  27. 'url': 'https://vtvgo.vn/kho-video/918311.html',
  28. 'info_dict': {
  29. 'id': '918311',
  30. 'title': 'Cà phê sáng | 05/02/2024 | Tái hiện hình ảnh Hà Nội xưa tại ngôi nhà di sản',
  31. 'ext': 'mp4',
  32. 'thumbnail': 'https://vtvgo-images.vtvdigital.vn/images/20240205/0506_ca_phe_sang_638427226021318322.jpg',
  33. 'description': 'md5:b121c67948f1ce58e6a036042fc14c1b',
  34. },
  35. }, {
  36. 'url': 'https://vtvgo.vn/digital/detail.php?digital_id=168&content_id=918634',
  37. 'info_dict': {
  38. 'id': '918634',
  39. 'ext': 'mp4',
  40. 'title': 'Gặp nhau cuối năm | Táo quân 2024',
  41. 'description': 'md5:a1c221e78e5954d29d49b2a11c20513c',
  42. 'thumbnail': 'https://vtvgo-images.vtvdigital.vn/images/20240210/d0f73369-8f03-4108-9edd-83d4bc3997b2.png',
  43. },
  44. }, {
  45. 'url': 'https://vtvgo.vn/digital/detail.php?content_id=919358',
  46. 'info_dict': {
  47. 'id': '919358',
  48. 'ext': 'mp4',
  49. 'title': 'Chúng ta của 8 năm sau | Tập 45 | Dương có bằng chứng, nhân chứng vạch mặt ông Khiêm',
  50. 'description': 'md5:16ff5208cac6585137f554472a4677f3',
  51. 'thumbnail': 'https://vtvgo-images.vtvdigital.vn/images/20240221/550deff9-7736-4a0e-8b5d-33274d97cd7d.jpg',
  52. },
  53. }, {
  54. 'url': 'https://vtvgo.vn/kho-video/888456',
  55. 'only_matching': True,
  56. }]
  57. def _real_extract(self, url):
  58. video_id = self._match_id(url)
  59. webpage = self._download_webpage(url, video_id)
  60. m3u8_url = self._search_regex(
  61. r'(?:var\s+link\s*=\s*|addPlayer\()["\'](https://[^"\']+/index\.m3u8)["\']', webpage, 'm3u8 url')
  62. return {
  63. 'id': video_id,
  64. 'title': self._og_search_title(webpage, default=None),
  65. 'description': self._og_search_description(webpage, default=None),
  66. 'thumbnail': self._og_search_thumbnail(webpage, default=None),
  67. 'formats': self._extract_m3u8_formats(m3u8_url, video_id, 'mp4'),
  68. }
  69. class VTVIE(InfoExtractor):
  70. _VALID_URL = r'https?://(?:www\.)?vtv\.vn/video/[\w-]*?(?P<id>\d+)\.htm'
  71. _TESTS = [{
  72. 'url': 'https://vtv.vn/video/thoi-su-20h-vtv1-12-6-2024-680411.htm',
  73. 'info_dict': {
  74. 'id': '680411',
  75. 'ext': 'mp4',
  76. 'title': 'Thời sự 20h VTV1 - 12/6/2024 - Video đã phát trên VTV1 | VTV.VN',
  77. 'thumbnail': 'https://cdn-images.vtv.vn/zoom/600_315/66349b6076cb4dee98746cf1/2024/06/12/thumb/1206-ts-20h-02929741475480320806760.mp4/thumb0.jpg',
  78. },
  79. }, {
  80. 'url': 'https://vtv.vn/video/zlife-1-khong-ngo-toi-phai-khong-vtv24-560248.htm',
  81. 'info_dict': {
  82. 'id': '560248',
  83. 'ext': 'mp4',
  84. 'title': 'ZLife #1: Không ngờ tới phải không? | VTV24 - Video đã phát trên VTV-NEWS | VTV.VN',
  85. 'description': 'Ai đứng sau vụ việc thay đổi ảnh đại diện trên các trang mạng xã hội của VTV Digital tối 2/5?',
  86. 'thumbnail': 'https://video-thumbs.mediacdn.vn/zoom/600_315/vtv/2022/5/13/t67s6btf3ji-16524555726231894427334.jpg',
  87. },
  88. }]
  89. def _real_extract(self, url):
  90. video_id = self._match_id(url)
  91. webpage = self._download_webpage(url, video_id)
  92. data_vid = extract_attributes(get_element_html_by_class(
  93. 'VCSortableInPreviewMode', get_element_html_by_class(
  94. 'video-highlight-box', webpage)))['data-vid']
  95. m3u8_url = f'https://cdn-videos.vtv.vn/{remove_start(data_vid, "vtv.mediacdn.vn/")}/master.m3u8'
  96. return {
  97. 'id': video_id,
  98. 'title': self._og_search_title(webpage, default=None),
  99. 'description': self._og_search_description(webpage, default=None),
  100. 'thumbnail': self._og_search_thumbnail(webpage, default=None),
  101. 'formats': self._extract_m3u8_formats(m3u8_url, video_id, 'mp4'),
  102. }