summaryrefslogtreecommitdiffstats
path: root/yt_dlp/extractor/boosty.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:10:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:10:24 +0000
commita0743e7d455e8e2e771bf834301e730f81d999a5 (patch)
tree679adb6bb9b3acc0fd4244063cf2863939cc36ac /yt_dlp/extractor/boosty.py
parentReleasing progress-linux version 2024.04.09-1~progress7.99u1. (diff)
downloadyt-dlp-a0743e7d455e8e2e771bf834301e730f81d999a5.tar.xz
yt-dlp-a0743e7d455e8e2e771bf834301e730f81d999a5.zip
Merging upstream version 2024.05.26.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'yt_dlp/extractor/boosty.py')
-rw-r--r--yt_dlp/extractor/boosty.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/yt_dlp/extractor/boosty.py b/yt_dlp/extractor/boosty.py
index fb14ca1..d3aab7a 100644
--- a/yt_dlp/extractor/boosty.py
+++ b/yt_dlp/extractor/boosty.py
@@ -1,7 +1,11 @@
+import json
+import urllib.parse
+
from .common import InfoExtractor
from .youtube import YoutubeIE
from ..utils import (
ExtractorError,
+ bug_reports_message,
int_or_none,
qualities,
str_or_none,
@@ -162,9 +166,19 @@ class BoostyIE(InfoExtractor):
def _real_extract(self, url):
user, post_id = self._match_valid_url(url).group('user', 'post_id')
+
+ auth_headers = {}
+ auth_cookie = self._get_cookies('https://boosty.to/').get('auth')
+ if auth_cookie is not None:
+ try:
+ auth_data = json.loads(urllib.parse.unquote(auth_cookie.value))
+ auth_headers['Authorization'] = f'Bearer {auth_data["accessToken"]}'
+ except (json.JSONDecodeError, KeyError):
+ self.report_warning(f'Failed to extract token from auth cookie{bug_reports_message()}')
+
post = self._download_json(
f'https://api.boosty.to/v1/blog/{user}/post/{post_id}', post_id,
- note='Downloading post data', errnote='Unable to download post data')
+ note='Downloading post data', errnote='Unable to download post data', headers=auth_headers)
post_title = post.get('title')
if not post_title:
@@ -202,7 +216,9 @@ class BoostyIE(InfoExtractor):
'thumbnail': (('previewUrl', 'defaultPreview'), {url_or_none}),
}, get_all=False)})
- if not entries:
+ if not entries and not post.get('hasAccess'):
+ self.raise_login_required('This post requires a subscription', metadata_available=True)
+ elif not entries:
raise ExtractorError('No videos found', expected=True)
if len(entries) == 1:
return entries[0]