-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AbemaTV: failing to download with recent nightly version #7622
Comments
AbemaTV will need a rewrite for the new networking framework, as initially planned when the extractor was being written (see #3615). The current implementation is temporary and expected to not be compatible. For a workaround we could add |
Would you be able to check whether this works around the issue? diff --git a/yt_dlp/extractor/abematv.py b/yt_dlp/extractor/abematv.py
index 98ece8da7..f849d859a 100644
--- a/yt_dlp/extractor/abematv.py
+++ b/yt_dlp/extractor/abematv.py
@@ -34,8 +34,13 @@ def add_opener(ydl, handler):
''' Add a handler for opening URLs, like _download_webpage '''
# https://github.com/python/cpython/blob/main/Lib/urllib/request.py#L426
# https://github.com/python/cpython/blob/main/Lib/urllib/request.py#L605
- assert isinstance(ydl._opener, urllib.request.OpenerDirector)
- ydl._opener.add_handler(handler)
+ rh = ydl._request_director.handlers['Urllib']
+ if 'abematv-license' in rh._SUPPORTED_URL_SCHEMES:
+ return
+ opener = rh._get_instance(cookiejar=ydl.cookiejar, proxies=ydl.proxies)
+ assert isinstance(opener, urllib.request.OpenerDirector)
+ opener.add_handler(handler)
+ rh._SUPPORTED_URL_SCHEMES = (*rh._SUPPORTED_URL_SCHEMES, 'abematv-license')
def remove_opener(ydl, handler):
@@ -212,8 +217,6 @@ def _get_device_token(self):
})
AbemaTVBaseIE._USERTOKEN = user_data['token']
- # don't allow adding it 2 times or more, though it's guarded
- remove_opener(self._downloader, AbemaLicenseHandler)
add_opener(self._downloader, AbemaLicenseHandler(self))
return self._USERTOKEN |
The patch proposed in #7622 (comment) does not fix the issue due to another error.
|
@xtkoba Try this slightly improved patch: diff --git a/yt_dlp/extractor/abematv.py b/yt_dlp/extractor/abematv.py
index 98ece8da7..6b1f4da88 100644
--- a/yt_dlp/extractor/abematv.py
+++ b/yt_dlp/extractor/abematv.py
@@ -34,8 +34,13 @@ def add_opener(ydl, handler):
''' Add a handler for opening URLs, like _download_webpage '''
# https://github.com/python/cpython/blob/main/Lib/urllib/request.py#L426
# https://github.com/python/cpython/blob/main/Lib/urllib/request.py#L605
- assert isinstance(ydl._opener, urllib.request.OpenerDirector)
- ydl._opener.add_handler(handler)
+ rh = ydl._request_director.handlers['Urllib']
+ if 'abematv-license' in rh._SUPPORTED_URL_SCHEMES:
+ return
+ opener = rh._get_instance(cookiejar=ydl.cookiejar, proxies=ydl.proxies)
+ assert isinstance(opener, urllib.request.OpenerDirector)
+ opener.add_handler(handler)
+ rh._SUPPORTED_URL_SCHEMES = (*rh._SUPPORTED_URL_SCHEMES, 'abematv-license')
def remove_opener(ydl, handler):
@@ -140,7 +145,7 @@ def abematv_license_open(self, url):
ticket = urllib.parse.urlparse(url).netloc
response_data = self._get_videokey_from_ticket(ticket)
return urllib.response.addinfourl(io.BytesIO(response_data), headers={
- 'Content-Length': len(response_data),
+ 'Content-Length': str(len(response_data)),
}, url=url, code=200)
@@ -212,8 +217,6 @@ def _get_device_token(self):
})
AbemaTVBaseIE._USERTOKEN = user_data['token']
- # don't allow adding it 2 times or more, though it's guarded
- remove_opener(self._downloader, AbemaLicenseHandler)
add_opener(self._downloader, AbemaLicenseHandler(self))
return self._USERTOKEN |
#7622 (comment) This works. Thanks. |
DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE
Checklist
Region
Japan
Provide a description that is worded well enough to be understood
The AbemaTV extractor fails to download a video with nightly@2023.07.15.211025.
I have confirmed that the same video can be downloded with 2023.07.06.
I suspect this is something related to commit 227bf1a.
Provide verbose output that clearly demonstrates the problem
yt-dlp -vU <your command line>
)'verbose': True
toYoutubeDL
params instead[debug] Command-line config
) and insert it belowComplete Verbose Output
The text was updated successfully, but these errors were encountered: