gorillavid.py 2.9 KB

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