]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/photobucket.py
[youtube] Prefer UTC upload date for videos (#2223)
[yt-dlp.git] / yt_dlp / extractor / photobucket.py
1 from __future__ import unicode_literals
2
3 import json
4
5 from .common import InfoExtractor
6 from ..compat import compat_urllib_parse_unquote
7
8
9 class PhotobucketIE(InfoExtractor):
10 _VALID_URL = r'https?://(?:[a-z0-9]+\.)?photobucket\.com/.*(([\?\&]current=)|_)(?P<id>.*)\.(?P<ext>(flv)|(mp4))'
11 _TEST = {
12 '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',
13 'md5': '7dabfb92b0a31f6c16cebc0f8e60ff99',
14 'info_dict': {
15 'id': 'zpsc0c3b9fa',
16 'ext': 'mp4',
17 'timestamp': 1367669341,
18 'upload_date': '20130504',
19 'uploader': 'rachaneronas',
20 'title': 'Tired of Link Building? Try BacklinkMyDomain.com!',
21 }
22 }
23
24 def _real_extract(self, url):
25 mobj = self._match_valid_url(url)
26 video_id = mobj.group('id')
27 video_extension = mobj.group('ext')
28
29 webpage = self._download_webpage(url, video_id)
30
31 # Extract URL, uploader, and title from webpage
32 self.report_extraction(video_id)
33 info_json = self._search_regex(r'Pb\.Data\.Shared\.put\(Pb\.Data\.Shared\.MEDIA, (.*?)\);',
34 webpage, 'info json')
35 info = json.loads(info_json)
36 url = compat_urllib_parse_unquote(self._html_search_regex(r'file=(.+\.mp4)', info['linkcodes']['html'], 'url'))
37 return {
38 'id': video_id,
39 'url': url,
40 'uploader': info['username'],
41 'timestamp': info['creationDate'],
42 'title': info['title'],
43 'ext': video_extension,
44 'thumbnail': info['thumbUrl'],
45 }