]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/gofile.py
1 from .common
import InfoExtractor
8 class GofileIE(InfoExtractor
):
9 _VALID_URL
= r
'https?://(?:www\.)?gofile\.io/d/(?P<id>[^/]+)'
11 'url': 'https://gofile.io/d/AMZyDw',
15 'playlist_mincount': 2,
18 'id': 'de571ac1-5edc-42e2-8ec2-bdac83ad4a31',
22 'release_timestamp': 1638338704,
23 'release_date': '20211201',
27 'url': 'https://gofile.io/d/is8lKr',
33 'skip': 'No video/audio found at provided URL.',
35 'url': 'https://gofile.io/d/TMjXd9',
43 def _real_initialize(self
):
44 token
= self
._get
_cookies
('https://gofile.io/').get('accountToken')
46 self
._TOKEN
= token
.value
49 account_data
= self
._download
_json
(
50 'https://api.gofile.io/createAccount', None, note
='Getting a new guest account')
51 self
._TOKEN
= account_data
['data']['token']
52 self
._set
_cookie
('gofile.io', 'accountToken', self
._TOKEN
)
54 def _entries(self
, file_id
):
55 files
= self
._download
_json
('https://api.gofile.io/getContent', 'Gofile', note
='Getting filelist', query
={
58 'websiteToken': 12345,
61 status
= files
['status']
63 raise ExtractorError(f
'{self.IE_NAME} said: status {status}', expected
=True)
66 for file in (try_get(files
, lambda x
: x
['data']['contents'], dict) or {}).values():
67 file_type
, file_format
= file.get('mimetype').split('/', 1)
68 if file_type
not in ('video', 'audio') and file_format
!= 'vnd.mts':
72 file_url
= file.get('link')
76 'title': file['name'].rsplit('.', 1)[0],
78 'filesize': file.get('size'),
79 'release_timestamp': file.get('createTime')
83 raise ExtractorError('No video/audio found at provided URL.', expected
=True)
85 def _real_extract(self
, url
):
86 file_id
= self
._match
_id
(url
)
87 return self
.playlist_result(self
._entries
(file_id
), playlist_id
=file_id
)