]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/fujitv.py
[LnkIE] Add extractor (#2408)
[yt-dlp.git] / yt_dlp / extractor / fujitv.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5
6
7 class FujiTVFODPlus7IE(InfoExtractor):
8 _VALID_URL = r'https?://fod\.fujitv\.co\.jp/title/[0-9a-z]{4}/(?P<id>[0-9a-z]+)'
9 _BASE_URL = 'http://i.fod.fujitv.co.jp/'
10 _BITRATE_MAP = {
11 300: (320, 180),
12 800: (640, 360),
13 1200: (1280, 720),
14 2000: (1280, 720),
15 4000: (1920, 1080),
16 }
17
18 _TESTS = [{
19 'url': 'https://fod.fujitv.co.jp/title/5d40/5d40810075',
20 'info_dict': {
21 'id': '5d40810075',
22 'title': '5d40810075',
23 'ext': 'mp4',
24 'format_id': '4000',
25 'thumbnail': 'http://i.fod.fujitv.co.jp/pc/image/wbtn/wbtn_5d40810075.jpg'
26 },
27 'skip': 'Expires after a week'
28 }]
29
30 def _real_extract(self, url):
31 video_id = self._match_id(url)
32 formats = self._extract_m3u8_formats(
33 self._BASE_URL + 'abr/tv_android/%s.m3u8' % video_id, video_id, 'mp4')
34 for f in formats:
35 wh = self._BITRATE_MAP.get(f.get('tbr'))
36 if wh:
37 f.update({
38 'width': wh[0],
39 'height': wh[1],
40 })
41 self._sort_formats(formats)
42
43 return {
44 'id': video_id,
45 'title': video_id,
46 'formats': formats,
47 'thumbnail': self._BASE_URL + 'pc/image/wbtn/wbtn_%s.jpg' % video_id,
48 }