diff options
author | Unknown <blackjack4494@web.de> | 2020-09-02 23:33:41 +0200 |
---|---|---|
committer | Unknown <blackjack4494@web.de> | 2020-09-02 23:33:41 +0200 |
commit | 3ca3f77f9ce9dd504dc6af4ef605c245c31ff860 (patch) | |
tree | 6bd9c9352327148a78b8c46227c8d526f1447b03 /youtube_dl/extractor/foxgay.py | |
parent | 4cd6add62b54721eeb3bf76bd9c0b4d676dc4d68 (diff) | |
download | hypervideo-pre-3ca3f77f9ce9dd504dc6af4ef605c245c31ff860.tar.lz hypervideo-pre-3ca3f77f9ce9dd504dc6af4ef605c245c31ff860.tar.xz hypervideo-pre-3ca3f77f9ce9dd504dc6af4ef605c245c31ff860.zip |
[skip travis] adding automerge support
basically copying content of youtube_dl folder to youtube_dlc and excluding the youtube_dl folder when compiling
Diffstat (limited to 'youtube_dl/extractor/foxgay.py')
-rw-r--r-- | youtube_dl/extractor/foxgay.py | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/youtube_dl/extractor/foxgay.py b/youtube_dl/extractor/foxgay.py new file mode 100644 index 000000000..512a10645 --- /dev/null +++ b/youtube_dl/extractor/foxgay.py @@ -0,0 +1,63 @@ +from __future__ import unicode_literals + +import itertools + +from .common import InfoExtractor +from ..utils import ( + get_element_by_id, + int_or_none, + remove_end, +) + + +class FoxgayIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?foxgay\.com/videos/(?:\S+-)?(?P<id>\d+)\.shtml' + _TEST = { + 'url': 'http://foxgay.com/videos/fuck-turkish-style-2582.shtml', + 'md5': '344558ccfea74d33b7adbce22e577f54', + 'info_dict': { + 'id': '2582', + 'ext': 'mp4', + 'title': 'Fuck Turkish-style', + 'description': 'md5:6ae2d9486921891efe89231ace13ffdf', + 'age_limit': 18, + 'thumbnail': r're:https?://.*\.jpg$', + }, + } + + def _real_extract(self, url): + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + + title = remove_end(self._html_search_regex( + r'<title>([^<]+)</title>', webpage, 'title'), ' - Foxgay.com') + description = get_element_by_id('inf_tit', webpage) + + # The default user-agent with foxgay cookies leads to pages without videos + self._downloader.cookiejar.clear('.foxgay.com') + # Find the URL for the iFrame which contains the actual video. + iframe_url = self._html_search_regex( + r'<iframe[^>]+src=([\'"])(?P<url>[^\'"]+)\1', webpage, + 'video frame', group='url') + iframe = self._download_webpage( + iframe_url, video_id, headers={'User-Agent': 'curl/7.50.1'}, + note='Downloading video frame') + video_data = self._parse_json(self._search_regex( + r'video_data\s*=\s*([^;]+);', iframe, 'video data'), video_id) + + formats = [{ + 'url': source, + 'height': int_or_none(resolution), + } for source, resolution in zip( + video_data['sources'], video_data.get('resolutions', itertools.repeat(None)))] + + self._sort_formats(formats) + + return { + 'id': video_id, + 'title': title, + 'formats': formats, + 'description': description, + 'thumbnail': video_data.get('act_vid', {}).get('thumb'), + 'age_limit': 18, + } |