gorillavid.py 2.8 KB

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