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.

66 lines
2.1 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import(
  5. unified_strdate,
  6. str_to_int,
  7. )
  8. class RadioJavanIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:www\.)?radiojavan\.com/videos/video/(?P<id>[^/]+)/?'
  10. _TEST = {
  11. 'url': 'http://www.radiojavan.com/videos/video/chaartaar-ashoobam',
  12. 'md5': 'e85208ffa3ca8b83534fca9fe19af95b',
  13. 'info_dict': {
  14. 'id': 'chaartaar-ashoobam',
  15. 'ext': 'mp4',
  16. 'title': 'Chaartaar - Ashoobam',
  17. 'thumbnail': 're:^https?://.*\.jpe?g$',
  18. 'upload_date': '20150215',
  19. 'view_count': int,
  20. 'like_count': int,
  21. 'dislike_count': int,
  22. }
  23. }
  24. def _real_extract(self, url):
  25. video_id = self._match_id(url)
  26. webpage = self._download_webpage(url, video_id)
  27. formats = [{
  28. 'url': 'https://media.rdjavan.com/media/music_video/%s' % video_path,
  29. 'format_id': '%sp' % height,
  30. 'height': height,
  31. } for height, video_path in re.findall(r"RJ\.video(\d+)p\s*=\s*'/?([^']+)'", webpage)]
  32. title = self._og_search_title(webpage)
  33. thumbnail = self._og_search_thumbnail(webpage)
  34. upload_date = unified_strdate(self._search_regex(
  35. r'class="date_added">Date added: ([^<]+)<',
  36. webpage, 'upload date', fatal=False))
  37. view_count = str_to_int(self._search_regex(
  38. r'class="views">Plays: ([\d,]+)',
  39. webpage, 'view count', fatal=False))
  40. like_count = str_to_int(self._search_regex(
  41. r'class="rating">([\d,]+) likes',
  42. webpage, 'like count', fatal=False))
  43. dislike_count = str_to_int(self._search_regex(
  44. r'class="rating">([\d,]+) dislikes',
  45. webpage, 'dislike count', fatal=False))
  46. return {
  47. 'id': video_id,
  48. 'title': title,
  49. 'thumbnail': thumbnail,
  50. 'upload_date': upload_date,
  51. 'view_count': view_count,
  52. 'like_count': like_count,
  53. 'dislike_count': dislike_count,
  54. 'formats': formats,
  55. }