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.

97 lines
3.1 KiB

  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. determine_ext,
  8. compat_urllib_parse,
  9. compat_urllib_request,
  10. )
  11. class GorillaVidIE(InfoExtractor):
  12. IE_DESC = 'GorillaVid.in, daclips.in and movpod.in'
  13. _VALID_URL = r'''(?x)
  14. https?://(?P<host>(?:www\.)?
  15. (?:daclips\.in|gorillavid\.in|movpod\.in))/
  16. (?:embed-)?(?P<id>[0-9a-zA-Z]+)(?:-[0-9]+x[0-9]+\.html)?
  17. '''
  18. _FILE_NOT_FOUND_REGEX = r'>(?:404 - )?File Not Found<'
  19. _TESTS = [{
  20. 'url': 'http://gorillavid.in/06y9juieqpmi',
  21. 'md5': '5ae4a3580620380619678ee4875893ba',
  22. 'info_dict': {
  23. 'id': '06y9juieqpmi',
  24. 'ext': 'flv',
  25. 'title': 'Rebecca Black My Moment Official Music Video Reaction-6GK87Rc8bzQ',
  26. 'thumbnail': 're:http://.*\.jpg',
  27. },
  28. }, {
  29. 'url': 'http://gorillavid.in/embed-z08zf8le23c6-960x480.html',
  30. 'md5': 'c9e293ca74d46cad638e199c3f3fe604',
  31. 'info_dict': {
  32. 'id': 'z08zf8le23c6',
  33. 'ext': 'mp4',
  34. 'title': 'Say something nice',
  35. 'thumbnail': 're:http://.*\.jpg',
  36. },
  37. }, {
  38. 'url': 'http://daclips.in/3rso4kdn6f9m',
  39. 'md5': '1ad8fd39bb976eeb66004d3a4895f106',
  40. 'info_dict': {
  41. 'id': '3rso4kdn6f9m',
  42. 'ext': 'mp4',
  43. 'title': 'Micro Pig piglets ready on 16th July 2009',
  44. 'thumbnail': 're:http://.*\.jpg',
  45. },
  46. }, {
  47. 'url': 'http://movpod.in/0wguyyxi1yca',
  48. 'only_matching': True,
  49. }]
  50. def _real_extract(self, url):
  51. mobj = re.match(self._VALID_URL, url)
  52. video_id = mobj.group('id')
  53. webpage = self._download_webpage('http://%s/%s' % (mobj.group('host'), video_id), video_id)
  54. if re.search(self._FILE_NOT_FOUND_REGEX, webpage) is not None:
  55. raise ExtractorError('Video %s does not exist' % video_id, expected=True)
  56. fields = dict(re.findall(r'''(?x)<input\s+
  57. type="hidden"\s+
  58. name="([^"]+)"\s+
  59. (?:id="[^"]+"\s+)?
  60. value="([^"]*)"
  61. ''', webpage))
  62. if fields['op'] == 'download1':
  63. post = compat_urllib_parse.urlencode(fields)
  64. req = compat_urllib_request.Request(url, post)
  65. req.add_header('Content-type', 'application/x-www-form-urlencoded')
  66. webpage = self._download_webpage(req, video_id, 'Downloading video page')
  67. title = self._search_regex(r'style="z-index: [0-9]+;">([^<]+)</span>', webpage, 'title')
  68. video_url = self._search_regex(r'file\s*:\s*\'(http[^\']+)\',', webpage, 'file url')
  69. thumbnail = self._search_regex(r'image\s*:\s*\'(http[^\']+)\',', webpage, 'thumbnail', fatal=False)
  70. formats = [{
  71. 'format_id': 'sd',
  72. 'url': video_url,
  73. 'ext': determine_ext(video_url),
  74. 'quality': 1,
  75. }]
  76. return {
  77. 'id': video_id,
  78. 'title': title,
  79. 'thumbnail': thumbnail,
  80. 'formats': formats,
  81. }