]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/yesjapan.py
[extractor/FranceCulture] Fix extractor (#3874)
[yt-dlp.git] / yt_dlp / extractor / yesjapan.py
CommitLineData
408b5839
NJ
1from .common import InfoExtractor
2from ..utils import (
3 HEADRequest,
4 get_element_by_attribute,
5 parse_iso8601,
6)
7
8
9class YesJapanIE(InfoExtractor):
10 _VALID_URL = r'https?://(?:www\.)?yesjapan\.com/video/(?P<slug>[A-Za-z0-9\-]*)_(?P<id>[A-Za-z0-9]+)\.html'
11 _TEST = {
12 'url': 'http://www.yesjapan.com/video/japanese-in-5-20-wa-and-ga-particle-usages_726497834.html',
13 'md5': 'f0be416314e5be21a12b499b330c21cf',
14 'info_dict': {
15 'id': '726497834',
16 'title': 'Japanese in 5! #20 - WA And GA Particle Usages',
17 'description': 'This should clear up some issues most students of Japanese encounter with WA and GA....',
18 'ext': 'mp4',
19 'timestamp': 1416391590,
20 'upload_date': '20141119',
ec85ded8 21 'thumbnail': r're:^https?://.*\.jpg$',
408b5839
NJ
22 }
23 }
24
25 def _real_extract(self, url):
26 video_id = self._match_id(url)
27
28 webpage = self._download_webpage(url, video_id)
29 title = self._og_search_title(webpage)
30 video_url = self._og_search_video_url(webpage)
31 description = self._og_search_description(webpage)
32 thumbnail = self._og_search_thumbnail(webpage)
33
34 timestamp = None
35 submit_info = get_element_by_attribute('class', 'pm-submit-data', webpage)
36 if submit_info:
37 timestamp = parse_iso8601(self._search_regex(
4a4fbfc9 38 r'datetime="([^"]+)"', submit_info, 'upload date', fatal=False, default=None))
408b5839
NJ
39
40 # attempt to resolve the final URL in order to get a proper extension
41 redirect_req = HEADRequest(video_url)
42 req = self._request_webpage(
43 redirect_req, video_id, note='Resolving final URL', errnote='Could not resolve final URL', fatal=False)
44 if req:
45 video_url = req.geturl()
46
47 formats = [{
48 'format_id': 'sd',
49 'url': video_url,
50 }]
51
52 return {
53 'id': video_id,
54 'title': title,
55 'formats': formats,
56 'description': description,
57 'timestamp': timestamp,
58 'thumbnail': thumbnail,
59 }