xfileshare.py 4.3 KB

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