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.

77 lines
2.6 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. 'params': {
  31. # rtmp download
  32. 'skip_download': True,
  33. },
  34. }
  35. def _real_extract(self, url):
  36. video_id = self._match_id(url)
  37. webpage = self._download_webpage(url, video_id)
  38. title = self._og_search_title(webpage)
  39. description = self._html_search_regex(
  40. r'(?s)<div class="video-item-agenda"[^>]*>(.*?)<',
  41. webpage, 'description', fatal=False)
  42. player_params = compat_parse_qs(self._search_regex(
  43. r'<embed src="http://ft\.arkena\.tv/flash/ftplayer\.swf\?([^"]+)"',
  44. webpage, 'player params'))
  45. xml_url = player_params['xml'][0]
  46. doc = self._download_xml(xml_url, video_id)
  47. timestamp = parse_iso8601(xpath_text(doc, './/date'))
  48. duration = parse_duration(xpath_text(doc, './/duration'))
  49. width = int_or_none(xpath_text(doc, './/width'))
  50. height = int_or_none(xpath_text(doc, './/height'))
  51. view_count = int_or_none(xpath_text(doc, './/views'))
  52. formats = [{
  53. 'format_id': n.attrib['bitrate'],
  54. 'url': xpath_text(n, './url', fatal=True),
  55. 'tbr': int_or_none(n.attrib['bitrate']),
  56. } for n in doc.findall('.//streams/stream')]
  57. self._sort_formats(formats)
  58. return {
  59. 'id': video_id,
  60. 'title': title,
  61. 'formats': formats,
  62. 'description': description,
  63. 'timestamp': timestamp,
  64. 'width': width,
  65. 'height': height,
  66. 'duration': duration,
  67. 'view_count': view_count,
  68. }