xfileshare.py 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. decode_packed_codes,
  7. ExtractorError,
  8. int_or_none,
  9. NO_DEFAULT,
  10. sanitized_Request,
  11. urlencode_postdata,
  12. )
  13. class XFileShareIE(InfoExtractor):
  14. _SITES = (
  15. ('daclips.in', 'DaClips'),
  16. ('filehoot.com', 'FileHoot'),
  17. ('gorillavid.in', 'GorillaVid'),
  18. ('movpod.in', 'MovPod'),
  19. ('powerwatch.pw', 'PowerWatch'),
  20. ('rapidvideo.ws', 'Rapidvideo.ws'),
  21. ('thevideobee.to', 'TheVideoBee'),
  22. ('vidto.me', 'Vidto'),
  23. ('streamin.to', 'Streamin.To'),
  24. ('xvidstage.com', 'XVIDSTAGE'),
  25. )
  26. IE_DESC = 'XFileShare based sites: %s' % ', '.join(list(zip(*_SITES))[1])
  27. _VALID_URL = (r'https?://(?P<host>(?:www\.)?(?:%s))/(?:embed-)?(?P<id>[0-9a-zA-Z]+)'
  28. % '|'.join(re.escape(site) for site in list(zip(*_SITES))[0]))
  29. _FILE_NOT_FOUND_REGEX = r'>(?:404 - )?File Not Found<'
  30. _TESTS = [{
  31. 'url': 'http://gorillavid.in/06y9juieqpmi',
  32. 'md5': '5ae4a3580620380619678ee4875893ba',
  33. 'info_dict': {
  34. 'id': '06y9juieqpmi',
  35. 'ext': 'flv',
  36. 'title': 'Rebecca Black My Moment Official Music Video Reaction-6GK87Rc8bzQ',
  37. 'thumbnail': 're:http://.*\.jpg',
  38. },
  39. }, {
  40. 'url': 'http://gorillavid.in/embed-z08zf8le23c6-960x480.html',
  41. 'only_matching': True,
  42. }, {
  43. 'url': 'http://daclips.in/3rso4kdn6f9m',
  44. 'md5': '1ad8fd39bb976eeb66004d3a4895f106',
  45. 'info_dict': {
  46. 'id': '3rso4kdn6f9m',
  47. 'ext': 'mp4',
  48. 'title': 'Micro Pig piglets ready on 16th July 2009-bG0PdrCdxUc',
  49. 'thumbnail': 're:http://.*\.jpg',
  50. }
  51. }, {
  52. 'url': 'http://movpod.in/0wguyyxi1yca',
  53. 'only_matching': True,
  54. }, {
  55. 'url': 'http://filehoot.com/3ivfabn7573c.html',
  56. 'info_dict': {
  57. 'id': '3ivfabn7573c',
  58. 'ext': 'mp4',
  59. 'title': 'youtube-dl test video \'äBaW_jenozKc.mp4.mp4',
  60. 'thumbnail': 're:http://.*\.jpg',
  61. },
  62. 'skip': 'Video removed',
  63. }, {
  64. 'url': 'http://vidto.me/ku5glz52nqe1.html',
  65. 'info_dict': {
  66. 'id': 'ku5glz52nqe1',
  67. 'ext': 'mp4',
  68. 'title': 'test'
  69. }
  70. }, {
  71. 'url': 'http://powerwatch.pw/duecjibvicbu',
  72. 'info_dict': {
  73. 'id': 'duecjibvicbu',
  74. 'ext': 'mp4',
  75. 'title': 'Big Buck Bunny trailer',
  76. },
  77. }, {
  78. 'url': 'http://xvidstage.com/e0qcnl03co6z',
  79. 'info_dict': {
  80. 'id': 'e0qcnl03co6z',
  81. 'ext': 'mp4',
  82. 'title': 'Chucky Prank 2015.mp4',
  83. },
  84. }]
  85. def _real_extract(self, url):
  86. mobj = re.match(self._VALID_URL, url)
  87. video_id = mobj.group('id')
  88. url = 'http://%s/%s' % (mobj.group('host'), video_id)
  89. webpage = self._download_webpage(url, video_id)
  90. if re.search(self._FILE_NOT_FOUND_REGEX, webpage) is not None:
  91. raise ExtractorError('Video %s does not exist' % video_id, expected=True)
  92. fields = self._hidden_inputs(webpage)
  93. if fields['op'] == 'download1':
  94. countdown = int_or_none(self._search_regex(
  95. r'<span id="countdown_str">(?:[Ww]ait)?\s*<span id="cxc">(\d+)</span>\s*(?:seconds?)?</span>',
  96. webpage, 'countdown', default=None))
  97. if countdown:
  98. self._sleep(countdown, video_id)
  99. post = urlencode_postdata(fields)
  100. req = sanitized_Request(url, post)
  101. req.add_header('Content-type', 'application/x-www-form-urlencoded')
  102. webpage = self._download_webpage(req, video_id, 'Downloading video page')
  103. title = (self._search_regex(
  104. [r'style="z-index: [0-9]+;">([^<]+)</span>',
  105. r'<td nowrap>([^<]+)</td>',
  106. r'h4-fine[^>]*>([^<]+)<',
  107. r'>Watch (.+) ',
  108. r'<h2 class="video-page-head">([^<]+)</h2>'],
  109. webpage, 'title', default=None) or self._og_search_title(webpage)).strip()
  110. def extract_video_url(default=NO_DEFAULT):
  111. return self._search_regex(
  112. (r'file\s*:\s*(["\'])(?P<url>http.+?)\1,',
  113. r'file_link\s*=\s*(["\'])(?P<url>http.+?)\1',
  114. r'addVariable\((\\?["\'])file\1\s*,\s*(\\?["\'])(?P<url>http.+?)\2\)',
  115. r'<embed[^>]+src=(["\'])(?P<url>http.+?)\1'),
  116. webpage, 'file url', default=default, group='url')
  117. video_url = extract_video_url(default=None)
  118. if not video_url:
  119. webpage = decode_packed_codes(self._search_regex(
  120. r"(}\('(.+)',(\d+),(\d+),'[^']*\b(?:file|embed)\b[^']*'\.split\('\|'\))",
  121. webpage, 'packed code'))
  122. video_url = extract_video_url()
  123. thumbnail = self._search_regex(
  124. r'image\s*:\s*["\'](http[^"\']+)["\'],', webpage, 'thumbnail', default=None)
  125. formats = [{
  126. 'format_id': 'sd',
  127. 'url': video_url,
  128. 'quality': 1,
  129. }]
  130. return {
  131. 'id': video_id,
  132. 'title': title,
  133. 'thumbnail': thumbnail,
  134. 'formats': formats,
  135. }