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.

42 lines
1.4 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. class FilmwebIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www\.)?filmweb\.no/(?P<type>trailere|filmnytt)/article(?P<id>\d+)\.ece'
  6. _TEST = {
  7. 'url': 'http://www.filmweb.no/trailere/article1264921.ece',
  8. 'md5': 'e353f47df98e557d67edaceda9dece89',
  9. 'info_dict': {
  10. 'id': '13033574',
  11. 'ext': 'mp4',
  12. 'title': 'Det som en gang var',
  13. 'upload_date': '20160316',
  14. 'timestamp': 1458140101,
  15. 'uploader_id': '12639966',
  16. 'uploader': 'Live Roaldset',
  17. }
  18. }
  19. def _real_extract(self, url):
  20. article_type, article_id = re.match(self._VALID_URL, url).groups()
  21. if article_type == 'filmnytt':
  22. webpage = self._download_webpage(url, article_id)
  23. article_id = self._search_regex(r'data-videoid="(\d+)"', webpage, 'article id')
  24. embed_code = self._download_json(
  25. 'https://www.filmweb.no/template_v2/ajax/json_trailerEmbed.jsp',
  26. article_id, query={
  27. 'articleId': article_id,
  28. })['embedCode']
  29. iframe_url = self._proto_relative_url(self._search_regex(
  30. r'<iframe[^>]+src="([^"]+)', embed_code, 'iframe url'))
  31. return {
  32. '_type': 'url_transparent',
  33. 'id': article_id,
  34. 'url': iframe_url,
  35. 'ie_key': 'TwentyThreeVideo',
  36. }