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.

76 lines
2.3 KiB

  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. determine_ext,
  7. compat_urllib_parse,
  8. compat_urllib_request,
  9. )
  10. class GorillaVidIE(InfoExtractor):
  11. _VALID_URL = r'https?://(?:www\.)?gorillavid\.in/(?:embed-)?(?P<id>[0-9a-zA-Z]+)(?:-[0-9]+x[0-9]+\.html)?'
  12. _TESTS = [{
  13. 'url': 'http://gorillavid.in/06y9juieqpmi',
  14. 'md5': '5ae4a3580620380619678ee4875893ba',
  15. 'info_dict': {
  16. 'id': '06y9juieqpmi',
  17. 'ext': 'flv',
  18. 'title': 'Rebecca Black My Moment Official Music Video Reaction',
  19. 'thumbnail': 're:http://.*\.jpg',
  20. },
  21. }, {
  22. 'url': 'http://gorillavid.in/embed-z08zf8le23c6-960x480.html',
  23. 'md5': 'c9e293ca74d46cad638e199c3f3fe604',
  24. 'info_dict': {
  25. 'id': 'z08zf8le23c6',
  26. 'ext': 'mp4',
  27. 'title': 'Say something nice',
  28. 'thumbnail': 're:http://.*\.jpg',
  29. },
  30. }]
  31. def _real_extract(self, url):
  32. mobj = re.match(self._VALID_URL, url)
  33. video_id = mobj.group('id')
  34. url = 'http://gorillavid.in/%s' % video_id
  35. webpage = self._download_webpage(url, video_id)
  36. fields = dict(re.findall(r'''(?x)<input\s+
  37. type="hidden"\s+
  38. name="([^"]+)"\s+
  39. (?:id="[^"]+"\s+)?
  40. value="([^"]*)"
  41. ''', webpage))
  42. if fields['op'] == 'download1':
  43. post = compat_urllib_parse.urlencode(fields)
  44. req = compat_urllib_request.Request(url, post)
  45. req.add_header('Content-type', 'application/x-www-form-urlencoded')
  46. webpage = self._download_webpage(req, video_id, 'Downloading video page')
  47. title = self._search_regex(r'style="z-index: [0-9]+;">([0-9a-zA-Z ]+)(?:-.+)?</span>', webpage, 'title')
  48. thumbnail = self._search_regex(r'image:\'(http[^\']+)\',', webpage, 'thumbnail')
  49. url = self._search_regex(r'file: \'(http[^\']+)\',', webpage, 'file url')
  50. formats = [{
  51. 'format_id': 'sd',
  52. 'url': url,
  53. 'ext': determine_ext(url),
  54. 'quality': 1,
  55. }]
  56. return {
  57. 'id': video_id,
  58. 'title': title,
  59. 'thumbnail': thumbnail,
  60. 'formats': formats,
  61. }