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.

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