goshgay.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import urllib.parse
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. parse_duration,
  5. )
  6. class GoshgayIE(InfoExtractor):
  7. _VALID_URL = r'https?://(?:www\.)?goshgay\.com/video(?P<id>\d+?)($|/)'
  8. _TEST = {
  9. 'url': 'http://www.goshgay.com/video299069/diesel_sfw_xxx_video',
  10. 'md5': '4b6db9a0a333142eb9f15913142b0ed1',
  11. 'info_dict': {
  12. 'id': '299069',
  13. 'ext': 'flv',
  14. 'title': 'DIESEL SFW XXX Video',
  15. 'thumbnail': r're:^http://.*\.jpg$',
  16. 'duration': 80,
  17. 'age_limit': 18,
  18. },
  19. }
  20. def _real_extract(self, url):
  21. video_id = self._match_id(url)
  22. webpage = self._download_webpage(url, video_id)
  23. title = self._html_search_regex(
  24. r'<h2>(.*?)<', webpage, 'title')
  25. duration = parse_duration(self._html_search_regex(
  26. r'<span class="duration">\s*-?\s*(.*?)</span>',
  27. webpage, 'duration', fatal=False))
  28. flashvars = urllib.parse.parse_qs(self._html_search_regex(
  29. r'<embed.+?id="flash-player-embed".+?flashvars="([^"]+)"',
  30. webpage, 'flashvars'))
  31. thumbnail = flashvars.get('url_bigthumb', [None])[0]
  32. video_url = flashvars['flv_url'][0]
  33. return {
  34. 'id': video_id,
  35. 'url': video_url,
  36. 'title': title,
  37. 'thumbnail': thumbnail,
  38. 'duration': duration,
  39. 'age_limit': 18,
  40. }