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