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.

96 lines
3.1 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..compat import compat_urlparse
  5. from ..utils import (
  6. fix_xml_ampersands,
  7. float_or_none,
  8. xpath_with_ns,
  9. xpath_text,
  10. )
  11. class KarriereVideosIE(InfoExtractor):
  12. _VALID_URL = r'http://(?:www\.)?karrierevideos\.at(?:/[^/]+)+/(?P<id>[^/]+)'
  13. _TESTS = [{
  14. 'url': 'http://www.karrierevideos.at/berufsvideos/mittlere-hoehere-schulen/altenpflegerin',
  15. 'info_dict': {
  16. 'id': '32c91',
  17. 'ext': 'flv',
  18. 'title': 'AltenpflegerIn',
  19. 'description': 'md5:dbadd1259fde2159a9b28667cb664ae2',
  20. 'thumbnail': 're:^http://.*\.png',
  21. },
  22. 'params': {
  23. # rtmp download
  24. 'skip_download': True,
  25. }
  26. }, {
  27. # broken ampersands
  28. 'url': 'http://www.karrierevideos.at/orientierung/vaeterkarenz-und-neue-chancen-fuer-muetter-baby-was-nun',
  29. 'info_dict': {
  30. 'id': '5sniu',
  31. 'ext': 'flv',
  32. 'title': 'Väterkarenz und neue Chancen für Mütter - "Baby - was nun?"',
  33. 'description': 'md5:97092c6ad1fd7d38e9d6a5fdeb2bcc33',
  34. 'thumbnail': 're:^http://.*\.png',
  35. },
  36. 'params': {
  37. # rtmp download
  38. 'skip_download': True,
  39. }
  40. }]
  41. def _real_extract(self, url):
  42. video_id = self._match_id(url)
  43. webpage = self._download_webpage(url, video_id)
  44. title = (self._html_search_meta('title', webpage, default=None) or
  45. self._search_regex(r'<h1 class="title">([^<]+)</h1>'))
  46. video_id = self._search_regex(
  47. r'/config/video/(.+?)\.xml', webpage, 'video id')
  48. playlist = self._download_xml(
  49. 'http://www.karrierevideos.at/player-playlist.xml.php?p=%s' % video_id,
  50. video_id, transform_source=fix_xml_ampersands)
  51. NS_MAP = {
  52. 'jwplayer': 'http://developer.longtailvideo.com/trac/wiki/FlashFormats'
  53. }
  54. def ns(path):
  55. return xpath_with_ns(path, NS_MAP)
  56. item = playlist.find('./tracklist/item')
  57. video_file = xpath_text(
  58. item, ns('./jwplayer:file'), 'video url', fatal=True)
  59. streamer = xpath_text(
  60. item, ns('./jwplayer:streamer'), 'streamer', fatal=True)
  61. uploader = xpath_text(
  62. item, ns('./jwplayer:author'), 'uploader')
  63. duration = float_or_none(
  64. xpath_text(item, ns('./jwplayer:duration'), 'duration'))
  65. description = self._html_search_regex(
  66. r'(?s)<div class="leadtext">(.+?)</div>',
  67. webpage, 'description')
  68. thumbnail = self._html_search_meta(
  69. 'thumbnail', webpage, 'thumbnail')
  70. if thumbnail:
  71. thumbnail = compat_urlparse.urljoin(url, thumbnail)
  72. return {
  73. 'id': video_id,
  74. 'url': streamer.replace('rtmpt', 'rtmp'),
  75. 'play_path': 'mp4:%s' % video_file,
  76. 'ext': 'flv',
  77. 'title': title,
  78. 'description': description,
  79. 'thumbnail': thumbnail,
  80. 'uploader': uploader,
  81. 'duration': duration,
  82. }