bigflix.py 2.1 KB

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