[ie/wistia] Support password-protected videos (#11100)
[yt-dlp3.git] / yt_dlp / extractor / photobucket.py
bloba7e5bc007dc4531de7c5effab0d7aefccf0e3262
1 import json
2 import urllib.parse
4 from .common import InfoExtractor
7 class PhotobucketIE(InfoExtractor):
8 _VALID_URL = r'https?://(?:[a-z0-9]+\.)?photobucket\.com/.*(([\?\&]current=)|_)(?P<id>.*)\.(?P<ext>(flv)|(mp4))'
9 _TEST = {
10 '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',
11 'md5': '7dabfb92b0a31f6c16cebc0f8e60ff99',
12 'info_dict': {
13 'id': 'zpsc0c3b9fa',
14 'ext': 'mp4',
15 'timestamp': 1367669341,
16 'upload_date': '20130504',
17 'uploader': 'rachaneronas',
18 'title': 'Tired of Link Building? Try BacklinkMyDomain.com!',
22 def _real_extract(self, url):
23 mobj = self._match_valid_url(url)
24 video_id = mobj.group('id')
25 video_extension = mobj.group('ext')
27 webpage = self._download_webpage(url, video_id)
29 # Extract URL, uploader, and title from webpage
30 self.report_extraction(video_id)
31 info_json = self._search_regex(r'Pb\.Data\.Shared\.put\(Pb\.Data\.Shared\.MEDIA, (.*?)\);',
32 webpage, 'info json')
33 info = json.loads(info_json)
34 url = urllib.parse.unquote(self._html_search_regex(r'file=(.+\.mp4)', info['linkcodes']['html'], 'url'))
35 return {
36 'id': video_id,
37 'url': url,
38 'uploader': info['username'],
39 'timestamp': info['creationDate'],
40 'title': info['title'],
41 'ext': video_extension,
42 'thumbnail': info['thumbUrl'],