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.

58 lines
1.8 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. compat_urlparse,
  6. ExtractorError,
  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/video4116282',
  12. 'md5': '268b9f3c3229105c57859e166dd72b03',
  13. 'info_dict': {
  14. 'id': '4116282',
  15. 'ext': 'flv',
  16. 'title': 'md5:089833a4790b5e103285a07337f245bf',
  17. 'thumbnail': 're:http://.*\.jpg',
  18. 'age_limit': 18,
  19. }
  20. }
  21. def _real_extract(self, url):
  22. video_id = self._match_id(url)
  23. webpage = self._download_webpage(url, video_id)
  24. title = self._og_search_title(webpage)
  25. thumbnail = self._og_search_thumbnail(webpage)
  26. family_friendly = self._html_search_meta(
  27. 'isFamilyFriendly', webpage, default='false')
  28. config_url = self._search_regex(
  29. r"'config'\s*:\s*'([^']+)'", webpage, 'config URL')
  30. config = self._download_xml(
  31. config_url, video_id, 'Downloading player config XML')
  32. if config is None:
  33. raise ExtractorError('Missing config XML')
  34. if config.tag != 'config':
  35. raise ExtractorError('Missing config attribute')
  36. fns = config.findall('file')
  37. if len(fns) < 1:
  38. raise ExtractorError('Missing media URI')
  39. video_url = fns[0].text
  40. url_comp = compat_urlparse.urlparse(url)
  41. ref = "%s://%s%s" % (url_comp[0], url_comp[1], url_comp[2])
  42. return {
  43. 'id': video_id,
  44. 'url': video_url,
  45. 'title': title,
  46. 'thumbnail': thumbnail,
  47. 'http_referer': ref,
  48. 'age_limit': 0 if family_friendly == 'true' else 18,
  49. }