aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2021-04-03 00:23:46 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2021-04-03 14:07:27 +0530
commit54df8fc5b25a0c9d159a23f5cf9f1eabce1e6294 (patch)
tree18c9f58bdf3b8a02105e0ff57b0290989563f7d7
parent5d39972ed06f896dca482c0a778a3972742cfe9e (diff)
downloadhypervideo-pre-54df8fc5b25a0c9d159a23f5cf9f1eabce1e6294.tar.lz
hypervideo-pre-54df8fc5b25a0c9d159a23f5cf9f1eabce1e6294.tar.xz
hypervideo-pre-54df8fc5b25a0c9d159a23f5cf9f1eabce1e6294.zip
[ViewSource] Add extractor to handle `view-source:`
-rw-r--r--yt_dlp/extractor/commonprotocols.py15
-rw-r--r--yt_dlp/extractor/extractors.py1
2 files changed, 16 insertions, 0 deletions
diff --git a/yt_dlp/extractor/commonprotocols.py b/yt_dlp/extractor/commonprotocols.py
index d98331a4e..1fc7779b8 100644
--- a/yt_dlp/extractor/commonprotocols.py
+++ b/yt_dlp/extractor/commonprotocols.py
@@ -1,5 +1,7 @@
from __future__ import unicode_literals
+import re
+
from .common import InfoExtractor
from ..compat import (
compat_urlparse,
@@ -58,3 +60,16 @@ class MmsIE(InfoExtractor):
'title': title,
'url': url,
}
+
+
+class ViewSourceIE(InfoExtractor):
+ IE_DESC = False
+ _VALID_URL = r'view-source:(?P<url>.+)'
+
+ _TEST = {
+ 'url': 'view-source:https://www.youtube.com/watch?v=BaW_jenozKc',
+ 'only_matching': True
+ }
+
+ def _real_extract(self, url):
+ return self.url_result(re.match(self._VALID_URL, url).group('url'))
diff --git a/yt_dlp/extractor/extractors.py b/yt_dlp/extractor/extractors.py
index d9b7e3b5d..d9e6742ba 100644
--- a/yt_dlp/extractor/extractors.py
+++ b/yt_dlp/extractor/extractors.py
@@ -264,6 +264,7 @@ from .commonmistakes import CommonMistakesIE, UnicodeBOMIE
from .commonprotocols import (
MmsIE,
RtmpIE,
+ ViewSourceIE,
)
from .condenast import CondeNastIE
from .contv import CONtvIE