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.

75 lines
2.5 KiB

  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..compat import compat_parse_qs
  5. from ..utils import (
  6. int_or_none,
  7. parse_duration,
  8. parse_iso8601,
  9. xpath_text,
  10. )
  11. class FolketingetIE(InfoExtractor):
  12. IE_DESC = 'Folketinget (ft.dk; Danish parliament)'
  13. _VALID_URL = r'https?://(?:www\.)?ft\.dk/webtv/video/[^?#]*?\.(?P<id>[0-9]+)\.aspx'
  14. _TEST = {
  15. 'url': 'http://www.ft.dk/webtv/video/20141/eru/td.1165642.aspx?as=1#player',
  16. 'info_dict': {
  17. 'id': '1165642',
  18. 'ext': 'mp4',
  19. 'title': 'Åbent samråd i Erhvervsudvalget',
  20. 'description': 'Åbent samråd med erhvervs- og vækstministeren om regeringens politik på teleområdet',
  21. 'view_count': int,
  22. 'width': 768,
  23. 'height': 432,
  24. 'tbr': 928000,
  25. 'timestamp': 1416493800,
  26. 'upload_date': '20141120',
  27. 'duration': 3960,
  28. },
  29. 'params': {
  30. 'skip_download': 'rtmpdump required',
  31. }
  32. }
  33. def _real_extract(self, url):
  34. video_id = self._match_id(url)
  35. webpage = self._download_webpage(url, video_id)
  36. title = self._og_search_title(webpage)
  37. description = self._html_search_regex(
  38. r'(?s)<div class="video-item-agenda"[^>]*>(.*?)<',
  39. webpage, 'description', fatal=False)
  40. player_params = compat_parse_qs(self._search_regex(
  41. r'<embed src="http://ft\.arkena\.tv/flash/ftplayer\.swf\?([^"]+)"',
  42. webpage, 'player params'))
  43. xml_url = player_params['xml'][0]
  44. doc = self._download_xml(xml_url, video_id)
  45. timestamp = parse_iso8601(xpath_text(doc, './/date'))
  46. duration = parse_duration(xpath_text(doc, './/duration'))
  47. width = int_or_none(xpath_text(doc, './/width'))
  48. height = int_or_none(xpath_text(doc, './/height'))
  49. view_count = int_or_none(xpath_text(doc, './/views'))
  50. formats = [{
  51. 'format_id': n.attrib['bitrate'],
  52. 'url': xpath_text(n, './url', fatal=True),
  53. 'tbr': int_or_none(n.attrib['bitrate']),
  54. } for n in doc.findall('.//streams/stream')]
  55. self._sort_formats(formats)
  56. return {
  57. 'id': video_id,
  58. 'title': title,
  59. 'formats': formats,
  60. 'description': description,
  61. 'timestamp': timestamp,
  62. 'width': width,
  63. 'height': height,
  64. 'duration': duration,
  65. 'view_count': view_count,
  66. }