aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor
diff options
context:
space:
mode:
authorremitamine <remitamine@gmail.com>2015-06-29 07:53:21 +0100
committerremitamine <remitamine@gmail.com>2015-07-23 11:57:09 +0100
commit3e5f3df1729846a33631dd38a887cd1d81a727c1 (patch)
tree62de1800ace3f6160de8c256184753fb92ab58c3 /youtube_dl/extractor
parentf120a7ab5e9c560a8114f9662e2f213243a945b0 (diff)
move the embed to a separate class
Diffstat (limited to 'youtube_dl/extractor')
-rw-r--r--youtube_dl/extractor/googledrive.py31
1 files changed, 30 insertions, 1 deletions
diff --git a/youtube_dl/extractor/googledrive.py b/youtube_dl/extractor/googledrive.py
index e3d5c3418..ac891b275 100644
--- a/youtube_dl/extractor/googledrive.py
+++ b/youtube_dl/extractor/googledrive.py
@@ -1,8 +1,37 @@
+import re
+
from .common import InfoExtractor
from ..utils import RegexNotFoundError
+class GoogleDriveEmbedIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:video\.google\.com/get_player\?.*?docid=|(?:docs|drive)\.google\.com/file/d/)(?P<id>[a-zA-Z0-9-]{28})(?:/preview)'
+ _TEST = {
+ 'url': 'https://docs.google.com/file/d/0B8KB9DRosYGKMXNoeWxqa3JYclE/preview',
+ 'info_dict': {
+ 'id': '0B8KB9DRosYGKMXNoeWxqa3JYclE',
+ 'ext': 'mp4',
+ 'title': 'Jimmy Fallon Sings Since You\'ve Been Gone.wmv',
+ }
+ }
+
+ @staticmethod
+ def _extract_url(webpage):
+ mobj = re.search(
+ r'<iframe src="https?://(?:video\.google\.com/get_player\?.*?docid=|(?:docs|drive)\.google\.com/file/d/)(?P<id>[a-zA-Z0-9-]{28})(?:/preview)',
+ webpage)
+ if mobj:
+ return 'https://drive.google.com/file/d/%s' % mobj.group('id')
+
+ def _real_extract(self, url):
+ video_id = self._match_id(url)
+ return {
+ '_type': 'url',
+ 'ie-key': 'GoogleDrive',
+ 'url': 'https://drive.google.com/file/d/%s' % video_id
+ }
+
class GoogleDriveIE(InfoExtractor):
- _VALID_URL = r'(?:https?://)?(?:video\.google\.com/get_player\?.*?docid=|(?:docs|drive)\.google\.com/(?:uc\?.*?id=|file/d/))(?P<id>.+?)(?:&|/|$)'
+ _VALID_URL = r'https?://(?:docs|drive)\.google\.com/(?:uc\?.*?id=|file/d/)(?P<id>[a-zA-Z0-9-]{28})'
_TEST = {
'url': 'https://drive.google.com/file/d/0ByeS4oOUV-49Zzh4R1J6R09zazQ/edit?pli=1',
'info_dict': {