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.

201 lines
7.0 KiB

10 years ago
  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. determine_ext,
  8. ExtractorError,
  9. int_or_none,
  10. NO_DEFAULT,
  11. urlencode_postdata,
  12. )
  13. class XFileShareIE(InfoExtractor):
  14. _SITES = (
  15. (r'daclips\.(?:in|com)', 'DaClips'),
  16. (r'filehoot\.com', 'FileHoot'),
  17. (r'gorillavid\.(?:in|com)', 'GorillaVid'),
  18. (r'movpod\.in', 'MovPod'),
  19. (r'powerwatch\.pw', 'PowerWatch'),
  20. (r'rapidvideo\.ws', 'Rapidvideo.ws'),
  21. (r'thevideobee\.to', 'TheVideoBee'),
  22. (r'vidto\.me', 'Vidto'),
  23. (r'streamin\.to', 'Streamin.To'),
  24. (r'xvidstage\.com', 'XVIDSTAGE'),
  25. (r'vidabc\.com', 'Vid ABC'),
  26. (r'vidbom\.com', 'VidBom'),
  27. (r'vidlo\.us', 'vidlo'),
  28. (r'rapidvideo\.(?:cool|org)', 'RapidVideo.TV'),
  29. (r'fastvideo\.me', 'FastVideo.me'),
  30. )
  31. IE_DESC = 'XFileShare based sites: %s' % ', '.join(list(zip(*_SITES))[1])
  32. _VALID_URL = (r'https?://(?P<host>(?:www\.)?(?:%s))/(?:embed-)?(?P<id>[0-9a-zA-Z]+)'
  33. % '|'.join(site for site in list(zip(*_SITES))[0]))
  34. _FILE_NOT_FOUND_REGEXES = (
  35. r'>(?:404 - )?File Not Found<',
  36. r'>The file was removed by administrator<',
  37. )
  38. _TESTS = [{
  39. 'url': 'http://gorillavid.in/06y9juieqpmi',
  40. 'md5': '5ae4a3580620380619678ee4875893ba',
  41. 'info_dict': {
  42. 'id': '06y9juieqpmi',
  43. 'ext': 'mp4',
  44. 'title': 'Rebecca Black My Moment Official Music Video Reaction-6GK87Rc8bzQ',
  45. 'thumbnail': r're:http://.*\.jpg',
  46. },
  47. }, {
  48. 'url': 'http://gorillavid.in/embed-z08zf8le23c6-960x480.html',
  49. 'only_matching': True,
  50. }, {
  51. 'url': 'http://daclips.in/3rso4kdn6f9m',
  52. 'md5': '1ad8fd39bb976eeb66004d3a4895f106',
  53. 'info_dict': {
  54. 'id': '3rso4kdn6f9m',
  55. 'ext': 'mp4',
  56. 'title': 'Micro Pig piglets ready on 16th July 2009-bG0PdrCdxUc',
  57. 'thumbnail': r're:http://.*\.jpg',
  58. }
  59. }, {
  60. 'url': 'http://movpod.in/0wguyyxi1yca',
  61. 'only_matching': True,
  62. }, {
  63. 'url': 'http://filehoot.com/3ivfabn7573c.html',
  64. 'info_dict': {
  65. 'id': '3ivfabn7573c',
  66. 'ext': 'mp4',
  67. 'title': 'youtube-dl test video \'äBaW_jenozKc.mp4.mp4',
  68. 'thumbnail': r're:http://.*\.jpg',
  69. },
  70. 'skip': 'Video removed',
  71. }, {
  72. 'url': 'http://vidto.me/ku5glz52nqe1.html',
  73. 'info_dict': {
  74. 'id': 'ku5glz52nqe1',
  75. 'ext': 'mp4',
  76. 'title': 'test'
  77. }
  78. }, {
  79. 'url': 'http://powerwatch.pw/duecjibvicbu',
  80. 'info_dict': {
  81. 'id': 'duecjibvicbu',
  82. 'ext': 'mp4',
  83. 'title': 'Big Buck Bunny trailer',
  84. },
  85. }, {
  86. 'url': 'http://xvidstage.com/e0qcnl03co6z',
  87. 'info_dict': {
  88. 'id': 'e0qcnl03co6z',
  89. 'ext': 'mp4',
  90. 'title': 'Chucky Prank 2015.mp4',
  91. },
  92. }, {
  93. # removed by administrator
  94. 'url': 'http://xvidstage.com/amfy7atlkx25',
  95. 'only_matching': True,
  96. }, {
  97. 'url': 'http://vidabc.com/i8ybqscrphfv',
  98. 'info_dict': {
  99. 'id': 'i8ybqscrphfv',
  100. 'ext': 'mp4',
  101. 'title': 're:Beauty and the Beast 2017',
  102. },
  103. 'params': {
  104. 'skip_download': True,
  105. },
  106. }, {
  107. 'url': 'http://www.rapidvideo.cool/b667kprndr8w',
  108. 'only_matching': True,
  109. }, {
  110. 'url': 'http://www.fastvideo.me/k8604r8nk8sn/FAST_FURIOUS_8_-_Trailer_italiano_ufficiale.mp4.html',
  111. 'only_matching': True
  112. }]
  113. def _real_extract(self, url):
  114. mobj = re.match(self._VALID_URL, url)
  115. video_id = mobj.group('id')
  116. url = 'http://%s/%s' % (mobj.group('host'), video_id)
  117. webpage = self._download_webpage(url, video_id)
  118. if any(re.search(p, webpage) for p in self._FILE_NOT_FOUND_REGEXES):
  119. raise ExtractorError('Video %s does not exist' % video_id, expected=True)
  120. fields = self._hidden_inputs(webpage)
  121. if fields['op'] == 'download1':
  122. countdown = int_or_none(self._search_regex(
  123. r'<span id="countdown_str">(?:[Ww]ait)?\s*<span id="cxc">(\d+)</span>\s*(?:seconds?)?</span>',
  124. webpage, 'countdown', default=None))
  125. if countdown:
  126. self._sleep(countdown, video_id)
  127. webpage = self._download_webpage(
  128. url, video_id, 'Downloading video page',
  129. data=urlencode_postdata(fields), headers={
  130. 'Referer': url,
  131. 'Content-type': 'application/x-www-form-urlencoded',
  132. })
  133. title = (self._search_regex(
  134. (r'style="z-index: [0-9]+;">([^<]+)</span>',
  135. r'<td nowrap>([^<]+)</td>',
  136. r'h4-fine[^>]*>([^<]+)<',
  137. r'>Watch (.+) ',
  138. r'<h2 class="video-page-head">([^<]+)</h2>',
  139. r'<h2 style="[^"]*color:#403f3d[^"]*"[^>]*>([^<]+)<'), # streamin.to
  140. webpage, 'title', default=None) or self._og_search_title(
  141. webpage, default=None) or video_id).strip()
  142. def extract_formats(default=NO_DEFAULT):
  143. urls = []
  144. for regex in (
  145. r'(?:file|src)\s*:\s*(["\'])(?P<url>http(?:(?!\1).)+\.(?:m3u8|mp4|flv)(?:(?!\1).)*)\1',
  146. r'file_link\s*=\s*(["\'])(?P<url>http(?:(?!\1).)+)\1',
  147. r'addVariable\((\\?["\'])file\1\s*,\s*(\\?["\'])(?P<url>http(?:(?!\2).)+)\2\)',
  148. r'<embed[^>]+src=(["\'])(?P<url>http(?:(?!\1).)+\.(?:m3u8|mp4|flv)(?:(?!\1).)*)\1'):
  149. for mobj in re.finditer(regex, webpage):
  150. video_url = mobj.group('url')
  151. if video_url not in urls:
  152. urls.append(video_url)
  153. formats = []
  154. for video_url in urls:
  155. if determine_ext(video_url) == 'm3u8':
  156. formats.extend(self._extract_m3u8_formats(
  157. video_url, video_id, 'mp4',
  158. entry_protocol='m3u8_native', m3u8_id='hls',
  159. fatal=False))
  160. else:
  161. formats.append({
  162. 'url': video_url,
  163. 'format_id': 'sd',
  164. })
  165. if not formats and default is not NO_DEFAULT:
  166. return default
  167. self._sort_formats(formats)
  168. return formats
  169. formats = extract_formats(default=None)
  170. if not formats:
  171. webpage = decode_packed_codes(self._search_regex(
  172. r"(}\('(.+)',(\d+),(\d+),'[^']*\b(?:file|embed)\b[^']*'\.split\('\|'\))",
  173. webpage, 'packed code'))
  174. formats = extract_formats()
  175. thumbnail = self._search_regex(
  176. r'image\s*:\s*["\'](http[^"\']+)["\'],', webpage, 'thumbnail', default=None)
  177. return {
  178. 'id': video_id,
  179. 'title': title,
  180. 'thumbnail': thumbnail,
  181. 'formats': formats,
  182. }