]> git.bitcoin.ninja Git - youtube-dl/blob - youtube_dl/extractor/photobucket.py
Merge branch 'ustream-embed-recorded2' of https://github.com/anovicecodemonkey/youtub...
[youtube-dl] / youtube_dl / extractor / photobucket.py
1 from __future__ import unicode_literals
2
3 import json
4 import re
5
6 from .common import InfoExtractor
7 from ..utils import compat_urllib_parse
8
9
10 class PhotobucketIE(InfoExtractor):
11     _VALID_URL = r'http://(?:[a-z0-9]+\.)?photobucket\.com/.*(([\?\&]current=)|_)(?P<id>.*)\.(?P<ext>(flv)|(mp4))'
12     _TEST = {
13         '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',
14         'file': 'zpsc0c3b9fa.mp4',
15         'md5': '7dabfb92b0a31f6c16cebc0f8e60ff99',
16         'info_dict': {
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 = re.match(self._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         }