]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/tvp.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
9 class TVPIE(InfoExtractor
):
11 IE_DESC
= 'Telewizja Polska'
12 _VALID_URL
= r
'https?://[^/]+\.tvp\.(?:pl|info)/(?:(?!\d+/)[^/]+/)*(?P<id>\d+)'
15 'url': 'http://vod.tvp.pl/194536/i-seria-odc-13',
16 'md5': '8aa518c15e5cc32dfe8db400dc921fbb',
20 'title': 'Czas honoru, I seria – odc. 13',
23 'url': 'http://www.tvp.pl/there-can-be-anything-so-i-shortened-it/17916176',
24 'md5': 'c3b15ed1af288131115ff17a17c19dda',
28 'title': 'TVP Gorzów pokaże filmy studentów z podroży dookoła świata',
31 'url': 'http://vod.tvp.pl/seriale/obyczajowe/na-sygnale/sezon-2-27-/odc-39/17834272',
32 'only_matching': True,
34 'url': 'http://wiadomosci.tvp.pl/25169746/24052016-1200',
35 'only_matching': True,
37 'url': 'http://krakow.tvp.pl/25511623/25lecie-mck-wyjatkowe-miejsce-na-mapie-krakowa',
38 'only_matching': True,
40 'url': 'http://teleexpress.tvp.pl/25522307/wierni-wzieli-udzial-w-procesjach',
41 'only_matching': True,
43 'url': 'http://sport.tvp.pl/25522165/krychowiak-uspokaja-w-sprawie-kontuzji-dwa-tygodnie-to-maksimum',
44 'only_matching': True,
46 'url': 'http://www.tvp.info/25511919/trwa-rewolucja-wladza-zdecydowala-sie-na-pogwalcenie-konstytucji',
47 'only_matching': True,
50 def _real_extract(self
, url
):
51 video_id
= self
._match
_id
(url
)
53 webpage
= self
._download
_webpage
(
54 'http://www.tvp.pl/sess/tvplayer.php?object_id=%s' % video_id
, video_id
)
56 title
= self
._search
_regex
(
57 r
'name\s*:\s*([\'"])Title\1\s*,\s*value\s*:\s*\1(?P<title>.+?)\1',
58 webpage, 'title', group='title')
59 series_title = self._search_regex(
60 r'name\s*:\s*([\'"])SeriesTitle\
1\s
*,\s
*value\s
*:\s
*\
1(?P
<series
>.+?
)\
1',
61 webpage, 'series
', group='series
', default=None)
63 title = '%s, %s' % (series_title, title)
65 thumbnail = self._search_regex(
66 r"poster\s*:\s*'([^
']+)'", webpage, 'thumbnail', default=None)
68 video_url = self._search_regex(
69 r'0:{src:([\'"])(?P
<url
>.*?
)\
1', webpage, 'formats
', group='url
', default=None)
71 video_url = self._download_json(
72 'http
://www
.tvp
.pl
/pub
/stat
/videofileinfo?video_id
=%s' % video_id,
73 video_id)['video_url
']
75 ext = video_url.rsplit('.', 1)[-1]
76 if ext != 'ism
/manifest
':
80 'format_id
': 'direct
',
85 m3u8_url = re.sub('([^
/]*)\
.ism
/manifest
', r'\
1.ism
/\
1.m3u8
', video_url)
86 formats = self._extract_m3u8_formats(m3u8_url, video_id, 'mp4
')
88 self._sort_formats(formats)
93 'thumbnail
': thumbnail,
98 class TVPSeriesIE(InfoExtractor):
99 IE_NAME = 'tvp
:series
'
100 _VALID_URL = r'https?
://vod\
.tvp\
.pl
/(?
:[^
/]+/){2}
(?P
<id>[^
/]+)/?$
'
103 'url
': 'http
://vod
.tvp
.pl
/filmy
-fabularne
/filmy
-za
-darmo
/ogniem
-i
-mieczem
',
105 'title
': 'Ogniem i mieczem
',
110 'url
': 'http
://vod
.tvp
.pl
/audycje
/podroze
/boso
-przez
-swiat
',
112 'title
': 'Boso przez świat
',
115 'playlist_count
': 86,
118 def _real_extract(self, url):
119 display_id = self._match_id(url)
120 webpage = self._download_webpage(url, display_id, tries=5)
122 title = self._html_search_regex(
123 r'(?s
) id=[\'"]path[\'"]>(?
:.*?
/ ){2}
(.*?
)</span
>', webpage, 'series
')
124 playlist_id = self._search_regex(r'nodeId
:\s
*(\d
+)', webpage, 'playlist
id')
125 playlist = self._download_webpage(
126 'http
://vod
.tvp
.pl
/vod
/seriesAjax?
type=series
&nodeId
=%s&recommend
'
127 'edId
=0&sort
=&page
=0&pageSize
=10000' % playlist_id, display_id, tries=5,
128 note='Downloading playlist
')
130 videos_paths = re.findall(
131 '(?s
)class="shortTitle">.*?href
="(/[^"]+)', playlist)
133 self.url_result('http
://vod
.tvp
.pl
%s' % v_path, ie=TVPIE.ie_key())
134 for v_path in videos_paths]
139 'display_id
': display_id,