From da04fecf3c31772b63dffb4a2627ce2d29ae5adb Mon Sep 17 00:00:00 2001 From: Surya Oktafendri Date: Tue, 27 Mar 2018 13:11:58 +0700 Subject: [PATCH] [Metube] Add a new extractor for metube.id --- youtube_dl/extractor/extractors.py | 1 + youtube_dl/extractor/metube.py | 45 ++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 youtube_dl/extractor/metube.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index de48a37ad..c2dd69ab5 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -596,6 +596,7 @@ from .melonvod import MelonVODIE from .meta import METAIE from .metacafe import MetacafeIE from .metacritic import MetacriticIE +from .metube import MetubeIE from .mgoon import MgoonIE from .mgtv import MGTVIE from .miaopai import MiaoPaiIE diff --git a/youtube_dl/extractor/metube.py b/youtube_dl/extractor/metube.py new file mode 100644 index 000000000..e81d93cb8 --- /dev/null +++ b/youtube_dl/extractor/metube.py @@ -0,0 +1,45 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import re + +from .common import InfoExtractor + + +class MetubeIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?metube\.id/videos/(?P\d+)/(?P[^/?#&]+)' + _TEST = { + 'url': 'https://www.metube.id/videos/15090866/dragon-ball-super-eps-131', + 'info_dict': { + 'id': '15090866', + 'slug': 'dragon-ball-super-eps-131', + 'ext': 'm3u8', + 'title': 'Dragon Ball Super Eps.131', + 'description': 'md5:dc4bfa9274e3db15392bfce045964331', + 'thumbnail': r're:^https?://.*\.jpg$', + }, + } + + def _real_extract(self, url): + mobj = re.match(self._VALID_URL, url) + video_id, slug = mobj.group('id', 'slug') + + webpage = self._download_webpage(url, video_id) + title = self._og_search_title(webpage) + description = self._og_search_description(webpage) + thumbnail = self._og_search_property('image', webpage) + m3u8_url = self._html_search_regex( + r'''jwplayer\s*\(\s*["'][^'"]+["']\s*\)\s*\.setup.*?['"]?file['"]?\s*:\s*["\'](.*?)["\']''', + webpage, 'm3u8_url', default='{}', fatal=False) + formats = self._extract_m3u8_formats( + m3u8_url, video_id, 'm3u8', entry_protocol='m3u8_native') + self._sort_formats(formats) + + return { + 'id': video_id, + 'slug': slug, + 'title': title, + 'description': description, + 'thumbnail': thumbnail, + 'formats': formats + }