trollvids.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. from .nuevo import NuevoBaseIE
  4. from ..compat import (
  5. compat_urllib_parse_unquote
  6. )
  7. import re
  8. class TrollvidsIE(NuevoBaseIE):
  9. _VALID_URL = r'http://(?:www\.)?trollvids\.com/+video/+(?P<id>[0-9]+)/+(?P<title>[^?&]+)'
  10. IE_NAME = 'trollvids'
  11. def _real_extract(self, url):
  12. match = re.match(self._VALID_URL, url)
  13. video_id = match.group('id')
  14. raw_video_title = match.group('title')
  15. url = 'http://trollvids.com/video/%s/%s' % (video_id, raw_video_title)
  16. config_url = 'http://trollvids.com/nuevo/player/config.php?v=%s' % video_id
  17. info = self._extract_nuevo(config_url, video_id)
  18. info.update({
  19. 'webpage_url': url,
  20. 'age_limit': 18
  21. })
  22. if 'title' not in info:
  23. info['title'] = compat_urllib_parse_unquote(raw_video_title)
  24. return info
  25. _TESTS = [
  26. {
  27. 'url': 'http://trollvids.com/video/2349002/%E3%80%90MMD-R-18%E3%80%91%E3%82%AC%E3%83%BC%E3%83%AB%E3%83%95%E3%83%AC%E3%83%B3%E3%83%89-carrymeoff',
  28. 'md5': '1d53866b2c514b23ed69e4352fdc9839',
  29. 'info_dict': {
  30. 'id': '2349002',
  31. 'ext': 'mp4',
  32. 'title': "【MMD R-18】ガールフレンド carry_me_off",
  33. 'age_limit': 18,
  34. 'duration': 216.78,
  35. },
  36. },
  37. ]