]>
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 | |
8c25f81b PH |
8 | from ..compat import compat_urllib_parse_unquote |
9 | from ..utils import url_basename | |
8da53135 | 10 | |
ce4e242a | 11 | |
6b79f40c | 12 | class DropboxIE(InfoExtractor): |
7bd4b422 JMF |
13 | _VALID_URL = r'https?://(?:www\.)?dropbox[.]com/sh?/(?P<id>[a-zA-Z0-9]{15})/.*' |
14 | _TESTS = [{ | |
b94744d1 | 15 | 'url': 'https://www.dropbox.com/s/nelirfsxnmcfbfh/youtube-dl%20test%20video%20%27%C3%A4%22BaW_jenozKc.mp4?dl=0', |
ce4e242a | 16 | 'info_dict': { |
264a7044 | 17 | 'id': 'nelirfsxnmcfbfh', |
79629ec7 | 18 | 'ext': 'mp4', |
264a7044 | 19 | 'title': 'youtube-dl test video \'ä"BaW_jenozKc' |
6b79f40c | 20 | } |
7bd4b422 JMF |
21 | }, |
22 | { | |
23 | 'url': 'https://www.dropbox.com/sh/662glsejgzoj9sr/AAByil3FGH9KFNZ13e08eSa1a/Pregame%20Ceremony%20Program%20PA%2020140518.m4v', | |
24 | 'only_matching': True, | |
25 | }, | |
26 | ] | |
ce4e242a PH |
27 | |
28 | def _real_extract(self, url): | |
8da53135 | 29 | mobj = re.match(self._VALID_URL, url) |
ce4e242a | 30 | video_id = mobj.group('id') |
7bd4b422 | 31 | fn = compat_urllib_parse_unquote(url_basename(url)) |
264a7044 | 32 | title = os.path.splitext(fn)[0] |
18937a50 JMF |
33 | video_url = re.sub(r'[?&]dl=0', '', url) |
34 | video_url += ('?' if '?' not in video_url else '&') + 'dl=1' | |
ce4e242a PH |
35 | |
36 | return { | |
37 | 'id': video_id, | |
38 | 'title': title, | |
39 | 'url': video_url, | |
40 | } |