]> git.bitcoin.ninja Git - youtube-dl/blob - youtube_dl/extractor/tvnoe.py
[pornhub] Extract categories and tags (closes #10499)
[youtube-dl] / youtube_dl / extractor / tvnoe.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .jwplatform import JWPlatformBaseIE
5 from ..utils import (
6     clean_html,
7     get_element_by_class,
8     js_to_json,
9 )
10
11
12 class TVNoeIE(JWPlatformBaseIE):
13     _VALID_URL = r'https?://(?:www\.)?tvnoe\.cz/video/(?P<id>[0-9]+)'
14     _TEST = {
15         'url': 'http://www.tvnoe.cz/video/10362',
16         'md5': 'aee983f279aab96ec45ab6e2abb3c2ca',
17         'info_dict': {
18             'id': '10362',
19             'ext': 'mp4',
20             'series': 'Noční univerzita',
21             'title': 'prof. Tomáš Halík, Th.D. - Návrat náboženství a střet civilizací',
22             'description': 'md5:f337bae384e1a531a52c55ebc50fff41',
23         }
24     }
25
26     def _real_extract(self, url):
27         video_id = self._match_id(url)
28         webpage = self._download_webpage(url, video_id)
29
30         iframe_url = self._search_regex(
31             r'<iframe[^>]+src="([^"]+)"', webpage, 'iframe URL')
32
33         ifs_page = self._download_webpage(iframe_url, video_id)
34         jwplayer_data = self._parse_json(
35             self._find_jwplayer_data(ifs_page),
36             video_id, transform_source=js_to_json)
37         info_dict = self._parse_jwplayer_data(
38             jwplayer_data, video_id, require_title=False, base_url=iframe_url)
39
40         info_dict.update({
41             'id': video_id,
42             'title': clean_html(get_element_by_class(
43                 'field-name-field-podnazev', webpage)),
44             'description': clean_html(get_element_by_class(
45                 'field-name-body', webpage)),
46             'series': clean_html(get_element_by_class('title', webpage))
47         })
48
49         return info_dict