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.

62 lines
2.5 KiB

  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. class AftonbladetIE(InfoExtractor):
  5. _VALID_URL = r'^http://tv\.aftonbladet\.se/webbtv.+?(?P<video_id>article[0-9]+)\.ab(?:$|[?#])'
  6. _TEST = {
  7. 'url': 'http://tv.aftonbladet.se/webbtv/nyheter/vetenskap/rymden/article36015.ab',
  8. 'info_dict': {
  9. 'id': 'article36015',
  10. 'ext': 'mp4',
  11. 'title': 'Vulkanutbrott i rymden - nu släpper NASA bilderna',
  12. 'description': 'Jupiters måne mest aktiv av alla himlakroppar',
  13. 'timestamp': 1394142732,
  14. 'upload_date': '20140306',
  15. },
  16. }
  17. def _real_extract(self, url):
  18. video_id = self._match_id(url)
  19. webpage = self._download_webpage(url, video_id)
  20. # find internal video meta data
  21. meta_url = 'http://aftonbladet-play.drlib.aptoma.no/video/%s.json'
  22. internal_meta_id = self._html_search_regex(
  23. r'data-aptomaId="([\w\d]+)"', webpage, 'internal_meta_id')
  24. internal_meta_url = meta_url % internal_meta_id
  25. internal_meta_json = self._download_json(
  26. internal_meta_url, video_id, 'Downloading video meta data')
  27. # find internal video formats
  28. format_url = 'http://aftonbladet-play.videodata.drvideo.aptoma.no/actions/video/?id=%s'
  29. internal_video_id = internal_meta_json['videoId']
  30. internal_formats_url = format_url % internal_video_id
  31. internal_formats_json = self._download_json(
  32. internal_formats_url, video_id, 'Downloading video formats')
  33. formats = []
  34. for fmt in internal_formats_json['formats']['http']['pseudostreaming']['mp4']:
  35. p = fmt['paths'][0]
  36. formats.append({
  37. 'url': 'http://%s:%d/%s/%s' % (p['address'], p['port'], p['path'], p['filename']),
  38. 'ext': 'mp4',
  39. 'width': fmt['width'],
  40. 'height': fmt['height'],
  41. 'tbr': fmt['bitrate'],
  42. 'protocol': 'http',
  43. })
  44. self._sort_formats(formats)
  45. return {
  46. 'id': video_id,
  47. 'title': internal_meta_json['title'],
  48. 'formats': formats,
  49. 'thumbnail': internal_meta_json['imageUrl'],
  50. 'description': internal_meta_json['shortPreamble'],
  51. 'timestamp': internal_meta_json['timePublished'],
  52. 'duration': internal_meta_json['duration'],
  53. 'view_count': internal_meta_json['views'],
  54. }