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.

75 lines
2.5 KiB

  1. from .common import InfoExtractor
  2. import re
  3. class ToypicsIE(InfoExtractor):
  4. IE_DESC = 'Toypics user profile'
  5. _VALID_URL = r'http://videos\.toypics\.net/view/(?P<id>[0-9]+)/.*'
  6. _TEST = {
  7. 'url': 'http://videos.toypics.net/view/514/chancebulged,-2-1/',
  8. 'md5': '16e806ad6d6f58079d210fe30985e08b',
  9. 'info_dict': {
  10. 'id': '514',
  11. 'ext': 'mp4',
  12. 'title': 'Chance-Bulge\'d, 2',
  13. 'age_limit': 18,
  14. 'uploader': 'kidsune',
  15. }
  16. }
  17. def _real_extract(self, url):
  18. mobj = re.match(self._VALID_URL, url)
  19. video_id = mobj.group('id')
  20. page = self._download_webpage(url, video_id)
  21. video_url = self._html_search_regex(
  22. r'src:\s+"(http://static[0-9]+\.toypics\.net/flvideo/[^"]+)"', page, 'video URL')
  23. title = self._html_search_regex(
  24. r'<title>Toypics - ([^<]+)</title>', page, 'title')
  25. username = self._html_search_regex(
  26. r'toypics.net/([^/"]+)" class="user-name">', page, 'username')
  27. return {
  28. 'id': video_id,
  29. 'url': video_url,
  30. 'title': title,
  31. 'uploader': username,
  32. 'age_limit': 18,
  33. }
  34. class ToypicsUserIE(InfoExtractor):
  35. IE_DESC = 'Toypics user profile'
  36. _VALID_URL = r'http://videos\.toypics\.net/(?P<username>[^/?]+)(?:$|[?#])'
  37. def _real_extract(self, url):
  38. mobj = re.match(self._VALID_URL, url)
  39. username = mobj.group('username')
  40. profile_page = self._download_webpage(
  41. url, username, note='Retrieving profile page')
  42. video_count = int(self._search_regex(
  43. r'public/">Public Videos \(([0-9]+)\)</a></li>', profile_page,
  44. 'video count'))
  45. PAGE_SIZE = 8
  46. urls = []
  47. page_count = (video_count + PAGE_SIZE + 1) // PAGE_SIZE
  48. for n in range(1, page_count + 1):
  49. lpage_url = url + '/public/%d' % n
  50. lpage = self._download_webpage(
  51. lpage_url, username,
  52. note='Downloading page %d/%d' % (n, page_count))
  53. urls.extend(
  54. re.findall(
  55. r'<p class="video-entry-title">\n\s*<a href="(http://videos.toypics.net/view/[^"]+)">',
  56. lpage))
  57. return {
  58. '_type': 'playlist',
  59. 'id': username,
  60. 'entries': [{
  61. '_type': 'url',
  62. 'url': eurl,
  63. 'ie_key': 'Toypics',
  64. } for eurl in urls]
  65. }