Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/gofile.py (Python)

Code before:
        print('Getting a new guest account')
        get_account_data = requests.post('https://api.gofile.io/accounts', '{}')
        account_data = get_account_data.json()
        # account_data = self._download_json(get_account_data, None, note='Getting a new guest account')
        self._TOKEN = account_data['data']['token']
        self._set_cookie('.gofile.io', 'accountToken', self._TOKEN)

    def _entries(self, file_id):
        query_params = {
            # 'contentId': file_id,
            # 'token': self._TOKEN,
            'wt': '4fd6sg89d7s6',  # From https://gofile.io/dist/js/alljs.js
        }
        password = self.get_param('videopassword')
        if password:
            query_params['password'] = hashlib.sha256(password.encode('utf-8')).hexdigest()
        get_files = self._download_webpage(
            'https://api.gofile.io/contents/' + file_id,
            None,
            headers={
                'authority': 'api.gofile.io',
                'authorization': 'Bearer ' + self._TOKEN,
                'referer': 'https://gofile.io/',
                'origin': 'https://gofile.io'
            }, query=query_params)
        files = json.loads(get_files)
        status = files['status']
        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
        for file in (try_get(files, lambda x: x['data']['children'], dict) or {}).values():
            file_type, file_format = file.get('mimetype').split('/', 1)
            if file_type not in ('video', 'audio') and file_format != 'vnd.mts':
                continue

            found_files = True
            file_url = file.get('link')
            if file_url:
                yield {
                    'id': file['id'],
                    'title': file['name'].rsplit('.', 1)[0],
                    'url': file_url,
                    'filesize': file.get('size'),
                    'release_timestamp': file.get('createTime')
                }

        if not found_files:

Review comment (security):
```suggestion
        files = self._download_json(
            f'https://api.gofile.io/contents/{file_id}', file_id, 'Getting filelist',
            query=query_params, headers={'Authorization': f'Bearer {self._TOKEN}'})
```

Code after:
        self._TOKEN = account_data['data']['token']
        self._set_cookie('.gofile.io', 'accountToken', self._TOKEN)

    def _entries(self, file_id):
        query_params = {'wt': '4fd6sg89d7s6'}  # From https://gofile.io/dist/js/alljs.js
        password = self.get_param('videopassword')
        if password:
            query_params['password'] = hashlib.sha256(password.encode('utf-8')).hexdigest()
        files = self._download_json(
            f'https://api.gofile.io/contents/{file_id}', file_id, 'Getting filelist',
            query=query_params, headers={'Authorization': f'Bearer {self._TOKEN}'})

        status = files['status']
        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
        for file in (try_get(files, lambda x: x['data']['children'], dict) or {}).values():
            file_type, file_format = file.get('mimetype').split('/', 1)
            if file_type not in ('video', 'audio') and file_format != 'vnd.mts':
                continue

            found_files = True
            file_url = file.get('link')
            if file_url:
                yield {
                    'id': file['id'],
                    'title': file['name'].rsplit('.', 1)[0],
                    'url': file_url,
                    'filesize': file.get('size'),
                    'release_timestamp': file.get('createTime')
                }

        if not found_files:
            raise ExtractorError('No video/audio found at provided URL.', expected=True)

    def _real_extract(self, url):
        file_id = self._match_id(url)
        return self.playlist_result(self._entries(file_id), playlist_id=file_id)