]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/goshgay.py
[cleanup] Add more ruff rules (#10149)
[yt-dlp.git] / yt_dlp / extractor / goshgay.py
1 import urllib.parse
2
3 from .common import InfoExtractor
4 from ..utils import (
5 parse_duration,
6 )
7
8
9 class GoshgayIE(InfoExtractor):
10 _VALID_URL = r'https?://(?:www\.)?goshgay\.com/video(?P<id>\d+?)($|/)'
11 _TEST = {
12 'url': 'http://www.goshgay.com/video299069/diesel_sfw_xxx_video',
13 'md5': '4b6db9a0a333142eb9f15913142b0ed1',
14 'info_dict': {
15 'id': '299069',
16 'ext': 'flv',
17 'title': 'DIESEL SFW XXX Video',
18 'thumbnail': r're:^http://.*\.jpg$',
19 'duration': 80,
20 'age_limit': 18,
21 },
22 }
23
24 def _real_extract(self, url):
25 video_id = self._match_id(url)
26 webpage = self._download_webpage(url, video_id)
27
28 title = self._html_search_regex(
29 r'<h2>(.*?)<', webpage, 'title')
30 duration = parse_duration(self._html_search_regex(
31 r'<span class="duration">\s*-?\s*(.*?)</span>',
32 webpage, 'duration', fatal=False))
33
34 flashvars = urllib.parse.parse_qs(self._html_search_regex(
35 r'<embed.+?id="flash-player-embed".+?flashvars="([^"]+)"',
36 webpage, 'flashvars'))
37 thumbnail = flashvars.get('url_bigthumb', [None])[0]
38 video_url = flashvars['flv_url'][0]
39
40 return {
41 'id': video_id,
42 'url': video_url,
43 'title': title,
44 'thumbnail': thumbnail,
45 'duration': duration,
46 'age_limit': 18,
47 }