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.

34 lines
1008 B

  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',
  11. 'md5': '8a3d905427a6951ccb9eb292f154530b',
  12. 'info_dict': {
  13. 'id': 'nelirfsxnmcfbfh',
  14. 'ext': 'mp4',
  15. 'title': 'youtube-dl test video \'ä"BaW_jenozKc'
  16. }
  17. }
  18. def _real_extract(self, url):
  19. mobj = re.match(self._VALID_URL, url)
  20. video_id = mobj.group('id')
  21. fn = compat_urllib_parse_unquote(mobj.group('title'))
  22. title = os.path.splitext(fn)[0]
  23. video_url = url + '?dl=1'
  24. return {
  25. 'id': video_id,
  26. 'title': title,
  27. 'url': video_url,
  28. }