Package: mediafire
MediaFire Python Open SDKThis is a Python implementation ofMediaFire Core APIclient.Installing$pipinstallmediafireWhat should I use?If you are in a hurry, useMediaFireClient- it contains enough functions to
get your uploads/downloads and file listings working. It does not have a stable API,
and has rudimentary test coverage only.You may want to stick toMediaFireApiandMediaFireUploaderto have as much
control as possible over your application flow.mediafire.MediaFireApiAPI Client library provides an interface to MediaFire API. It handles
requests, responses, signatures and errors.Usage:frommediafireimportMediaFireApiapi=MediaFireApi()session=api.user_get_session_token(email='your.email@example.net',password='password',app_id='42511')# API client does not know about the token# until explicitly told about it:api.session=sessionresponse=api.user_get_info()print(response['user_info']['display_name'])# Or directly for methods that are not yet wrappedresponse=api.request("upload/add_web_upload",{"url":"http://forum.mediafiredev.com/images/mfforumlogo.png","filename":"mfforumlogo.png"})response=api.request("upload/get_web_uploads",{"key":response['upload_key']})API Client library supports operation w/o session_token. In this case all
operations that do require session_token will fail with Access denied error:frommediafireimportMediaFireApiapi=MediaFireApi()response=api.system_get_info()print(response)# prints system inforesponse=api.user_get_info()# fails with "Session token is missing"Once set, session token can be unset:api.session=None# ordelapi.sessionFor information on wrapped methods, seepydoc mediafire.api. For
documentation on actual values expected, seeMediaFire Core APIdocumentation.All wrapped methods follow the same naming convention,category_action, so
upload/instant isupload_instant.You can construct the call yourself easily:response=api.request("user/set_avatar",{"quick_key":"123456789012345"})DownloadingAPI client does not handle regular file downloads because these are simple HTTP requests
to URLs returned by “file/get_links”. Here’s how you can do that yourself:response=api.file_get_links('c94lcpx3vax6xp3')normal_download_url=response['links'][0]['normal_download']response=requests.get(normal_download_url,stream=True)withio.open("/tmp/green.jpg",'wb')asfd:forchunkinresponse.iter_content(chunk_size=4096):fd.write(chunk)In case response is a file download, e.g.file/zip, the response returned
is arequests.Responseobject, which you can read from:...response=api.request("file/zip",{"keys":"c94lcpx3vax6xp3"})withio.open("/tmp/green.zip",'wb')asfd:forchunkinresponse.iter_content(chunk_size=4096):fd.write(chunk)...SeeDownloaddocumentation for more information.mediafire.MediaFireUploaderMediaFire supports several upload methods andMediaFireUploaderexposes a
singleuploadmethod to make things easier:frommediafireimport(MediaFireApi,MediaFireUploader)api=MediaFireApi()uploader=MediaFireUploader(api)# ... authenticate ...fd=open('/path/to/file','rb')result=uploader.upload(fd,'Some filename.txt',folder_key='1234567890123')pprint(api.file_get_info(result.quickkey))resultis amediafire.uploader.UploadResultinstance.FileDropFor FileDrop uploads (i.e. when filedrop_key is used) onlyupload/instantresult has quickkey.upload/instantandupload/resumablereturnNonefor all the fields, sinceupload/polldoes not support
encrypted upload key.mediafire.media.ConversionServerClientThis API is subject to changeThis is a very thin layer on top of Image and Document conversion API.frommediafire.mediaimportConversionServerClientconv=ConversionServerClient()response=conv.request('2004','m8d6blce79xhxl5','i',size_id='1')withopen('/tmp/example.jpg','rb')asfd:fd.write(response.content)mediafire.client.MediaFireClientThis API is subject to changeHigh-level client library wraps API calls and presents simplified interface.Supported operations:File uploadFile download (direct download link)Listing directoriesCreating directoriesRemoving files and directoriesGetting info about files and directoriesMediaFire resources can be referenced by path or by quickkey/folderkey.path:mf:/Pictures/Sample.jpgor/Pictures/Sample.jpgfolder_key:mf:6302u1a9p0a9x(folder_keyis 13 chars long)quick_key:mf:46d3y4p8542kiyp(quick_keyis 15 chars long)frommediafire.clientimport(MediaFireClient,File,Folder)client=MediaFireClient()client.login(email='your.email@example.net',password='password',app_id='42511')client.upload_file("flower.jpg","mf:/Pictures/")client.download_file("mf:/Pictures/flower.jpg","flower-from-mediafire.jpg")foriteminclient.get_folder_contents_iter("mf:/Pictures"):iftype(item)isFile:print("File:{}".format(item['filename']))eliftype(item)isFolder:print("Folder:{}".format(item['name']))Seeexamples/mediafire-cli.pyfor high-level client usage.Requirementspython 2.7 or 3.4sixrequestsrequests_toolbeltresponses (for testing)TestsTest suite is located undertests/gitclonehttps://github.com/MediaFire/mediafire-python-open-sdk.gitcdmediafire-python-open-sdk# Run tests with python 3 interpreterPYTHONPATH=.python3-munittest# Run tests with python 2 interpreterPYTHONPATH=.python-munittestdiscoverReporting issuesSeehttps://pypi.org/project/mediafire/for the current maintainer.About and LicenseCopyright (c) 2014, Roman Yepishev. All rights reserved. Website:http://www.keypressure.comThis project was forked by MediaFire with explicit permission from Roman Yepishev on 10.24.2014This project is made under BSD license. See LICENSE file for more information.MediaFireÂ® is a registered trademark of the MediaFire, LLC.