gaskrank.py 3.7 KB

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