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.

67 lines
2.3 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .brightcove import BrightcoveNewIE
  5. from ..utils import update_url_query
  6. class SevenPlusIE(BrightcoveNewIE):
  7. IE_NAME = '7plus'
  8. _VALID_URL = r'https?://(?:www\.)?7plus\.com\.au/(?P<path>[^?]+\?.*?\bepisode-id=(?P<id>[^&#]+))'
  9. _TESTS = [{
  10. 'url': 'https://7plus.com.au/BEAT?episode-id=BEAT-001',
  11. 'info_dict': {
  12. 'id': 'BEAT-001',
  13. 'ext': 'mp4',
  14. 'title': 'S1 E1 - Help / Lucy In The Sky With Diamonds',
  15. 'description': 'md5:37718bea20a8eedaca7f7361af566131',
  16. 'uploader_id': '5303576322001',
  17. 'upload_date': '20171031',
  18. 'timestamp': 1509440068,
  19. },
  20. 'params': {
  21. 'format': 'bestvideo',
  22. 'skip_download': True,
  23. }
  24. }, {
  25. 'url': 'https://7plus.com.au/UUUU?episode-id=AUMS43-001',
  26. 'only_matching': True,
  27. }]
  28. def _real_extract(self, url):
  29. path, episode_id = re.match(self._VALID_URL, url).groups()
  30. media = self._download_json(
  31. 'https://videoservice.swm.digital/playback', episode_id, query={
  32. 'appId': '7plus',
  33. 'deviceType': 'web',
  34. 'platformType': 'web',
  35. 'accountId': 5303576322001,
  36. 'referenceId': 'ref:' + episode_id,
  37. 'deliveryId': 'csai',
  38. 'videoType': 'vod',
  39. })['media']
  40. for source in media.get('sources', {}):
  41. src = source.get('src')
  42. if not src:
  43. continue
  44. source['src'] = update_url_query(src, {'rule': ''})
  45. info = self._parse_brightcove_metadata(media, episode_id)
  46. content = self._download_json(
  47. 'https://component-cdn.swm.digital/content/' + path,
  48. episode_id, headers={
  49. 'market-id': 4,
  50. }, fatal=False) or {}
  51. for item in content.get('items', {}):
  52. if item.get('componentData', {}).get('componentType') == 'infoPanel':
  53. for src_key, dst_key in [('title', 'title'), ('shortSynopsis', 'description')]:
  54. value = item.get(src_key)
  55. if value:
  56. info[dst_key] = value
  57. return info