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.

55 lines
1.8 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. class TelewebionIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www\.)?telewebion\.com/#!/episode/(?P<id>\d+)'
  6. _TEST = {
  7. 'url': 'http://www.telewebion.com/#!/episode/1263668/',
  8. 'info_dict': {
  9. 'id': '1263668',
  10. 'ext': 'mp4',
  11. 'title': 'قرعه\u200cکشی لیگ قهرمانان اروپا',
  12. 'thumbnail': r're:^https?://.*\.jpg',
  13. 'view_count': int,
  14. },
  15. 'params': {
  16. # m3u8 download
  17. 'skip_download': True,
  18. },
  19. }
  20. def _real_extract(self, url):
  21. video_id = self._match_id(url)
  22. secure_token = self._download_webpage(
  23. 'http://m.s2.telewebion.com/op/op?action=getSecurityToken', video_id)
  24. episode_details = self._download_json(
  25. 'http://m.s2.telewebion.com/op/op', video_id,
  26. query={'action': 'getEpisodeDetails', 'episode_id': video_id})
  27. m3u8_url = 'http://m.s1.telewebion.com/smil/%s.m3u8?filepath=%s&m3u8=1&secure_token=%s' % (
  28. video_id, episode_details['file_path'], secure_token)
  29. formats = self._extract_m3u8_formats(
  30. m3u8_url, video_id, ext='mp4', m3u8_id='hls')
  31. picture_paths = [
  32. episode_details.get('picture_path'),
  33. episode_details.get('large_picture_path'),
  34. ]
  35. thumbnails = [{
  36. 'url': picture_path,
  37. 'preference': idx,
  38. } for idx, picture_path in enumerate(picture_paths) if picture_path is not None]
  39. return {
  40. 'id': video_id,
  41. 'title': episode_details['title'],
  42. 'formats': formats,
  43. 'thumbnails': thumbnails,
  44. 'view_count': episode_details.get('view_count'),
  45. }