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.

66 lines
2.1 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. determine_ext,
  6. )
  7. class OppetArkivIE(InfoExtractor):
  8. _VALID_URL = r'https?://(?:www\.)?oppetarkiv\.se/video/(?P<id>[0-9]+)'
  9. _TEST = {
  10. 'url': 'http://www.oppetarkiv.se/video/1058509/rederiet-sasong-1-avsnitt-1-av-318',
  11. 'md5': '5c1eb616e59f733d4af77edc5177d2fe',
  12. 'info_dict': {
  13. 'id': '1058509',
  14. 'ext': 'flv',
  15. 'title': 'Farlig kryssning',
  16. 'duration': 2566,
  17. 'thumbnail': 're:^https?://.*[\.-]jpg$',
  18. 'age_limit': 0,
  19. },
  20. 'skip': 'Only works from Sweden',
  21. }
  22. def _real_extract(self, url):
  23. video_id = self._match_id(url)
  24. info = self._download_json(
  25. 'http://www.oppetarkiv.se/video/%s?output=json' % video_id, video_id)
  26. title = info['context']['title']
  27. thumbnail = info['context'].get('thumbnailImage')
  28. video_info = info['video']
  29. formats = []
  30. for vr in video_info['videoReferences']:
  31. vurl = vr['url']
  32. ext = determine_ext(vurl)
  33. if ext == 'm3u8':
  34. formats.extend(self._extract_m3u8_formats(
  35. vurl, video_id,
  36. ext='mp4', entry_protocol='m3u8_native',
  37. m3u8_id=vr.get('playerType')))
  38. elif ext == 'f4m':
  39. formats.extend(self._extract_f4m_formats(
  40. vurl + '?hdcore=3.3.0', video_id,
  41. f4m_id=vr.get('playerType')))
  42. else:
  43. formats.append({
  44. 'format_id': vr.get('playerType'),
  45. 'url': vurl,
  46. })
  47. self._sort_formats(formats)
  48. duration = video_info.get('materialLength')
  49. age_limit = 18 if video_info.get('inappropriateForChildren') else 0
  50. return {
  51. 'id': video_id,
  52. 'title': title,
  53. 'formats': formats,
  54. 'thumbnail': thumbnail,
  55. 'duration': duration,
  56. 'age_limit': age_limit,
  57. }