Skip to content

Instantly share code, notes, and snippets.

@exzhawk
Created January 3, 2022 12:40
Show Gist options
  • Save exzhawk/11b1cbedc6c592792474bbe875520942 to your computer and use it in GitHub Desktop.
Save exzhawk/11b1cbedc6c592792474bbe875520942 to your computer and use it in GitHub Desktop.
Download gofile in cli. require aria2c
# -*- encoding: utf-8 -*-
# Author: Epix
import re
import subprocess
import fire
import requests
def main(gofile_url='https://gofile.io/d/Xf3djG'):
"""
https://gofile.io/d/Xf3djG
"""
content_id = re.fullmatch(r'https://gofile.io/d/([^/]*)', gofile_url).group(1)
s = requests.Session()
s.headers.update({
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36'
})
account_res = s.get('https://api.gofile.io/createAccount')
token = account_res.json()['data']['token']
content_res = s.get(
f'https://api.gofile.io/getContent?contentId={content_id}&token={token}&websiteToken=websiteToken')
contents = content_res.json()['data']['contents']
content_links = []
for content in contents.values():
content_links.append(content['link'])
download_command = [
'aria2c', '--enable-rpc=false', '-Z',
'--header', f'cookie: accountToken={token}',
*content_links
]
print(' '.join(download_command))
subprocess.run(download_command)
if __name__ == '__main__':
fire.Fire(main)
@eggplants
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment