aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/extractor/niconico.py
diff options
context:
space:
mode:
Diffstat (limited to 'yt_dlp/extractor/niconico.py')
-rw-r--r--yt_dlp/extractor/niconico.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/yt_dlp/extractor/niconico.py b/yt_dlp/extractor/niconico.py
index 89e8e6093..fa2d709d2 100644
--- a/yt_dlp/extractor/niconico.py
+++ b/yt_dlp/extractor/niconico.py
@@ -8,10 +8,8 @@ import time
from urllib.parse import urlparse
from .common import InfoExtractor, SearchInfoExtractor
-from ..compat import (
- compat_HTTPError,
-)
from ..dependencies import websockets
+from ..networking.exceptions import HTTPError
from ..utils import (
ExtractorError,
OnDemandPagedList,
@@ -396,7 +394,7 @@ class NiconicoIE(InfoExtractor):
webpage, handle = self._download_webpage_handle(
'https://www.nicovideo.jp/watch/' + video_id, video_id)
if video_id.startswith('so'):
- video_id = self._match_id(handle.geturl())
+ video_id = self._match_id(handle.url)
api_data = self._parse_json(self._html_search_regex(
'data-api-data="([^"]+)"', webpage,
@@ -407,9 +405,9 @@ class NiconicoIE(InfoExtractor):
'https://www.nicovideo.jp/api/watch/v3/%s?_frontendId=6&_frontendVersion=0&actionTrackId=AAAAAAAAAA_%d' % (video_id, round(time.time() * 1000)), video_id,
note='Downloading API JSON', errnote='Unable to fetch data')['data']
except ExtractorError:
- if not isinstance(e.cause, compat_HTTPError):
+ if not isinstance(e.cause, HTTPError):
raise
- webpage = e.cause.read().decode('utf-8', 'replace')
+ webpage = e.cause.response.read().decode('utf-8', 'replace')
error_msg = self._html_search_regex(
r'(?s)<section\s+class="(?:(?:ErrorMessage|WatchExceptionPage-message)\s*)+">(.+?)</section>',
webpage, 'error reason', default=None)
@@ -742,7 +740,7 @@ class NiconicoHistoryIE(NiconicoPlaylistBaseIE):
try:
mylist = self._call_api(list_id, 'list', {'pageSize': 1})
except ExtractorError as e:
- if isinstance(e.cause, compat_HTTPError) and e.cause.code == 401:
+ if isinstance(e.cause, HTTPError) and e.cause.status == 401:
self.raise_login_required('You have to be logged in to get your history')
raise
return self.playlist_result(self._entries(list_id), list_id, **self._parse_owner(mylist))
@@ -951,8 +949,8 @@ class NiconicoLiveIE(InfoExtractor):
'frontend_id': traverse_obj(embedded_data, ('site', 'frontendId')) or '9',
})
- hostname = remove_start(urlparse(urlh.geturl()).hostname, 'sp.')
- cookies = try_get(urlh.geturl(), self._downloader._calc_cookies)
+ hostname = remove_start(urlparse(urlh.url).hostname, 'sp.')
+ cookies = try_get(urlh.url, self._downloader._calc_cookies)
latency = try_get(self._configuration_arg('latency'), lambda x: x[0])
if latency not in self._KNOWN_LATENCY:
latency = 'high'