Repository: yt-dlp/yt-dlp

Issue:
Support password-protected gofile.io links
### Checklist

- [X] I'm reporting a site feature request
- [X] I've verified that I'm running yt-dlp version **2022.04.08** ([update instructions](https://github.com/yt-dlp/yt-dlp#update)) or later (specify commit)
- [X] I've checked that all provided URLs are alive and playable in a browser
- [X] I've searched the [bugtracker](https://github.com/yt-dlp/yt-dlp/issues?q=) for similar issues including closed ones. DO NOT post duplicates
- [X] I've read the [guidelines for opening an issue](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#opening-an-issue)
- [X] I've read about [sharing account credentials](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#are-you-willing-to-share-account-details-if-needed) and I'm willing to share it if required

### Region

United States/Everywhere

### Example URLs

https://gofile.io/d/gqOtRf

### Description

gofile.io links are supported but if a password is required there is no way to pass a password to it. The above url has the password `password`. Running `yt-dlp https://gofile.io/d/gqOtRf` does not work and just asks for password.

### Verbose log

```shell
yt-dlp -vU https://gofile.io/d/gqOtRf
[debug] Command-line config: ['-vU', 'https://gofile.io/d/gqOtRf']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, err utf-8, pref UTF-8
[debug] yt-dlp version 2022.04.08 [7884ade65]
[debug] Lazy loading extractors is disabled
[debug] Python version 3.9.9 (CPython 64bit) - Linux-5.13.0-39-generic-x86_64-with-glibc2.34
[debug] Checking exe version: ffmpeg -bsfs
[debug] Checking exe version: ffprobe -bsfs
[debug] exe versions: ffmpeg 4.4 (setts), ffprobe 4.4, rtmpdump 2.4
[debug] Optional libraries: brotli, certifi, Cryptodome, secretstorage, mutagen, sqlite, websockets
[debug] Proxy map: {}
Latest version: 2022.04.08, Current version: 2022.04.08
yt-dlp is up to date (2022.04.08)
[Gofile] Getting a new guest account
[debug] [Gofile] Extracting URL: https://gofile.io/d/gqOtRf
[download] Downloading playlist: gqOtRf
[Gofile] Gofile: Getting filelist
ERROR: Gofile said: status error-passwordRequired
Traceback (most recent call last):
  File "/home/$USER/.local/lib/python3.9/site-packages/yt_dlp/YoutubeDL.py", line 1384, in wrapper
    return func(self, *args, **kwargs)
  File "/home/$USER/.local/lib/python3.9/site-packages/yt_dlp/YoutubeDL.py", line 1689, in <lambda>
    lambda self, i: ie_entries[i - 1]
  File "/home/$USER/.local/lib/python3.9/site-packages/yt_dlp/utils.py", line 2620, in __getitem__
    self.__cache.extend(itertools.islice(self.__iterable, n))
  File "/home/$USER/.local/lib/python3.9/site-packages/yt_dlp/extractor/gofile.py", line 63, in _entries
    raise ExtractorError(f'{self.IE_NAME} said: status {status}', expected=True)
yt_dlp.utils.ExtractorError: Gofile said: status error-passwordRequired

[Gofile] playlist gqOtRf: Downloading 0 videos
[download] Finished downloading playlist: gqOtRf
```



Discussion:

Resolving patch:
diff --git a/yt_dlp/extractor/gofile.py b/yt_dlp/extractor/gofile.py
--- 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 @@ def _real_initialize(self):
         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


Test patch: