trunews.py 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. from .common import InfoExtractor
  2. class TruNewsIE(InfoExtractor):
  3. _VALID_URL = r'https?://(?:www\.)?trunews\.com/stream/(?P<id>[^/?#&]+)'
  4. _TEST = {
  5. 'url': 'https://www.trunews.com/stream/will-democrats-stage-a-circus-during-president-trump-s-state-of-the-union-speech',
  6. 'info_dict': {
  7. 'id': '5c5a21e65d3c196e1c0020cc',
  8. 'display_id': 'will-democrats-stage-a-circus-during-president-trump-s-state-of-the-union-speech',
  9. 'ext': 'mp4',
  10. 'title': "Will Democrats Stage a Circus During President Trump's State of the Union Speech?",
  11. 'description': 'md5:c583b72147cc92cf21f56a31aff7a670',
  12. 'duration': 3685,
  13. 'timestamp': 1549411440,
  14. 'upload_date': '20190206',
  15. },
  16. 'add_ie': ['Zype'],
  17. }
  18. _ZYPE_TEMPL = 'https://player.zype.com/embed/%s.js?api_key=X5XnahkjCwJrT_l5zUqypnaLEObotyvtUKJWWlONxDoHVjP8vqxlArLV8llxMbyt'
  19. def _real_extract(self, url):
  20. display_id = self._match_id(url)
  21. zype_id = self._download_json(
  22. 'https://api.zype.com/videos', display_id, query={
  23. 'app_key': 'PUVKp9WgGUb3-JUw6EqafLx8tFVP6VKZTWbUOR-HOm__g4fNDt1bCsm_LgYf_k9H',
  24. 'per_page': 1,
  25. 'active': 'true',
  26. 'friendly_title': display_id,
  27. })['response'][0]['_id']
  28. return self.url_result(self._ZYPE_TEMPL % zype_id, 'Zype', zype_id)