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.

73 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. 'md5': '6269e8626fa1a891bf5369b386ae996a',
  17. 'info_dict': {
  18. 'id': '1165642',
  19. 'ext': 'mp4',
  20. 'title': 'Åbent samråd i Erhvervsudvalget',
  21. 'description': 'Åbent samråd med erhvervs- og vækstministeren om regeringens politik på teleområdet',
  22. 'view_count': int,
  23. 'width': 768,
  24. 'height': 432,
  25. 'tbr': 928000,
  26. 'timestamp': 1416493800,
  27. 'upload_date': '20141120',
  28. 'duration': 3960,
  29. },
  30. }
  31. def _real_extract(self, url):
  32. video_id = self._match_id(url)
  33. webpage = self._download_webpage(url, video_id)
  34. title = self._og_search_title(webpage)
  35. description = self._html_search_regex(
  36. r'(?s)<div class="video-item-agenda"[^>]*>(.*?)<',
  37. webpage, 'description', fatal=False)
  38. player_params = compat_parse_qs(self._search_regex(
  39. r'<embed src="http://ft\.arkena\.tv/flash/ftplayer\.swf\?([^"]+)"',
  40. webpage, 'player params'))
  41. xml_url = player_params['xml'][0]
  42. doc = self._download_xml(xml_url, video_id)
  43. timestamp = parse_iso8601(xpath_text(doc, './/date'))
  44. duration = parse_duration(xpath_text(doc, './/duration'))
  45. width = int_or_none(xpath_text(doc, './/width'))
  46. height = int_or_none(xpath_text(doc, './/height'))
  47. view_count = int_or_none(xpath_text(doc, './/views'))
  48. formats = [{
  49. 'format_id': n.attrib['bitrate'],
  50. 'url': xpath_text(n, './url', fatal=True),
  51. 'tbr': int_or_none(n.attrib['bitrate']),
  52. } for n in doc.findall('.//streams/stream')]
  53. self._sort_formats(formats)
  54. return {
  55. 'id': video_id,
  56. 'title': title,
  57. 'formats': formats,
  58. 'description': description,
  59. 'timestamp': timestamp,
  60. 'width': width,
  61. 'height': height,
  62. 'duration': duration,
  63. 'view_count': view_count,
  64. }