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.

85 lines
2.6 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import base64
  4. import re
  5. from .common import InfoExtractor
  6. from ..compat import compat_urllib_parse_unquote
  7. class BigflixIE(InfoExtractor):
  8. _VALID_URL = r'https?://(?:www\.)?bigflix\.com/.+/(?P<id>[0-9]+)'
  9. _TESTS = [{
  10. 'url': 'http://www.bigflix.com/Hindi-movies/Action-movies/Singham-Returns/16537',
  11. 'md5': 'dc1b4aebb46e3a7077ecc0d9f43f61e3',
  12. 'info_dict': {
  13. 'id': '16537',
  14. 'ext': 'mp4',
  15. 'title': 'Singham Returns',
  16. 'description': 'md5:3d2ba5815f14911d5cc6a501ae0cf65d',
  17. }
  18. }, {
  19. # 2 formats
  20. 'url': 'http://www.bigflix.com/Tamil-movies/Drama-movies/Madarasapatinam/16070',
  21. 'info_dict': {
  22. 'id': '16070',
  23. 'ext': 'mp4',
  24. 'title': 'Madarasapatinam',
  25. 'description': 'md5:9f0470b26a4ba8e824c823b5d95c2f6b',
  26. 'formats': 'mincount:2',
  27. },
  28. 'params': {
  29. 'skip_download': True,
  30. }
  31. }, {
  32. # multiple formats
  33. 'url': 'http://www.bigflix.com/Malayalam-movies/Drama-movies/Indian-Rupee/15967',
  34. 'only_matching': True,
  35. }]
  36. def _real_extract(self, url):
  37. video_id = self._match_id(url)
  38. webpage = self._download_webpage(url, video_id)
  39. title = self._html_search_regex(
  40. r'<div[^>]+class=["\']pagetitle["\'][^>]*>(.+?)</div>',
  41. webpage, 'title')
  42. def decode_url(quoted_b64_url):
  43. return base64.b64decode(compat_urllib_parse_unquote(
  44. quoted_b64_url).encode('ascii')).decode('utf-8')
  45. formats = []
  46. for height, encoded_url in re.findall(
  47. r'ContentURL_(\d{3,4})[pP][^=]+=([^&]+)', webpage):
  48. video_url = decode_url(encoded_url)
  49. f = {
  50. 'url': video_url,
  51. 'format_id': '%sp' % height,
  52. 'height': int(height),
  53. }
  54. if video_url.startswith('rtmp'):
  55. f['ext'] = 'flv'
  56. formats.append(f)
  57. file_url = self._search_regex(
  58. r'file=([^&]+)', webpage, 'video url', default=None)
  59. if file_url:
  60. video_url = decode_url(file_url)
  61. if all(f['url'] != video_url for f in formats):
  62. formats.append({
  63. 'url': decode_url(file_url),
  64. })
  65. self._sort_formats(formats)
  66. description = self._html_search_meta('description', webpage)
  67. return {
  68. 'id': video_id,
  69. 'title': title,
  70. 'description': description,
  71. 'formats': formats
  72. }