]>
Commit | Line | Data |
---|---|---|
1 | import re | |
2 | ||
3 | from .common import InfoExtractor | |
4 | from ..utils import ( | |
5 | float_or_none, | |
6 | int_or_none, | |
7 | unified_strdate, | |
8 | ) | |
9 | ||
10 | ||
11 | class GaskrankIE(InfoExtractor): | |
12 | _VALID_URL = r'https?://(?:www\.)?gaskrank\.tv/tv/(?P<categories>[^/]+)/(?P<id>[^/]+)\.htm' | |
13 | _TESTS = [{ | |
14 | 'url': 'http://www.gaskrank.tv/tv/motorrad-fun/strike-einparken-durch-anfaenger-crash-mit-groesserem-flurschaden.htm', | |
15 | 'md5': '1ae88dbac97887d85ebd1157a95fc4f9', | |
16 | 'info_dict': { | |
17 | 'id': '201601/26955', | |
18 | 'ext': 'mp4', | |
19 | 'title': 'Strike! Einparken können nur Männer - Flurschaden hält sich in Grenzen *lol*', | |
20 | 'thumbnail': r're:^https?://.*\.jpg$', | |
21 | 'categories': ['motorrad-fun'], | |
22 | 'display_id': 'strike-einparken-durch-anfaenger-crash-mit-groesserem-flurschaden', | |
23 | 'uploader_id': 'Bikefun', | |
24 | 'upload_date': '20170110', | |
25 | }, | |
26 | }, { | |
27 | 'url': 'http://www.gaskrank.tv/tv/racing/isle-of-man-tt-2011-michael-du-15920.htm', | |
28 | 'md5': 'c33ee32c711bc6c8224bfcbe62b23095', | |
29 | 'info_dict': { | |
30 | 'id': '201106/15920', | |
31 | 'ext': 'mp4', | |
32 | 'title': 'Isle of Man - Michael Dunlop vs Guy Martin - schwindelig kucken', | |
33 | 'thumbnail': r're:^https?://.*\.jpg$', | |
34 | 'categories': ['racing'], | |
35 | 'display_id': 'isle-of-man-tt-2011-michael-du-15920', | |
36 | 'uploader_id': 'IOM', | |
37 | 'upload_date': '20170523', | |
38 | 'uploader_url': 'www.iomtt.com', | |
39 | }, | |
40 | }] | |
41 | ||
42 | def _real_extract(self, url): | |
43 | display_id = self._match_id(url) | |
44 | ||
45 | webpage = self._download_webpage(url, display_id) | |
46 | ||
47 | title = self._og_search_title( | |
48 | webpage, default=None) or self._html_search_meta( | |
49 | 'title', webpage, fatal=True) | |
50 | ||
51 | categories = [self._match_valid_url(url).group('categories')] | |
52 | ||
53 | mobj = re.search( | |
54 | r'Video von:\s*(?P<uploader_id>[^|]*?)\s*\|\s*vom:\s*(?P<upload_date>[0-9][0-9]\.[0-9][0-9]\.[0-9][0-9][0-9][0-9])', | |
55 | webpage) | |
56 | if mobj is not None: | |
57 | uploader_id = mobj.groupdict().get('uploader_id') | |
58 | upload_date = unified_strdate(mobj.groupdict().get('upload_date')) | |
59 | ||
60 | uploader_url = self._search_regex( | |
61 | r'Homepage:\s*<[^>]*>(?P<uploader_url>[^<]*)', | |
62 | webpage, 'uploader_url', default=None) | |
63 | tags = re.findall( | |
64 | r'/tv/tags/[^/]+/"\s*>(?P<tag>[^<]*?)<', | |
65 | webpage) | |
66 | ||
67 | view_count = self._search_regex( | |
68 | r'class\s*=\s*"gkRight"(?:[^>]*>\s*<[^>]*)*icon-eye-open(?:[^>]*>\s*<[^>]*)*>\s*(?P<view_count>[0-9\.]*)', | |
69 | webpage, 'view_count', default=None) | |
70 | if view_count: | |
71 | view_count = int_or_none(view_count.replace('.', '')) | |
72 | ||
73 | average_rating = self._search_regex( | |
74 | r'itemprop\s*=\s*"ratingValue"[^>]*>\s*(?P<average_rating>[0-9,]+)', | |
75 | webpage, 'average_rating') | |
76 | if average_rating: | |
77 | average_rating = float_or_none(average_rating.replace(',', '.')) | |
78 | ||
79 | video_id = self._search_regex( | |
80 | r'https?://movies\.gaskrank\.tv/([^-]*?)(-[^\.]*)?\.mp4', | |
81 | webpage, 'video id', default=display_id) | |
82 | ||
83 | entry = self._parse_html5_media_entries(url, webpage, video_id)[0] | |
84 | entry.update({ | |
85 | 'id': video_id, | |
86 | 'title': title, | |
87 | 'categories': categories, | |
88 | 'display_id': display_id, | |
89 | 'uploader_id': uploader_id, | |
90 | 'upload_date': upload_date, | |
91 | 'uploader_url': uploader_url, | |
92 | 'tags': tags, | |
93 | 'view_count': view_count, | |
94 | 'average_rating': average_rating, | |
95 | }) | |
96 | ||
97 | return entry |