aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormehq <11481344+mehq@users.noreply.github.com>2022-04-20 15:43:15 +0600
committerGitHub <noreply@github.com>2022-04-20 02:43:15 -0700
commite08585b0f84368e2cb8c78b271116a2d13f6e032 (patch)
tree30a4d502cb20856e08897b8b8c5a151cd4e96240
parent2d3b3feb7e69df0840d06fc1c8b27c5f26de054f (diff)
downloadhypervideo-pre-e08585b0f84368e2cb8c78b271116a2d13f6e032.tar.lz
hypervideo-pre-e08585b0f84368e2cb8c78b271116a2d13f6e032.tar.xz
hypervideo-pre-e08585b0f84368e2cb8c78b271116a2d13f6e032.zip
[Gofile] Support password-protected links (#3488)
Closes #3465 Authored by: mehq
-rw-r--r--yt_dlp/extractor/gofile.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/yt_dlp/extractor/gofile.py b/yt_dlp/extractor/gofile.py
index b491b46a5..ddbce2ee8 100644
--- a/yt_dlp/extractor/gofile.py
+++ b/yt_dlp/extractor/gofile.py
@@ -1,3 +1,5 @@
+import hashlib
+
from .common import InfoExtractor
from ..utils import (
ExtractorError,
@@ -37,6 +39,15 @@ class GofileIE(InfoExtractor):
'id': 'TMjXd9',
},
'playlist_count': 1,
+ }, {
+ 'url': 'https://gofile.io/d/gqOtRf',
+ 'info_dict': {
+ 'id': 'gqOtRf',
+ },
+ 'playlist_mincount': 1,
+ 'params': {
+ 'videopassword': 'password',
+ },
}]
_TOKEN = None
@@ -52,14 +63,22 @@ class GofileIE(InfoExtractor):
self._set_cookie('gofile.io', 'accountToken', self._TOKEN)
def _entries(self, file_id):
- files = self._download_json('https://api.gofile.io/getContent', 'Gofile', note='Getting filelist', query={
+ query_params = {
'contentId': file_id,
'token': self._TOKEN,
'websiteToken': 12345,
- })
+ }
+ password = self.get_param('videopassword')
+ if password:
+ query_params['password'] = hashlib.sha256(password.encode('utf-8')).hexdigest()
+ files = self._download_json(
+ 'https://api.gofile.io/getContent', file_id, note='Getting filelist', query=query_params)
status = files['status']
- if status != 'ok':
+ if status == 'error-passwordRequired':
+ raise ExtractorError(
+ 'This video is protected by a password, use the --video-password option', expected=True)
+ elif status != 'ok':
raise ExtractorError(f'{self.IE_NAME} said: status {status}', expected=True)
found_files = False