From 4349c07dd7cd07620365b36093f0a148c41ce434 Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Thu, 4 Dec 2014 17:02:05 +0100 Subject: [minhateca] Add extractor (Fixes #4094) --- youtube_dl/extractor/minhateca.py | 71 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 youtube_dl/extractor/minhateca.py (limited to 'youtube_dl/extractor/minhateca.py') diff --git a/youtube_dl/extractor/minhateca.py b/youtube_dl/extractor/minhateca.py new file mode 100644 index 000000000..077c9b19d --- /dev/null +++ b/youtube_dl/extractor/minhateca.py @@ -0,0 +1,71 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor +from ..compat import ( + compat_urllib_parse, + compat_urllib_request, +) +from ..utils import ( + int_or_none, + parse_filesize, +) + + +class MinhatecaIE(InfoExtractor): + _VALID_URL = r'https?://minhateca\.com\.br/[^?#]+,(?P[0-9]+)\.' + _TEST = { + 'url': 'http://minhateca.com.br/pereba/misc/youtube-dl+test+video,125848331.mp4(video)', + 'info_dict': { + 'id': '125848331', + 'ext': 'mp4', + 'title': 'youtube-dl test video', + 'thumbnail': 're:^https?://.*\.jpg$', + 'filesize_approx': 1530000, + 'duration': 9, + 'view_count': int, + } + } + + def _real_extract(self, url): + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + + token = self._html_search_regex( + r'(.*?)', webpage, 'title') + title, _, ext = title_str.rpartition('.') + filesize_approx = parse_filesize(self._html_search_regex( + r'

(.*?)

', + webpage, 'file size approximation', fatal=False)) + duration = int_or_none(self._html_search_regex( + r'(?s)

.*?([0-9]+)\s*s', + webpage, 'duration', fatal=False)) + view_count = int_or_none(self._html_search_regex( + r'

([0-9]+)

', + webpage, 'view count', fatal=False)) + + return { + 'id': video_id, + 'url': video_url, + 'title': title, + 'ext': ext, + 'filesize_approx': filesize_approx, + 'duration': duration, + 'view_count': view_count, + 'thumbnail': self._og_search_thumbnail(webpage), + } -- cgit v1.2.3