]>
Commit | Line | Data |
---|---|---|
8da53135 | 1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4cf393bb | 4 | import os.path |
8da53135 | 5 | import re |
6 | ||
7 | from .common import InfoExtractor | |
f1f725c6 | 8 | from ..utils import compat_urllib_parse_unquote |
8da53135 | 9 | |
ce4e242a | 10 | |
6b79f40c | 11 | class DropboxIE(InfoExtractor): |
12 | _VALID_URL = r'https?://(?:www\.)?dropbox[.]com/s/(?P<id>[a-zA-Z0-9]{15})/(?P<title>[^?#]*)' | |
8da53135 | 13 | _TEST = { |
b94744d1 | 14 | 'url': 'https://www.dropbox.com/s/nelirfsxnmcfbfh/youtube-dl%20test%20video%20%27%C3%A4%22BaW_jenozKc.mp4?dl=0', |
ce4e242a | 15 | 'info_dict': { |
264a7044 | 16 | 'id': 'nelirfsxnmcfbfh', |
79629ec7 | 17 | 'ext': 'mp4', |
264a7044 | 18 | 'title': 'youtube-dl test video \'รค"BaW_jenozKc' |
6b79f40c | 19 | } |
8da53135 | 20 | } |
ce4e242a PH |
21 | |
22 | def _real_extract(self, url): | |
8da53135 | 23 | mobj = re.match(self._VALID_URL, url) |
ce4e242a | 24 | video_id = mobj.group('id') |
f1f725c6 | 25 | fn = compat_urllib_parse_unquote(mobj.group('title')) |
264a7044 | 26 | title = os.path.splitext(fn)[0] |
b94744d1 PH |
27 | video_url = ( |
28 | re.sub(r'[?&]dl=0', '', url) + | |
29 | ('?' if '?' in url else '&') + 'dl=1') | |
ce4e242a PH |
30 | |
31 | return { | |
32 | 'id': video_id, | |
33 | 'title': title, | |
34 | 'url': video_url, | |
35 | } |