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.

138 lines
4.6 KiB

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