From 5b251628e9f45c89c1becb3f62c4212874eb74ea Mon Sep 17 00:00:00 2001 From: remitamine Date: Mon, 21 Dec 2015 03:05:34 +0100 Subject: [googledrive] Modernize --- youtube_dl/extractor/googledrive.py | 144 +++++++++++++----------------------- 1 file changed, 50 insertions(+), 94 deletions(-) (limited to 'youtube_dl/extractor/googledrive.py') diff --git a/youtube_dl/extractor/googledrive.py b/youtube_dl/extractor/googledrive.py index 7bc7b7a0d..f354c9c7a 100644 --- a/youtube_dl/extractor/googledrive.py +++ b/youtube_dl/extractor/googledrive.py @@ -1,132 +1,88 @@ +from __future__ import unicode_literals + import re from .common import InfoExtractor from ..utils import ( - RegexNotFoundError, ExtractorError, + int_or_none, ) -class GoogleDriveEmbedIE(InfoExtractor): - _VALID_URL = r'https?://(?:video\.google\.com/get_player\?.*?docid=|(?:docs|drive)\.google\.com/file/d/)(?P[a-zA-Z0-9_-]{28})' + +class GoogleDriveIE(InfoExtractor): + _VALID_URL = r'https?://(?:(?:docs|drive)\.google\.com/(?:uc\?.*?id=|file/d/)|video\.google\.com/get_player\?.*?docid=)(?P[a-zA-Z0-9_-]{28})' _TEST = { - 'url': 'https://docs.google.com/file/d/0B8KB9DRosYGKMXNoeWxqa3JYclE/preview', + 'url': 'https://drive.google.com/file/d/0ByeS4oOUV-49Zzh4R1J6R09zazQ/edit?pli=1', + 'md5': '881f7700aec4f538571fa1e0eed4a7b6', 'info_dict': { - 'id': '0B8KB9DRosYGKMXNoeWxqa3JYclE', + 'id': '0ByeS4oOUV-49Zzh4R1J6R09zazQ', 'ext': 'mp4', - 'title': 'Jimmy Fallon Sings Since You\'ve Been Gone.wmv', + 'title': 'Big Buck Bunny.mp4', + 'duration': 46, } } + _FORMATS_EXT = { + '5': 'flv', + '6': 'flv', + '13': '3gp', + '17': '3gp', + '18': 'mp4', + '22': 'mp4', + '34': 'flv', + '35': 'flv', + '36': '3gp', + '37': 'mp4', + '38': 'mp4', + '43': 'webm', + '44': 'webm', + '45': 'webm', + '46': 'webm', + '59': 'mp4', + } @staticmethod def _extract_url(webpage): mobj = re.search( - r'