Skip to content

Instantly share code, notes, and snippets.

@thelazyliz
Last active July 16, 2020 07:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thelazyliz/4e4ae052b36bb940c2621e401877b904 to your computer and use it in GitHub Desktop.
Save thelazyliz/4e4ae052b36bb940c2621e401877b904 to your computer and use it in GitHub Desktop.
get direct resource link from masv download link
import requests
import re
import sys
root_url = "https://api.massive.app/v1"
def get_masv(dl_link, password=None):
print('Retrieving direct link(s)...')
split_link = re.split('[/?=]', dl_link)
link_id = split_link[3]
secret = split_link[-1]
header = {}
if password:
header = {'X-Link-Password': password}
r = requests.get(
f'{root_url}/links/{link_id}',
headers=header,
params={'secret': secret}
)
if not r.ok:
return False, r.json()
package_token = r.json()["package_token"]
package_id = r.json()["package_id"]
r2 = requests.get(
f'{root_url}/packages/{package_id}/files',
headers={'X-Package-Token': package_token}
)
if not r2.ok:
return False, r2.json()
files_url = {}
for item in r2.json():
r3 = requests.get(
f'{root_url}/packages/{package_id}/files/{item["id"]}/download',
headers={'X-Package-Token': package_token}
)
files_url[item["name"]] = r3.json()['url']
return True, files_url
if __name__ == "__main__":
if len(sys.argv) < 2 or len(sys.argv) > 3:
print(
'Correct usage is python get_masv.py [download link] [password (optional)]'
)
sys.exit()
status, resp = get_masv(*sys.argv[1::])
if status:
print('Success! The links are: \n')
print(resp)
else:
print('Something went wrong: \n')
print(resp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment