You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.4 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. class ServusIE(InfoExtractor):
  6. _VALID_URL = r'''(?x)
  7. https?://
  8. (?:www\.)?
  9. (?:
  10. servus\.com/(?:(?:at|de)/p/[^/]+|tv/videos)|
  11. servustv\.com/videos
  12. )
  13. /(?P<id>[aA]{2}-\w+|\d+-\d+)
  14. '''
  15. _TESTS = [{
  16. # new URL schema
  17. 'url': 'https://www.servustv.com/videos/aa-1t6vbu5pw1w12/',
  18. 'md5': '3e1dd16775aa8d5cbef23628cfffc1f4',
  19. 'info_dict': {
  20. 'id': 'AA-1T6VBU5PW1W12',
  21. 'ext': 'mp4',
  22. 'title': 'Die Grünen aus Sicht des Volkes',
  23. 'description': 'md5:1247204d85783afe3682644398ff2ec4',
  24. 'thumbnail': r're:^https?://.*\.jpg',
  25. }
  26. }, {
  27. # old URL schema
  28. 'url': 'https://www.servus.com/de/p/Die-Gr%C3%BCnen-aus-Sicht-des-Volkes/AA-1T6VBU5PW1W12/',
  29. 'only_matching': True,
  30. }, {
  31. 'url': 'https://www.servus.com/at/p/Wie-das-Leben-beginnt/1309984137314-381415152/',
  32. 'only_matching': True,
  33. }, {
  34. 'url': 'https://www.servus.com/tv/videos/aa-1t6vbu5pw1w12/',
  35. 'only_matching': True,
  36. }, {
  37. 'url': 'https://www.servus.com/tv/videos/1380889096408-1235196658/',
  38. 'only_matching': True,
  39. }]
  40. def _real_extract(self, url):
  41. video_id = self._match_id(url).upper()
  42. webpage = self._download_webpage(url, video_id)
  43. title = self._search_regex(
  44. (r'videoLabel\s*=\s*(["\'])(?P<title>(?:(?!\1).)+)\1',
  45. r'<h\d+[^>]+\bclass=["\']heading--(?:one|two)["\'][^>]*>(?P<title>[^<]+)'),
  46. webpage, 'title', default=None,
  47. group='title') or self._og_search_title(webpage)
  48. title = re.sub(r'\s*-\s*Servus TV\s*$', '', title)
  49. description = self._og_search_description(webpage)
  50. thumbnail = self._og_search_thumbnail(webpage)
  51. formats = self._extract_m3u8_formats(
  52. 'https://stv.rbmbtnx.net/api/v1/manifests/%s.m3u8' % video_id,
  53. video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls')
  54. self._sort_formats(formats)
  55. return {
  56. 'id': video_id,
  57. 'title': title,
  58. 'description': description,
  59. 'thumbnail': thumbnail,
  60. 'formats': formats,
  61. }