behindkink.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import url_basename
  6. class BehindKinkIE(InfoExtractor):
  7. _VALID_URL = r'(?:http://)(?:www\.)?behindkink\.com/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/(?P<day>[0-9]{2})/(?P<id>[^/?_]+)'
  8. _TEST = {
  9. 'url': 'http://www.behindkink.com/2014/08/14/ab1576-performers-voice-finally-heard-the-bill-is-killed/',
  10. 'md5': '41ad01222b8442089a55528fec43ec01',
  11. 'info_dict': {
  12. 'id': '36370',
  13. 'ext': 'mp4',
  14. 'title': 'AB1576 - PERFORMERS VOICE FINALLY HEARD - THE BILL IS KILLED!',
  15. 'description': 'The adult industry voice was finally heard as Assembly Bill 1576 remained\xa0 in suspense today at the Senate Appropriations Hearing. AB1576 was, among other industry damaging issues, a condom mandate...',
  16. 'upload_date': '20140814',
  17. 'thumbnail': 'http://www.behindkink.com/wp-content/uploads/2014/08/36370_AB1576_Win.jpg',
  18. 'age_limit': 18,
  19. }
  20. }
  21. def _real_extract(self, url):
  22. mobj = re.match(self._VALID_URL, url)
  23. display_id = mobj.group('id')
  24. year = mobj.group('year')
  25. month = mobj.group('month')
  26. day = mobj.group('day')
  27. upload_date = year + month + day
  28. webpage_url = 'http://www.behindkink.com/' + year + '/' + month + '/' + day + '/' + display_id
  29. webpage = self._download_webpage(webpage_url, display_id)
  30. self.report_extraction(display_id)
  31. video_url = self._search_regex(
  32. r"'file':\s*'([^']+)'",
  33. webpage, 'URL base')
  34. video_id = url_basename(video_url)
  35. video_id = video_id.split('_')[0]
  36. self.report_extraction(video_id)
  37. return {
  38. 'id': video_id,
  39. 'url': video_url,
  40. 'ext': 'mp4',
  41. 'title': self._og_search_title(webpage),
  42. 'display_id': display_id,
  43. 'thumbnail': self._og_search_thumbnail(webpage),
  44. 'description': self._og_search_description(webpage),
  45. 'upload_date': upload_date,
  46. 'age_limit': 18,
  47. }