mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-09-05 10:29:35 +02:00
[Gofile] Support password-protected links (#3488)
Closes #3465 Authored by: mehq
This commit is contained in:
parent
2d3b3feb7e
commit
e08585b0f8
@ -1,3 +1,5 @@
|
|||||||
|
import hashlib
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
@ -37,6 +39,15 @@ class GofileIE(InfoExtractor):
|
|||||||
'id': 'TMjXd9',
|
'id': 'TMjXd9',
|
||||||
},
|
},
|
||||||
'playlist_count': 1,
|
'playlist_count': 1,
|
||||||
|
}, {
|
||||||
|
'url': 'https://gofile.io/d/gqOtRf',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'gqOtRf',
|
||||||
|
},
|
||||||
|
'playlist_mincount': 1,
|
||||||
|
'params': {
|
||||||
|
'videopassword': 'password',
|
||||||
|
},
|
||||||
}]
|
}]
|
||||||
_TOKEN = None
|
_TOKEN = None
|
||||||
|
|
||||||
@ -52,14 +63,22 @@ def _real_initialize(self):
|
|||||||
self._set_cookie('gofile.io', 'accountToken', self._TOKEN)
|
self._set_cookie('gofile.io', 'accountToken', self._TOKEN)
|
||||||
|
|
||||||
def _entries(self, file_id):
|
def _entries(self, file_id):
|
||||||
files = self._download_json('https://api.gofile.io/getContent', 'Gofile', note='Getting filelist', query={
|
query_params = {
|
||||||
'contentId': file_id,
|
'contentId': file_id,
|
||||||
'token': self._TOKEN,
|
'token': self._TOKEN,
|
||||||
'websiteToken': 12345,
|
'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']
|
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)
|
raise ExtractorError(f'{self.IE_NAME} said: status {status}', expected=True)
|
||||||
|
|
||||||
found_files = False
|
found_files = False
|
||||||
|
Loading…
Reference in New Issue
Block a user