3 from .common
import InfoExtractor
10 class GofileIE(InfoExtractor
):
11 _VALID_URL
= r
'https?://(?:www\.)?gofile\.io/d/(?P<id>[^/]+)'
13 'url': 'https://gofile.io/d/AMZyDw',
17 'playlist_mincount': 2,
20 'id': 'de571ac1-5edc-42e2-8ec2-bdac83ad4a31',
24 'release_timestamp': 1638338704,
25 'release_date': '20211201',
29 'url': 'https://gofile.io/d/is8lKr',
35 'skip': 'No video/audio found at provided URL.',
37 'url': 'https://gofile.io/d/TMjXd9',
43 'url': 'https://gofile.io/d/gqOtRf',
47 'playlist_mincount': 1,
49 'videopassword': 'password',
54 def _real_initialize(self
):
55 token
= self
._get
_cookies
('https://gofile.io/').get('accountToken')
57 self
._TOKEN
= token
.value
60 account_data
= self
._download
_json
(
61 'https://api.gofile.io/accounts', None, 'Getting a new guest account', data
=b
'{}')
62 self
._TOKEN
= account_data
['data']['token']
63 self
._set
_cookie
('.gofile.io', 'accountToken', self
._TOKEN
)
65 def _entries(self
, file_id
):
66 query_params
= {'wt': '4fd6sg89d7s6'}
# From https://gofile.io/dist/js/alljs.js
67 password
= self
.get_param('videopassword')
69 query_params
['password'] = hashlib
.sha256(password
.encode('utf-8')).hexdigest()
70 files
= self
._download
_json
(
71 f
'https://api.gofile.io/contents/{file_id}', file_id
, 'Getting filelist',
72 query
=query_params
, headers
={'Authorization': f'Bearer {self._TOKEN}
'})
74 status = files['status
']
75 if status == 'error
-passwordRequired
':
77 'This video
is protected by a password
, use the
--video
-password option
', expected=True)
79 raise ExtractorError(f'{self.IE_NAME} said
: status {status}
', expected=True)
82 for file in (try_get(files, lambda x: x['data
']['children
'], dict) or {}).values():
83 file_type, file_format = file.get('mimetype
').split('/', 1)
84 if file_type not in ('video
', 'audio
') and file_format != 'vnd
.mts
':
88 file_url = file.get('link
')
92 'title
': file['name
'].rsplit('.', 1)[0],
94 'filesize
': file.get('size
'),
95 'release_timestamp
': file.get('createTime
')
99 raise ExtractorError('No video
/audio found at provided URL
.', expected=True)
101 def _real_extract(self, url):
102 file_id = self._match_id(url)
103 return self.playlist_result(self._entries(file_id), playlist_id=file_id)