Skip to content

Commit

Permalink
throw error on geo-block
Browse files Browse the repository at this point in the history
copied from puhutv extractor
  • Loading branch information
garret1317 committed Aug 3, 2023
1 parent 9e68890 commit 9cd12f7
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions yt_dlp/extractor/tbsjp.py
@@ -1,6 +1,7 @@
from .common import InfoExtractor

from ..networking.exceptions import HTTPError
from ..utils import (
ExtractorError,
get_element_text_and_html_by_tag,
traverse_obj,
unified_timestamp,
Expand Down Expand Up @@ -56,9 +57,14 @@ def _real_extract(self, url):
video_url = self._search_regex(r'videoPlaybackUrl: *[\'"]([^\'"]+)[\'"]', tf_js, 'stream API url')
api_key = self._search_regex(r'api_key: *[\'"]([^\'"]+)[\'"]', tf_js, 'stream API key')

source_meta = self._download_json(f'{video_url}ref:{video_id}', video_id,
headers={"X-Streaks-Api-Key": api_key},
note='Downloading stream metadata')
try:
source_meta = self._download_json(f'{video_url}ref:{video_id}', video_id,
headers={"X-Streaks-Api-Key": api_key},
note='Downloading stream metadata')
except ExtractorError as e:
if isinstance(e.cause, HTTPError) and e.cause.status == 403:
self.raise_geo_restricted(countries=['JP'])
raise

formats = []
subs = []
Expand Down

0 comments on commit 9cd12f7

Please sign in to comment.