goshgay.py 1.5 KB

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