[foxgay] Fix extraction (closes #10480)

master
Yen Chi Hsuan 8 years ago
parent 6656a82481
commit e78a5428b6
No known key found for this signature in database
GPG Key ID: 3FDDD575826C5C30

@ -1,6 +1,7 @@
version <unreleased> version <unreleased>
Extractors Extractors
* [foxgay] Fix extraction (#10480)
+ [miaopai] New extractor (#10556) + [miaopai] New extractor (#10556)
* [gamestar] Fix metadata extraction (#10479) * [gamestar] Fix metadata extraction (#10479)
+ [bilibili] Support episodes (#10190) + [bilibili] Support episodes (#10190)

@ -1,18 +1,24 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import itertools
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import (
get_element_by_id,
remove_end,
)
class FoxgayIE(InfoExtractor): class FoxgayIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?foxgay\.com/videos/(?:\S+-)?(?P<id>\d+)\.shtml' _VALID_URL = r'https?://(?:www\.)?foxgay\.com/videos/(?:\S+-)?(?P<id>\d+)\.shtml'
_TEST = { _TEST = {
'url': 'http://foxgay.com/videos/fuck-turkish-style-2582.shtml', 'url': 'http://foxgay.com/videos/fuck-turkish-style-2582.shtml',
'md5': '80d72beab5d04e1655a56ad37afe6841', 'md5': '344558ccfea74d33b7adbce22e577f54',
'info_dict': { 'info_dict': {
'id': '2582', 'id': '2582',
'ext': 'mp4', 'ext': 'mp4',
'title': 'md5:6122f7ae0fc6b21ebdf59c5e083ce25a', 'title': 'Fuck Turkish-style',
'description': 'md5:5e51dc4405f1fd315f7927daed2ce5cf', 'description': 'md5:6ae2d9486921891efe89231ace13ffdf',
'age_limit': 18, 'age_limit': 18,
'thumbnail': 're:https?://.*\.jpg$', 'thumbnail': 're:https?://.*\.jpg$',
}, },
@ -22,27 +28,35 @@ class FoxgayIE(InfoExtractor):
video_id = self._match_id(url) video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
title = self._html_search_regex( title = remove_end(self._html_search_regex(
r'<title>(?P<title>.*?)</title>', r'<title>([^<]+)</title>', webpage, 'title'), ' - Foxgay.com')
webpage, 'title', fatal=False) description = get_element_by_id('inf_tit', webpage)
description = self._html_search_regex(
r'<div class="ico_desc"><h2>(?P<description>.*?)</h2>',
webpage, 'description', fatal=False)
# 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. # 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 = self._download_webpage(
self._html_search_regex(r'iframe src="(?P<frame>.*?)"', webpage, 'video frame'), iframe_url, video_id, headers={'User-Agent': 'curl/7.50.1'},
video_id) note='Downloading video frame')
video_url = self._html_search_regex( video_data = self._parse_json(self._search_regex(
r"v_path = '(?P<vid>http://.*?)'", iframe, 'url') r'video_data\s*=\s*([^;]+);', iframe, 'video data'), video_id)
thumb_url = self._html_search_regex(
r"t_path = '(?P<thumb>http://.*?)'", iframe, 'thumbnail', fatal=False) formats = [{
'url': source,
'height': resolution,
} for source, resolution in zip(
video_data['sources'], video_data.get('resolutions', itertools.repeat(None)))]
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,
'title': title, 'title': title,
'url': video_url, 'formats': formats,
'description': description, 'description': description,
'thumbnail': thumb_url, 'thumbnail': video_data.get('act_vid', {}).get('thumb'),
'age_limit': 18, 'age_limit': 18,
} }

Loading…
Cancel
Save