logo

youtube-dl

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

myvideoge.py (3513B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. clean_html,
  7. get_element_by_id,
  8. get_element_by_class,
  9. int_or_none,
  10. js_to_json,
  11. MONTH_NAMES,
  12. qualities,
  13. unified_strdate,
  14. )
  15. class MyVideoGeIE(InfoExtractor):
  16. _VALID_URL = r'https?://(?:www\.)?myvideo\.ge/v/(?P<id>[0-9]+)'
  17. _TEST = {
  18. 'url': 'https://www.myvideo.ge/v/3941048',
  19. 'md5': '8c192a7d2b15454ba4f29dc9c9a52ea9',
  20. 'info_dict': {
  21. 'id': '3941048',
  22. 'ext': 'mp4',
  23. 'title': 'The best prikol',
  24. 'upload_date': '20200611',
  25. 'thumbnail': r're:^https?://.*\.jpg$',
  26. 'uploader': 'chixa33',
  27. 'description': 'md5:5b067801318e33c2e6eea4ab90b1fdd3',
  28. },
  29. # working from local dev system
  30. 'skip': 'site blocks CI servers',
  31. }
  32. _MONTH_NAMES_KA = ['იანვარი', 'თებერვალი', 'მარტი', 'აპრილი', 'მაისი', 'ივნისი', 'ივლისი', 'აგვისტო', 'სექტემბერი', 'ოქტომბერი', 'ნოემბერი', 'დეკემბერი']
  33. _quality = staticmethod(qualities(('SD', 'HD')))
  34. def _real_extract(self, url):
  35. video_id = self._match_id(url)
  36. webpage = self._download_webpage(url, video_id)
  37. title = (
  38. self._og_search_title(webpage, default=None)
  39. or clean_html(get_element_by_class('my_video_title', webpage))
  40. or self._html_search_regex(r'<title\b[^>]*>([^<]+)</title\b', webpage, 'title'))
  41. jwplayer_sources = self._parse_json(
  42. self._search_regex(
  43. r'''(?s)jwplayer\s*\(\s*['"]mvplayer['"]\s*\)\s*\.\s*setup\s*\(.*?\bsources\s*:\s*(\[.*?])\s*[,});]''', webpage, 'jwplayer sources', fatal=False)
  44. or '',
  45. video_id, transform_source=js_to_json, fatal=False)
  46. formats = self._parse_jwplayer_formats(jwplayer_sources or [], video_id)
  47. for f in formats or []:
  48. f['preference'] = self._quality(f['format_id'])
  49. self._sort_formats(formats)
  50. description = (
  51. self._og_search_description(webpage)
  52. or get_element_by_id('long_desc_holder', webpage)
  53. or self._html_search_meta('description', webpage))
  54. uploader = self._search_regex(r'<a[^>]+class="mv_user_name"[^>]*>([^<]+)<', webpage, 'uploader', fatal=False)
  55. upload_date = get_element_by_class('mv_vid_upl_date', webpage)
  56. # as ka locale may not be present roll a local date conversion
  57. upload_date = (unified_strdate(
  58. # translate any ka month to an en one
  59. re.sub('|'.join(self._MONTH_NAMES_KA),
  60. lambda m: MONTH_NAMES['en'][self._MONTH_NAMES_KA.index(m.group(0))],
  61. upload_date, re.I))
  62. if upload_date else None)
  63. return {
  64. 'id': video_id,
  65. 'title': title,
  66. 'description': description,
  67. 'uploader': uploader,
  68. 'formats': formats,
  69. 'thumbnail': self._og_search_thumbnail(webpage),
  70. 'upload_date': upload_date,
  71. 'view_count': int_or_none(get_element_by_class('mv_vid_views', webpage)),
  72. 'like_count': int_or_none(get_element_by_id('likes_count', webpage)),
  73. 'dislike_count': int_or_none(get_element_by_id('dislikes_count', webpage)),
  74. }