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.

84 lines
2.9 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .brightcove import BrightcoveNewIE
  5. from ..compat import compat_str
  6. from ..utils import (
  7. try_get,
  8. update_url_query,
  9. )
  10. class SevenPlusIE(BrightcoveNewIE):
  11. IE_NAME = '7plus'
  12. _VALID_URL = r'https?://(?:www\.)?7plus\.com\.au/(?P<path>[^?]+\?.*?\bepisode-id=(?P<id>[^&#]+))'
  13. _TESTS = [{
  14. 'url': 'https://7plus.com.au/MTYS?episode-id=MTYS7-003',
  15. 'info_dict': {
  16. 'id': 'MTYS7-003',
  17. 'ext': 'mp4',
  18. 'title': 'S7 E3 - Wind Surf',
  19. 'description': 'md5:29c6a69f21accda7601278f81b46483d',
  20. 'uploader_id': '5303576322001',
  21. 'upload_date': '20171201',
  22. 'timestamp': 1512106377,
  23. 'series': 'Mighty Ships',
  24. 'season_number': 7,
  25. 'episode_number': 3,
  26. 'episode': 'Wind Surf',
  27. },
  28. 'params': {
  29. 'format': 'bestvideo',
  30. 'skip_download': True,
  31. }
  32. }, {
  33. 'url': 'https://7plus.com.au/UUUU?episode-id=AUMS43-001',
  34. 'only_matching': True,
  35. }]
  36. def _real_extract(self, url):
  37. path, episode_id = re.match(self._VALID_URL, url).groups()
  38. media = self._download_json(
  39. 'https://videoservice.swm.digital/playback', episode_id, query={
  40. 'appId': '7plus',
  41. 'deviceType': 'web',
  42. 'platformType': 'web',
  43. 'accountId': 5303576322001,
  44. 'referenceId': 'ref:' + episode_id,
  45. 'deliveryId': 'csai',
  46. 'videoType': 'vod',
  47. })['media']
  48. for source in media.get('sources', {}):
  49. src = source.get('src')
  50. if not src:
  51. continue
  52. source['src'] = update_url_query(src, {'rule': ''})
  53. info = self._parse_brightcove_metadata(media, episode_id)
  54. content = self._download_json(
  55. 'https://component-cdn.swm.digital/content/' + path,
  56. episode_id, headers={
  57. 'market-id': 4,
  58. }, fatal=False) or {}
  59. for item in content.get('items', {}):
  60. if item.get('componentData', {}).get('componentType') == 'infoPanel':
  61. for src_key, dst_key in [('title', 'title'), ('shortSynopsis', 'description')]:
  62. value = item.get(src_key)
  63. if value:
  64. info[dst_key] = value
  65. info['series'] = try_get(
  66. item, lambda x: x['seriesLogo']['name'], compat_str)
  67. mobj = re.search(r'^S(\d+)\s+E(\d+)\s+-\s+(.+)$', info['title'])
  68. if mobj:
  69. info.update({
  70. 'season_number': int(mobj.group(1)),
  71. 'episode_number': int(mobj.group(2)),
  72. 'episode': mobj.group(3),
  73. })
  74. return info