]> gitweb @ CieloNegro.org - youtube-dl.git/blob - youtube_dl/extractor/dropbox.py
[ebaumsworld] Modernize
[youtube-dl.git] / youtube_dl / extractor / dropbox.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import os.path
5 import re
6
7 from .common import InfoExtractor
8 from ..utils import compat_urllib_parse_unquote
9
10
11 class DropboxIE(InfoExtractor):
12     _VALID_URL = r'https?://(?:www\.)?dropbox[.]com/s/(?P<id>[a-zA-Z0-9]{15})/(?P<title>[^?#]*)'
13     _TEST = {
14         'url': 'https://www.dropbox.com/s/nelirfsxnmcfbfh/youtube-dl%20test%20video%20%27%C3%A4%22BaW_jenozKc.mp4',
15         'md5': '8a3d905427a6951ccb9eb292f154530b',
16         'info_dict': {
17             'id': 'nelirfsxnmcfbfh',
18             'ext': 'mp4',
19             'title': 'youtube-dl test video \'รค"BaW_jenozKc'
20         }
21     }
22
23     def _real_extract(self, url):
24         mobj = re.match(self._VALID_URL, url)
25         video_id = mobj.group('id')
26         fn = compat_urllib_parse_unquote(mobj.group('title'))
27         title = os.path.splitext(fn)[0]
28         video_url = url + '?dl=1'
29
30         return {
31             'id': video_id,
32             'title': title,
33             'url': video_url,
34         }