From 5b251628e9f45c89c1becb3f62c4212874eb74ea Mon Sep 17 00:00:00 2001 From: remitamine Date: Mon, 21 Dec 2015 03:05:34 +0100 Subject: [PATCH] [googledrive] Modernize --- youtube_dl/extractor/__init__.py | 5 +- youtube_dl/extractor/generic.py | 4 +- youtube_dl/extractor/googledrive.py | 146 ++++++++++------------------ 3 files changed, 54 insertions(+), 101 deletions(-) diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index 02e18a0da..6655d7eb5 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -209,10 +209,7 @@ from .godtube import GodTubeIE from .goldenmoustache import GoldenMoustacheIE from .golem import GolemIE -from .googledrive import ( - GoogleDriveEmbedIE, - GoogleDriveIE, -) +from .googledrive import GoogleDriveIE from .googleplus import GooglePlusIE from .googlesearch import GoogleSearchIE from .gorillavid import GorillaVidIE diff --git a/youtube_dl/extractor/generic.py b/youtube_dl/extractor/generic.py index 3f7b094db..abd98e500 100644 --- a/youtube_dl/extractor/generic.py +++ b/youtube_dl/extractor/generic.py @@ -48,7 +48,7 @@ from .dailymotion import DailymotionCloudIE from .onionstudios import OnionStudiosIE from .snagfilms import SnagFilmsEmbedIE -from .googledrive import GoogleDriveEmbedIE +from .googledrive import GoogleDriveIE class GenericIE(InfoExtractor): @@ -1601,7 +1601,7 @@ def _playlist_from_matches(matches, getter=None, ie=None): return self.url_result(nbc_sports_url, 'NBCSportsVPlayer') # Look for Google Drive embeds - google_drive_url = GoogleDriveEmbedIE._extract_url(webpage) + google_drive_url = GoogleDriveIE._extract_url(webpage) if google_drive_url: return self.url_result(google_drive_url, 'GoogleDrive') 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'