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.

46 lines
1.7 KiB

  1. from __future__ import unicode_literals
  2. import json
  3. import re
  4. from .common import InfoExtractor
  5. from ..compat import compat_urllib_parse
  6. class PhotobucketIE(InfoExtractor):
  7. _VALID_URL = r'http://(?:[a-z0-9]+\.)?photobucket\.com/.*(([\?\&]current=)|_)(?P<id>.*)\.(?P<ext>(flv)|(mp4))'
  8. _TEST = {
  9. 'url': 'http://media.photobucket.com/user/rachaneronas/media/TiredofLinkBuildingTryBacklinkMyDomaincom_zpsc0c3b9fa.mp4.html?filters[term]=search&filters[primary]=videos&filters[secondary]=images&sort=1&o=0',
  10. 'md5': '7dabfb92b0a31f6c16cebc0f8e60ff99',
  11. 'info_dict': {
  12. 'id': 'zpsc0c3b9fa',
  13. 'ext': 'mp4',
  14. 'timestamp': 1367669341,
  15. 'upload_date': '20130504',
  16. 'uploader': 'rachaneronas',
  17. 'title': 'Tired of Link Building? Try BacklinkMyDomain.com!',
  18. }
  19. }
  20. def _real_extract(self, url):
  21. mobj = re.match(self._VALID_URL, url)
  22. video_id = mobj.group('id')
  23. video_extension = mobj.group('ext')
  24. webpage = self._download_webpage(url, video_id)
  25. # Extract URL, uploader, and title from webpage
  26. self.report_extraction(video_id)
  27. info_json = self._search_regex(r'Pb\.Data\.Shared\.put\(Pb\.Data\.Shared\.MEDIA, (.*?)\);',
  28. webpage, 'info json')
  29. info = json.loads(info_json)
  30. url = compat_urllib_parse.unquote(self._html_search_regex(r'file=(.+\.mp4)', info['linkcodes']['html'], 'url'))
  31. return {
  32. 'id': video_id,
  33. 'url': url,
  34. 'uploader': info['username'],
  35. 'timestamp': info['creationDate'],
  36. 'title': info['title'],
  37. 'ext': video_extension,
  38. 'thumbnail': info['thumbUrl'],
  39. }