mirror of https://github.com/blackjack4494/yt-dlc
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
2.2 KiB
Python
64 lines
2.2 KiB
Python
10 years ago
|
from __future__ import unicode_literals
|
||
|
|
||
8 years ago
|
import itertools
|
||
|
|
||
10 years ago
|
from .common import InfoExtractor
|
||
8 years ago
|
from ..utils import (
|
||
|
get_element_by_id,
|
||
8 years ago
|
int_or_none,
|
||
8 years ago
|
remove_end,
|
||
|
)
|
||
10 years ago
|
|
||
|
|
||
|
class FoxgayIE(InfoExtractor):
|
||
9 years ago
|
_VALID_URL = r'https?://(?:www\.)?foxgay\.com/videos/(?:\S+-)?(?P<id>\d+)\.shtml'
|
||
10 years ago
|
_TEST = {
|
||
|
'url': 'http://foxgay.com/videos/fuck-turkish-style-2582.shtml',
|
||
8 years ago
|
'md5': '344558ccfea74d33b7adbce22e577f54',
|
||
10 years ago
|
'info_dict': {
|
||
|
'id': '2582',
|
||
|
'ext': 'mp4',
|
||
8 years ago
|
'title': 'Fuck Turkish-style',
|
||
|
'description': 'md5:6ae2d9486921891efe89231ace13ffdf',
|
||
10 years ago
|
'age_limit': 18,
|
||
8 years ago
|
'thumbnail': r're:https?://.*\.jpg$',
|
||
10 years ago
|
},
|
||
|
}
|
||
|
|
||
|
def _real_extract(self, url):
|
||
|
video_id = self._match_id(url)
|
||
|
webpage = self._download_webpage(url, video_id)
|
||
10 years ago
|
|
||
8 years ago
|
title = remove_end(self._html_search_regex(
|
||
|
r'<title>([^<]+)</title>', webpage, 'title'), ' - Foxgay.com')
|
||
|
description = get_element_by_id('inf_tit', webpage)
|
||
10 years ago
|
|
||
8 years ago
|
# The default user-agent with foxgay cookies leads to pages without videos
|
||
|
self._downloader.cookiejar.clear('.foxgay.com')
|
||
10 years ago
|
# Find the URL for the iFrame which contains the actual video.
|
||
8 years ago
|
iframe_url = self._html_search_regex(
|
||
|
r'<iframe[^>]+src=([\'"])(?P<url>[^\'"]+)\1', webpage,
|
||
|
'video frame', group='url')
|
||
10 years ago
|
iframe = self._download_webpage(
|
||
8 years ago
|
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,
|
||
8 years ago
|
'height': int_or_none(resolution),
|
||
8 years ago
|
} for source, resolution in zip(
|
||
|
video_data['sources'], video_data.get('resolutions', itertools.repeat(None)))]
|
||
|
|
||
|
self._sort_formats(formats)
|
||
10 years ago
|
|
||
|
return {
|
||
|
'id': video_id,
|
||
|
'title': title,
|
||
8 years ago
|
'formats': formats,
|
||
10 years ago
|
'description': description,
|
||
8 years ago
|
'thumbnail': video_data.get('act_vid', {}).get('thumb'),
|
||
10 years ago
|
'age_limit': 18,
|
||
|
}
|