You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.0 KiB

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