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.

194 lines
6.7 KiB

Switch codebase to use sanitized_Request instead of compat_urllib_request.Request [downloader/dash] Use sanitized_Request [downloader/http] Use sanitized_Request [atresplayer] Use sanitized_Request [bambuser] Use sanitized_Request [bliptv] Use sanitized_Request [brightcove] Use sanitized_Request [cbs] Use sanitized_Request [ceskatelevize] Use sanitized_Request [collegerama] Use sanitized_Request [extractor/common] Use sanitized_Request [crunchyroll] Use sanitized_Request [dailymotion] Use sanitized_Request [dcn] Use sanitized_Request [dramafever] Use sanitized_Request [dumpert] Use sanitized_Request [eitb] Use sanitized_Request [escapist] Use sanitized_Request [everyonesmixtape] Use sanitized_Request [extremetube] Use sanitized_Request [facebook] Use sanitized_Request [fc2] Use sanitized_Request [flickr] Use sanitized_Request [4tube] Use sanitized_Request [gdcvault] Use sanitized_Request [extractor/generic] Use sanitized_Request [hearthisat] Use sanitized_Request [hotnewhiphop] Use sanitized_Request [hypem] Use sanitized_Request [iprima] Use sanitized_Request [ivi] Use sanitized_Request [keezmovies] Use sanitized_Request [letv] Use sanitized_Request [lynda] Use sanitized_Request [metacafe] Use sanitized_Request [minhateca] Use sanitized_Request [miomio] Use sanitized_Request [meovideo] Use sanitized_Request [mofosex] Use sanitized_Request [moniker] Use sanitized_Request [mooshare] Use sanitized_Request [movieclips] Use sanitized_Request [mtv] Use sanitized_Request [myvideo] Use sanitized_Request [neteasemusic] Use sanitized_Request [nfb] Use sanitized_Request [niconico] Use sanitized_Request [noco] Use sanitized_Request [nosvideo] Use sanitized_Request [novamov] Use sanitized_Request [nowness] Use sanitized_Request [nuvid] Use sanitized_Request [played] Use sanitized_Request [pluralsight] Use sanitized_Request [pornhub] Use sanitized_Request [pornotube] Use sanitized_Request [primesharetv] Use sanitized_Request [promptfile] Use sanitized_Request [qqmusic] Use sanitized_Request [rtve] Use sanitized_Request [safari] Use sanitized_Request [sandia] Use sanitized_Request [shared] Use sanitized_Request [sharesix] Use sanitized_Request [sina] Use sanitized_Request [smotri] Use sanitized_Request [sohu] Use sanitized_Request [spankwire] Use sanitized_Request [sportdeutschland] Use sanitized_Request [streamcloud] Use sanitized_Request [streamcz] Use sanitized_Request [tapely] Use sanitized_Request [tube8] Use sanitized_Request [tubitv] Use sanitized_Request [twitch] Use sanitized_Request [twitter] Use sanitized_Request [udemy] Use sanitized_Request [vbox7] Use sanitized_Request [veoh] Use sanitized_Request [vessel] Use sanitized_Request [vevo] Use sanitized_Request [viddler] Use sanitized_Request [videomega] Use sanitized_Request [viewvster] Use sanitized_Request [viki] Use sanitized_Request [vk] Use sanitized_Request [vodlocker] Use sanitized_Request [voicerepublic] Use sanitized_Request [wistia] Use sanitized_Request [xfileshare] Use sanitized_Request [xtube] Use sanitized_Request [xvideos] Use sanitized_Request [yandexmusic] Use sanitized_Request [youku] Use sanitized_Request [youporn] Use sanitized_Request [youtube] Use sanitized_Request [patreon] Use sanitized_Request [extractor/common] Remove unused import [nfb] PEP 8
9 years ago
10 years ago
Switch codebase to use sanitized_Request instead of compat_urllib_request.Request [downloader/dash] Use sanitized_Request [downloader/http] Use sanitized_Request [atresplayer] Use sanitized_Request [bambuser] Use sanitized_Request [bliptv] Use sanitized_Request [brightcove] Use sanitized_Request [cbs] Use sanitized_Request [ceskatelevize] Use sanitized_Request [collegerama] Use sanitized_Request [extractor/common] Use sanitized_Request [crunchyroll] Use sanitized_Request [dailymotion] Use sanitized_Request [dcn] Use sanitized_Request [dramafever] Use sanitized_Request [dumpert] Use sanitized_Request [eitb] Use sanitized_Request [escapist] Use sanitized_Request [everyonesmixtape] Use sanitized_Request [extremetube] Use sanitized_Request [facebook] Use sanitized_Request [fc2] Use sanitized_Request [flickr] Use sanitized_Request [4tube] Use sanitized_Request [gdcvault] Use sanitized_Request [extractor/generic] Use sanitized_Request [hearthisat] Use sanitized_Request [hotnewhiphop] Use sanitized_Request [hypem] Use sanitized_Request [iprima] Use sanitized_Request [ivi] Use sanitized_Request [keezmovies] Use sanitized_Request [letv] Use sanitized_Request [lynda] Use sanitized_Request [metacafe] Use sanitized_Request [minhateca] Use sanitized_Request [miomio] Use sanitized_Request [meovideo] Use sanitized_Request [mofosex] Use sanitized_Request [moniker] Use sanitized_Request [mooshare] Use sanitized_Request [movieclips] Use sanitized_Request [mtv] Use sanitized_Request [myvideo] Use sanitized_Request [neteasemusic] Use sanitized_Request [nfb] Use sanitized_Request [niconico] Use sanitized_Request [noco] Use sanitized_Request [nosvideo] Use sanitized_Request [novamov] Use sanitized_Request [nowness] Use sanitized_Request [nuvid] Use sanitized_Request [played] Use sanitized_Request [pluralsight] Use sanitized_Request [pornhub] Use sanitized_Request [pornotube] Use sanitized_Request [primesharetv] Use sanitized_Request [promptfile] Use sanitized_Request [qqmusic] Use sanitized_Request [rtve] Use sanitized_Request [safari] Use sanitized_Request [sandia] Use sanitized_Request [shared] Use sanitized_Request [sharesix] Use sanitized_Request [sina] Use sanitized_Request [smotri] Use sanitized_Request [sohu] Use sanitized_Request [spankwire] Use sanitized_Request [sportdeutschland] Use sanitized_Request [streamcloud] Use sanitized_Request [streamcz] Use sanitized_Request [tapely] Use sanitized_Request [tube8] Use sanitized_Request [tubitv] Use sanitized_Request [twitch] Use sanitized_Request [twitter] Use sanitized_Request [udemy] Use sanitized_Request [vbox7] Use sanitized_Request [veoh] Use sanitized_Request [vessel] Use sanitized_Request [vevo] Use sanitized_Request [viddler] Use sanitized_Request [videomega] Use sanitized_Request [viewvster] Use sanitized_Request [viki] Use sanitized_Request [vk] Use sanitized_Request [vodlocker] Use sanitized_Request [voicerepublic] Use sanitized_Request [wistia] Use sanitized_Request [xfileshare] Use sanitized_Request [xtube] Use sanitized_Request [xvideos] Use sanitized_Request [yandexmusic] Use sanitized_Request [youku] Use sanitized_Request [youporn] Use sanitized_Request [youtube] Use sanitized_Request [patreon] Use sanitized_Request [extractor/common] Remove unused import [nfb] PEP 8
9 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. sanitized_Request,
  12. urlencode_postdata,
  13. )
  14. class XFileShareIE(InfoExtractor):
  15. _SITES = (
  16. (r'daclips\.(?:in|com)', 'DaClips'),
  17. (r'filehoot\.com', 'FileHoot'),
  18. (r'gorillavid\.(?:in|com)', 'GorillaVid'),
  19. (r'movpod\.in', 'MovPod'),
  20. (r'powerwatch\.pw', 'PowerWatch'),
  21. (r'rapidvideo\.ws', 'Rapidvideo.ws'),
  22. (r'thevideobee\.to', 'TheVideoBee'),
  23. (r'vidto\.me', 'Vidto'),
  24. (r'streamin\.to', 'Streamin.To'),
  25. (r'xvidstage\.com', 'XVIDSTAGE'),
  26. (r'vidabc\.com', 'Vid ABC'),
  27. (r'vidbom\.com', 'VidBom'),
  28. (r'vidlo\.us', 'vidlo'),
  29. )
  30. IE_DESC = 'XFileShare based sites: %s' % ', '.join(list(zip(*_SITES))[1])
  31. _VALID_URL = (r'https?://(?P<host>(?:www\.)?(?:%s))/(?:embed-)?(?P<id>[0-9a-zA-Z]+)'
  32. % '|'.join(site for site in list(zip(*_SITES))[0]))
  33. _FILE_NOT_FOUND_REGEXES = (
  34. r'>(?:404 - )?File Not Found<',
  35. r'>The file was removed by administrator<',
  36. )
  37. _TESTS = [{
  38. 'url': 'http://gorillavid.in/06y9juieqpmi',
  39. 'md5': '5ae4a3580620380619678ee4875893ba',
  40. 'info_dict': {
  41. 'id': '06y9juieqpmi',
  42. 'ext': 'mp4',
  43. 'title': 'Rebecca Black My Moment Official Music Video Reaction-6GK87Rc8bzQ',
  44. 'thumbnail': r're:http://.*\.jpg',
  45. },
  46. }, {
  47. 'url': 'http://gorillavid.in/embed-z08zf8le23c6-960x480.html',
  48. 'only_matching': True,
  49. }, {
  50. 'url': 'http://daclips.in/3rso4kdn6f9m',
  51. 'md5': '1ad8fd39bb976eeb66004d3a4895f106',
  52. 'info_dict': {
  53. 'id': '3rso4kdn6f9m',
  54. 'ext': 'mp4',
  55. 'title': 'Micro Pig piglets ready on 16th July 2009-bG0PdrCdxUc',
  56. 'thumbnail': r're:http://.*\.jpg',
  57. }
  58. }, {
  59. 'url': 'http://movpod.in/0wguyyxi1yca',
  60. 'only_matching': True,
  61. }, {
  62. 'url': 'http://filehoot.com/3ivfabn7573c.html',
  63. 'info_dict': {
  64. 'id': '3ivfabn7573c',
  65. 'ext': 'mp4',
  66. 'title': 'youtube-dl test video \'äBaW_jenozKc.mp4.mp4',
  67. 'thumbnail': r're:http://.*\.jpg',
  68. },
  69. 'skip': 'Video removed',
  70. }, {
  71. 'url': 'http://vidto.me/ku5glz52nqe1.html',
  72. 'info_dict': {
  73. 'id': 'ku5glz52nqe1',
  74. 'ext': 'mp4',
  75. 'title': 'test'
  76. }
  77. }, {
  78. 'url': 'http://powerwatch.pw/duecjibvicbu',
  79. 'info_dict': {
  80. 'id': 'duecjibvicbu',
  81. 'ext': 'mp4',
  82. 'title': 'Big Buck Bunny trailer',
  83. },
  84. }, {
  85. 'url': 'http://xvidstage.com/e0qcnl03co6z',
  86. 'info_dict': {
  87. 'id': 'e0qcnl03co6z',
  88. 'ext': 'mp4',
  89. 'title': 'Chucky Prank 2015.mp4',
  90. },
  91. }, {
  92. # removed by administrator
  93. 'url': 'http://xvidstage.com/amfy7atlkx25',
  94. 'only_matching': True,
  95. }, {
  96. 'url': 'http://vidabc.com/i8ybqscrphfv',
  97. 'info_dict': {
  98. 'id': 'i8ybqscrphfv',
  99. 'ext': 'mp4',
  100. 'title': 're:Beauty and the Beast 2017',
  101. },
  102. 'params': {
  103. 'skip_download': True,
  104. },
  105. }]
  106. def _real_extract(self, url):
  107. mobj = re.match(self._VALID_URL, url)
  108. video_id = mobj.group('id')
  109. url = 'http://%s/%s' % (mobj.group('host'), video_id)
  110. webpage = self._download_webpage(url, video_id)
  111. if any(re.search(p, webpage) for p in self._FILE_NOT_FOUND_REGEXES):
  112. raise ExtractorError('Video %s does not exist' % video_id, expected=True)
  113. fields = self._hidden_inputs(webpage)
  114. if fields['op'] == 'download1':
  115. countdown = int_or_none(self._search_regex(
  116. r'<span id="countdown_str">(?:[Ww]ait)?\s*<span id="cxc">(\d+)</span>\s*(?:seconds?)?</span>',
  117. webpage, 'countdown', default=None))
  118. if countdown:
  119. self._sleep(countdown, video_id)
  120. post = urlencode_postdata(fields)
  121. req = sanitized_Request(url, post)
  122. req.add_header('Content-type', 'application/x-www-form-urlencoded')
  123. webpage = self._download_webpage(req, video_id, 'Downloading video page')
  124. title = (self._search_regex(
  125. (r'style="z-index: [0-9]+;">([^<]+)</span>',
  126. r'<td nowrap>([^<]+)</td>',
  127. r'h4-fine[^>]*>([^<]+)<',
  128. r'>Watch (.+) ',
  129. r'<h2 class="video-page-head">([^<]+)</h2>',
  130. r'<h2 style="[^"]*color:#403f3d[^"]*"[^>]*>([^<]+)<'), # streamin.to
  131. webpage, 'title', default=None) or self._og_search_title(
  132. webpage, default=None) or video_id).strip()
  133. def extract_formats(default=NO_DEFAULT):
  134. urls = []
  135. for regex in (
  136. r'file\s*:\s*(["\'])(?P<url>http(?:(?!\1).)+\.(?:m3u8|mp4|flv)(?:(?!\1).)*)\1',
  137. r'file_link\s*=\s*(["\'])(?P<url>http(?:(?!\1).)+)\1',
  138. r'addVariable\((\\?["\'])file\1\s*,\s*(\\?["\'])(?P<url>http(?:(?!\2).)+)\2\)',
  139. r'<embed[^>]+src=(["\'])(?P<url>http(?:(?!\1).)+\.(?:m3u8|mp4|flv)(?:(?!\1).)*)\1'):
  140. for mobj in re.finditer(regex, webpage):
  141. video_url = mobj.group('url')
  142. if video_url not in urls:
  143. urls.append(video_url)
  144. formats = []
  145. for video_url in urls:
  146. if determine_ext(video_url) == 'm3u8':
  147. formats.extend(self._extract_m3u8_formats(
  148. video_url, video_id, 'mp4',
  149. entry_protocol='m3u8_native', m3u8_id='hls',
  150. fatal=False))
  151. else:
  152. formats.append({
  153. 'url': video_url,
  154. 'format_id': 'sd',
  155. })
  156. if not formats and default is not NO_DEFAULT:
  157. return default
  158. self._sort_formats(formats)
  159. return formats
  160. formats = extract_formats(default=None)
  161. if not formats:
  162. webpage = decode_packed_codes(self._search_regex(
  163. r"(}\('(.+)',(\d+),(\d+),'[^']*\b(?:file|embed)\b[^']*'\.split\('\|'\))",
  164. webpage, 'packed code'))
  165. formats = extract_formats()
  166. thumbnail = self._search_regex(
  167. r'image\s*:\s*["\'](http[^"\']+)["\'],', webpage, 'thumbnail', default=None)
  168. return {
  169. 'id': video_id,
  170. 'title': title,
  171. 'thumbnail': thumbnail,
  172. 'formats': formats,
  173. }