logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

bigflix.py (2334B)


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