]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/dropbox.py
[YoutubeDL] Include rtmpdump in exe versions -v output
[yt-dlp.git] / youtube_dl / extractor / dropbox.py
CommitLineData
8da53135 1# coding: utf-8
2from __future__ import unicode_literals
3
4cf393bb 4import os.path
8da53135 5import re
6
7from .common import InfoExtractor
7bd4b422 8from ..utils import compat_urllib_parse_unquote, url_basename
8da53135 9
ce4e242a 10
6b79f40c 11class DropboxIE(InfoExtractor):
7bd4b422
JMF
12 _VALID_URL = r'https?://(?:www\.)?dropbox[.]com/sh?/(?P<id>[a-zA-Z0-9]{15})/.*'
13 _TESTS = [{
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 }
7bd4b422
JMF
20 },
21 {
22 'url': 'https://www.dropbox.com/sh/662glsejgzoj9sr/AAByil3FGH9KFNZ13e08eSa1a/Pregame%20Ceremony%20Program%20PA%2020140518.m4v',
23 'only_matching': True,
24 },
25 ]
ce4e242a
PH
26
27 def _real_extract(self, url):
8da53135 28 mobj = re.match(self._VALID_URL, url)
ce4e242a 29 video_id = mobj.group('id')
7bd4b422 30 fn = compat_urllib_parse_unquote(url_basename(url))
264a7044 31 title = os.path.splitext(fn)[0]
18937a50
JMF
32 video_url = re.sub(r'[?&]dl=0', '', url)
33 video_url += ('?' if '?' not in video_url else '&') + 'dl=1'
ce4e242a
PH
34
35 return {
36 'id': video_id,
37 'title': title,
38 'url': video_url,
39 }