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.

45 lines
1.7 KiB

  1. from __future__ import unicode_literals
  2. import json
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils 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. 'file': 'zpsc0c3b9fa.mp4',
  11. 'md5': '7dabfb92b0a31f6c16cebc0f8e60ff99',
  12. 'info_dict': {
  13. 'timestamp': 1367669341,
  14. 'upload_date': '20130504',
  15. 'uploader': 'rachaneronas',
  16. 'title': 'Tired of Link Building? Try BacklinkMyDomain.com!',
  17. }
  18. }
  19. def _real_extract(self, url):
  20. mobj = re.match(self._VALID_URL, url)
  21. video_id = mobj.group('id')
  22. video_extension = mobj.group('ext')
  23. webpage = self._download_webpage(url, video_id)
  24. # Extract URL, uploader, and title from webpage
  25. self.report_extraction(video_id)
  26. info_json = self._search_regex(r'Pb\.Data\.Shared\.put\(Pb\.Data\.Shared\.MEDIA, (.*?)\);',
  27. webpage, 'info json')
  28. info = json.loads(info_json)
  29. url = compat_urllib_parse.unquote(self._html_search_regex(r'file=(.+\.mp4)', info['linkcodes']['html'], 'url'))
  30. return {
  31. 'id': video_id,
  32. 'url': url,
  33. 'uploader': info['username'],
  34. 'timestamp': info['creationDate'],
  35. 'title': info['title'],
  36. 'ext': video_extension,
  37. 'thumbnail': info['thumbUrl'],
  38. }