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.

43 lines
1.6 KiB

  1. from __future__ import unicode_literals
  2. import datetime
  3. import json
  4. import re
  5. from .common import InfoExtractor
  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. 'upload_date': '20130504',
  14. 'uploader': 'rachaneronas',
  15. 'title': 'Tired of Link Building? Try BacklinkMyDomain.com!',
  16. }
  17. }
  18. def _real_extract(self, url):
  19. mobj = re.match(self._VALID_URL, url)
  20. video_id = mobj.group('id')
  21. video_extension = mobj.group('ext')
  22. webpage = self._download_webpage(url, video_id)
  23. # Extract URL, uploader, and title from webpage
  24. self.report_extraction(video_id)
  25. info_json = self._search_regex(r'Pb\.Data\.Shared\.put\(Pb\.Data\.Shared\.MEDIA, (.*?)\);',
  26. webpage, 'info json')
  27. info = json.loads(info_json)
  28. return {
  29. 'id': video_id,
  30. 'url': info['downloadUrl'],
  31. 'uploader': info['username'],
  32. 'upload_date': datetime.date.fromtimestamp(info['creationDate']).strftime('%Y%m%d'),
  33. 'title': info['title'],
  34. 'ext': video_extension,
  35. 'thumbnail': info['thumbUrl'],
  36. }