]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/gofile.py
2 from .common
import InfoExtractor
9 class GofileIE(InfoExtractor
):
10 _VALID_URL
= r
'https?://(?:www\.)?gofile\.io/d/(?P<id>[^/]+)'
12 'url': 'https://gofile.io/d/AMZyDw',
16 'playlist_mincount': 2,
19 'id': 'de571ac1-5edc-42e2-8ec2-bdac83ad4a31',
25 }, { # URL to test mixed file types
26 'url': 'https://gofile.io/d/avt34h',
30 'playlist_mincount': 1,
31 }, { # URL to test no video/audio error
32 'url': 'https://gofile.io/d/aB03lZ',
37 'skip': 'No video/audio found at provided URL.',
41 def _real_initialize(self
):
42 token
= self
._get
_cookies
('https://gofile.io/').get('accountToken')
44 self
._TOKEN
= token
.value
47 account_data
= self
._download
_json
(
48 'https://api.gofile.io/createAccount', None, note
='Getting a new guest account')
49 self
._TOKEN
= account_data
['data']['token']
50 self
._set
_cookie
('gofile.io', 'accountToken', self
._TOKEN
)
52 def _entries(self
, file_id
):
53 files
= self
._download
_json
(
54 f
'https://api.gofile.io/getContent?contentId={file_id}&token={self._TOKEN}&websiteToken=websiteToken&cache=true',
55 'Gofile', note
='Getting filelist')
57 status
= files
['status']
59 raise ExtractorError(f
'{self.IE_NAME} said: status {status}', expected
=True)
62 for file in (try_get(files
, lambda x
: x
['data']['contents'], dict) or {}).values():
63 file_type
, file_format
= file.get('mimetype').split('/', 1)
64 if file_type
not in ('video', 'audio') and file_format
!= 'vnd.mts':
68 file_url
= file.get('directLink')
72 'title': file['name'].rsplit('.', 1)[0],
74 'filesize': file.get('size'),
75 'release_timestamp': file.get('createTime')
79 raise ExtractorError('No video/audio found at provided URL.', expected
=True)
81 def _real_extract(self
, url
):
82 file_id
= self
._match
_id
(url
)
83 return self
.playlist_result(self
._entries
(file_id
), playlist_id
=file_id
)