aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp
diff options
context:
space:
mode:
authorsam <mail@samueljenks.me>2022-11-05 23:13:05 +1300
committerGitHub <noreply@github.com>2022-11-05 15:43:05 +0530
commit0d113603ac2ccc869eb1d1b7419caed77f5f5d8a (patch)
treee71e61807dcbab749219f27c935df11608693e24 /yt_dlp
parent2e30b46fe4a04e82d1ec1a21f8d387e5f96405be (diff)
downloadhypervideo-pre-0d113603ac2ccc869eb1d1b7419caed77f5f5d8a.tar.lz
hypervideo-pre-0d113603ac2ccc869eb1d1b7419caed77f5f5d8a.tar.xz
hypervideo-pre-0d113603ac2ccc869eb1d1b7419caed77f5f5d8a.zip
[extractor/oftv] Add extractors (#5134)
Closes #5017 Authored by: DoubleCouponDay
Diffstat (limited to 'yt_dlp')
-rw-r--r--yt_dlp/extractor/_extractors.py4
-rw-r--r--yt_dlp/extractor/oftv.py54
2 files changed, 58 insertions, 0 deletions
diff --git a/yt_dlp/extractor/_extractors.py b/yt_dlp/extractor/_extractors.py
index 020f3b454..0a9b1bce9 100644
--- a/yt_dlp/extractor/_extractors.py
+++ b/yt_dlp/extractor/_extractors.py
@@ -1254,6 +1254,10 @@ from .nzherald import NZHeraldIE
from .nzz import NZZIE
from .odatv import OdaTVIE
from .odnoklassniki import OdnoklassnikiIE
+from .oftv import (
+ OfTVIE,
+ OfTVPlaylistIE
+)
from .oktoberfesttv import OktoberfestTVIE
from .olympics import OlympicsReplayIE
from .on24 import On24IE
diff --git a/yt_dlp/extractor/oftv.py b/yt_dlp/extractor/oftv.py
new file mode 100644
index 000000000..3ae7278fb
--- /dev/null
+++ b/yt_dlp/extractor/oftv.py
@@ -0,0 +1,54 @@
+from .common import InfoExtractor
+from .zype import ZypeIE
+from ..utils import traverse_obj
+
+
+class OfTVIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?of.tv/video/(?P<id>\w+)'
+ _TESTS = [{
+ 'url': 'https://of.tv/video/627d7d95b353db0001dadd1a',
+ 'md5': 'cb9cd5db3bb9ee0d32bfd7e373d6ef0a',
+ 'info_dict': {
+ 'id': '627d7d95b353db0001dadd1a',
+ 'ext': 'mp4',
+ 'title': 'E1: Jacky vs Eric',
+ 'thumbnail': r're:^https?://.*\.jpg',
+ 'average_rating': 0,
+ 'description': 'md5:dd16e3e2a8d27d922e7a989f85986853',
+ 'display_id': '',
+ 'duration': 1423,
+ 'timestamp': 1652391300,
+ 'upload_date': '20220512',
+ 'view_count': 0,
+ 'creator': 'This is Fire'
+ }
+ }]
+
+ def _real_extract(self, url):
+ video_id = self._match_id(url)
+ webpage = self._download_webpage(url, video_id)
+ info = next(ZypeIE.extract_from_webpage(self._downloader, url, webpage))
+ info['_type'] = 'url_transparent'
+ info['creator'] = self._search_regex(r'<a[^>]+class=\"creator-name\"[^>]+>([^<]+)', webpage, 'creator')
+ return info
+
+
+class OfTVPlaylistIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?of.tv/creators/(?P<id>[a-zA-Z0-9-]+)/.?'
+ _TESTS = [{
+ 'url': 'https://of.tv/creators/this-is-fire/',
+ 'playlist_count': 8,
+ 'info_dict': {
+ 'id': 'this-is-fire'
+ }
+ }]
+
+ def _real_extract(self, url):
+ playlist_id = self._match_id(url)
+ webpage = self._download_webpage(url, playlist_id)
+
+ json_match = self._search_json(
+ r'var\s*remaining_videos\s*=', webpage, 'oftv playlists', playlist_id, contains_pattern=r'\[.+\]')
+
+ return self.playlist_from_matches(
+ traverse_obj(json_match, (..., 'discovery_url')), playlist_id)