From 9d17948b5a1cc48bd526b1163292415577131c31 Mon Sep 17 00:00:00 2001 From: dirkf Date: Thu, 2 Feb 2023 23:25:44 +0000 Subject: [PATCH] [myvideoge] Add new extractor (#31360) NB download tests on CI servers blocked Co-authored-by: Alfonso Solbes --- youtube_dl/extractor/extractors.py | 1 + youtube_dl/extractor/myvideoge.py | 87 ++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 youtube_dl/extractor/myvideoge.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 31a3e588e..96b27b179 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -728,6 +728,7 @@ from .myvi import ( MyviIE, MyviEmbedIE, ) +from .myvideoge import MyVideoGeIE from .myvidster import MyVidsterIE from .nationalgeographic import ( NationalGeographicVideoIE, diff --git a/youtube_dl/extractor/myvideoge.py b/youtube_dl/extractor/myvideoge.py new file mode 100644 index 000000000..efbfda7a6 --- /dev/null +++ b/youtube_dl/extractor/myvideoge.py @@ -0,0 +1,87 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import re + +from .common import InfoExtractor +from ..utils import ( + clean_html, + get_element_by_id, + get_element_by_class, + int_or_none, + js_to_json, + MONTH_NAMES, + qualities, + unified_strdate, +) + + +class MyVideoGeIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?myvideo\.ge/v/(?P[0-9]+)' + _TEST = { + 'url': 'https://www.myvideo.ge/v/3941048', + 'md5': '8c192a7d2b15454ba4f29dc9c9a52ea9', + 'info_dict': { + 'id': '3941048', + 'ext': 'mp4', + 'title': 'The best prikol', + 'upload_date': '20200611', + 'thumbnail': r're:^https?://.*\.jpg$', + 'uploader': 'chixa33', + 'description': 'md5:5b067801318e33c2e6eea4ab90b1fdd3', + }, + # working from local dev system + 'skip': 'site blocks CI servers', + } + _MONTH_NAMES_KA = ['იანვარი', 'თებერვალი', 'მარტი', 'აპრილი', 'მაისი', 'ივნისი', 'ივლისი', 'აგვისტო', 'სექტემბერი', 'ოქტომბერი', 'ნოემბერი', 'დეკემბერი'] + + _quality = staticmethod(qualities(('SD', 'HD'))) + + def _real_extract(self, url): + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + + title = ( + self._og_search_title(webpage, default=None) + or clean_html(get_element_by_class('my_video_title', webpage)) + or self._html_search_regex(r']*>([^<]+)]+class="mv_user_name"[^>]*>([^<]+)<', webpage, 'uploader', fatal=False) + + upload_date = get_element_by_class('mv_vid_upl_date', webpage) + # as ka locale may not be present roll a local date conversion + upload_date = (unified_strdate( + # translate any ka month to an en one + re.sub('|'.join(self._MONTH_NAMES_KA), + lambda m: MONTH_NAMES['en'][self._MONTH_NAMES_KA.index(m.group(0))], + upload_date, re.I)) + if upload_date else None) + + return { + 'id': video_id, + 'title': title, + 'description': description, + 'uploader': uploader, + 'formats': formats, + 'thumbnail': self._og_search_thumbnail(webpage), + 'upload_date': upload_date, + 'view_count': int_or_none(get_element_by_class('mv_vid_views', webpage)), + 'like_count': int_or_none(get_element_by_id('likes_count', webpage)), + 'dislike_count': int_or_none(get_element_by_id('dislikes_count', webpage)), + } -- 2.22.2