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.2 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': r'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': int(height),
  31. } for height, video_path in re.findall(r"RJ\.video(\d+)p\s*=\s*'/?([^']+)'", webpage)]
  32. self._sort_formats(formats)
  33. title = self._og_search_title(webpage)
  34. thumbnail = self._og_search_thumbnail(webpage)
  35. upload_date = unified_strdate(self._search_regex(
  36. r'class="date_added">Date added: ([^<]+)<',
  37. webpage, 'upload date', fatal=False))
  38. view_count = str_to_int(self._search_regex(
  39. r'class="views">Plays: ([\d,]+)',
  40. webpage, 'view count', fatal=False))
  41. like_count = str_to_int(self._search_regex(
  42. r'class="rating">([\d,]+) likes',
  43. webpage, 'like count', fatal=False))
  44. dislike_count = str_to_int(self._search_regex(
  45. r'class="rating">([\d,]+) dislikes',
  46. webpage, 'dislike count', fatal=False))
  47. return {
  48. 'id': video_id,
  49. 'title': title,
  50. 'thumbnail': thumbnail,
  51. 'upload_date': upload_date,
  52. 'view_count': view_count,
  53. 'like_count': like_count,
  54. 'dislike_count': dislike_count,
  55. 'formats': formats,
  56. }