From 92b6dc13f3452be1acb57a61c61537a149ff1ea1 Mon Sep 17 00:00:00 2001 From: Alfonso Solbes Date: Sat, 8 Aug 2020 13:24:02 +0200 Subject: [PATCH] [MyVideoGe] add new extractor --- youtube_dl/extractor/extractors.py | 1 + youtube_dl/extractor/myvideoge.py | 56 ++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 youtube_dl/extractor/myvideoge.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 4b3092028..1da2c55a1 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -667,6 +667,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..0a1d7d0cb --- /dev/null +++ b/youtube_dl/extractor/myvideoge.py @@ -0,0 +1,56 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor +from ..utils import js_to_json + + +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', + 'thumbnail': r're:^https?://.*\.jpg$', + 'uploader': 'md5:d72addd357b0dd914e704781f7f777d8', + 'description': 'md5:5c0371f540f5888d603ebfedd46b6df3' + } + } + + def _real_extract(self, url): + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + + title = self._html_search_regex(r']*>([^<]+)', webpage, 'title') + description = self._og_search_description(webpage) + thumbnail = self._html_search_meta(['og:image'], webpage) + uploader = self._search_regex(r']+class="mv_user_name"[^>]*>([^<]+)<', webpage, 'uploader', fatal=False) + + jwplayer_sources = self._parse_json( + self._search_regex( + r"(?s)jwplayer\(\"mvplayer\"\).setup\(.*?sources: (.*?])", webpage, 'jwplayer sources'), + video_id, transform_source=js_to_json) + + def _formats_key(f): + if f['label'] == 'SD': + return -1 + elif f['label'] == 'HD': + return 1 + else: + return 0 + + jwplayer_sources = sorted(jwplayer_sources, key=_formats_key) + + formats = self._parse_jwplayer_formats(jwplayer_sources, video_id) + + return { + 'id': video_id, + 'title': title, + 'description': description, + 'uploader': uploader, + 'formats': formats, + 'thumbnail': thumbnail + }