Skip to content

Instantly share code, notes, and snippets.

@hthuong09
Created February 2, 2016 03:57
Show Gist options
  • Save hthuong09/a3fc331b6ab3df0887d0 to your computer and use it in GitHub Desktop.
Save hthuong09/a3fc331b6ab3df0887d0 to your computer and use it in GitHub Desktop.
Recursively get download link mediafire folder
from mediafire import MediaFireApi
import humanfriendly
import sys
import wget
api = MediaFireApi()
#folder_key = sys.argv[1]
folder_key = 'oct0x6rwhtkks';
response = api.request("user/get_session_token", {
"application_id": '*filldis*',
"email": '*filldis*',
"password": '*filldis*',
"signature": '*filldis*'
})
session_token = response['session_token']
def get_folder_content(folder_key):
print('Getting folder', folder_key, 'info...')
folders = get_folder_list(folder_key)
print('Found', len(folders), 'folders')
files = get_file_list(folder_key)
print('Found', len(files), 'files')
if (len(files) > 0):
FILE_LIST.extend(files)
for folder in folders:
get_folder_content(folder['folderkey'])
def get_folder_list(folder_key):
folders = []
response = api.request("folder/get_content", {
"folder_key": folder_key
})
for folder in response['folder_content']['folders']:
folders.append({
"name": folder['name'],
"folderkey": folder['folderkey'],
"folder_count": folder['folder_count'],
"file_count": folder['file_count']
})
return folders
def get_file_list(folder_key):
files = []
response = api.request("folder/get_content", {
"folder_key": folder_key,
"content_type": "files"
})
for file in response['folder_content']['files']:
files.append({
'filename': file['filename'],
'quickkey': file['quickkey'],
'size': humanfriendly.format_size(int(file['size'])),
'download_link': file['links']['normal_download']
})
return files
FILE_LIST = []
get_folder_content(folder_key)
for file in FILE_LIST:
response = api.request('file/get_links', {
"session_token": session_token,
"quick_key": file['quickkey'],
"signature": '*filldis*',
"link_type": 'direct_download'
})
link = response['links'][0]['direct_download']
fo = open("links.html", "a+")
fo.write('<a href="'+link+'">'+link+'</a><br />\n');
fo.close()
print(response['direct_download_free_bandwidth'])
@IbrahimMarzaq
Copy link

IbrahimMarzaq commented Nov 6, 2023

I need that in javascript
thank you

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