=========================
MediaFire Python Open SDK
=========================
This is a Python implementation of `MediaFire Core API`_ client.
.. _MediaFire Core Api: http://www.mediafire.com/developers/core_api/
==========
Installing
==========
.. code-block:: bash
$ pip install mediafire
==================
What should I use?
==================
If you are in a hurry, use ``MediaFireClient`` - 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 to ``MediaFireApi`` and ``MediaFireUploader`` to have as much
control as possible over your application flow.
======================
mediafire.MediaFireApi
======================
API Client library provides an interface to MediaFire API. It handles
requests, responses, signatures and errors.
Usage:
.. code-block:: python
from mediafire import MediaFireApi
api = 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 = session
response = api.user_get_info()
print(response['user_info']['display_name'])
# Or directly for methods that are not yet wrapped
response = 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:
.. code-block:: python
from mediafire import MediaFireApi
api = MediaFireApi()
response = api.system_get_info()
print(response) # prints system info
response = api.user_get_info() # fails with "Session token is missing"
Once set, session token can be unset:
.. code-block:: python
api.session = None
# or
del api.session
For information on wrapped methods, see ``pydoc mediafire.api``. For
documentation on actual values expected, see `MediaFire Core API`_
documentation.
All wrapped methods follow the same naming convention, ``category_action``, so
upload/instant is ``upload_instant``.
You can construct the call yourself easily:
.. code-block:: python
response = api.request("user/set_avatar",
{"quick_key": "123456789012345"})
Downloading
-----------
API 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:
.. code-block:: python
response = api.file_get_links('c94lcpx3vax6xp3')
normal_download_url = response['links'][0]['normal_download']
response = requests.get(normal_download_url, stream=True)
with io.open("/tmp/green.jpg", 'wb') as fd:
for chunk in response.iter_content(chunk_size=4096):
fd.write(chunk)
In case response is a file download, e.g. ``file/zip``, the response returned
is a `requests.Response`_ object, which you can read from:
.. code-block:: python
...
response = api.request("file/zip", {"keys": "c94lcpx3vax6xp3"})
with io.open("/tmp/green.zip", 'wb') as fd:
for chunk in response.iter_content(chunk_size=4096):
fd.write(chunk)
...
.. _requests.Response: http://docs.python-requests.org/en/latest/api/#requests.Response
See Download_ documentation for more information.
.. _Download: http://www.mediafire.com/developers/core_api/1.2/download/
===========================
mediafire.MediaFireUploader
===========================
MediaFire supports several upload methods and `MediaFireUploader` exposes a
single `upload` method to make things easier:
.. code-block:: python
from mediafire import (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))
``result`` is a ``mediafire.uploader.UploadResult`` instance.
FileDrop
--------
For FileDrop uploads (i.e. when filedrop_key is used) only ``upload/instant``
result has quickkey. ``upload/instant`` and ``upload/resumable`` return
``None`` for all the fields, since ``upload/poll`` does not support
encrypted upload key.
======================================
mediafire.media.ConversionServerClient
======================================
This API is subject to change
This is a very thin layer on top of Image and Document conversion API.
.. code-block:: python
from mediafire.media import ConversionServerClient
conv = ConversionServerClient()
response = conv.request('2004', 'm8d6blce79xhxl5', 'i', size_id='1')
with open('/tmp/example.jpg', 'rb') as fd:
fd.write(response.content)
================================
mediafire.client.MediaFireClient
================================
This API is subject to change
High-level client library wraps API calls and presents simplified interface.
Supported operations:
* File upload
* File download (direct download link)
* Listing directories
* Creating directories
* Removing files and directories
* Getting info about files and directories
MediaFire resources can be referenced by path or by quickkey/folderkey.
* **path**: ``mf:/Pictures/Sample.jpg`` or ``/Pictures/Sample.jpg``
* **folder_key**: ``mf:6302u1a9p0a9x`` (``folder_key`` is 13 chars long)
* **quick_key**: ``mf:46d3y4p8542kiyp`` (``quick_key`` is 15 chars long)
.. code-block:: python
from mediafire.client import (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")
for item in client.get_folder_contents_iter("mf:/Pictures"):
if type(item) is File:
print("File: {}".format(item['filename']))
elif type(item) is Folder:
print("Folder: {}".format(item['name']))
See ``examples/mediafire-cli.py`` for high-level client usage.
Requirements
------------
* python 2.7 or 3.4
* six
* requests
* requests\_toolbelt
* responses (for testing)
Tests
-----
Test suite is located under ``tests/``
.. code-block:: bash
git clone https://github.com/MediaFire/mediafire-python-open-sdk.git
cd mediafire-python-open-sdk
# Run tests with python 3 interpreter
PYTHONPATH=. python3 -munittest
# Run tests with python 2 interpreter
PYTHONPATH=. python -munittest discover
================
Reporting issues
================
See https://pypi.org/project/mediafire/ for the current maintainer.
=================
About and License
=================
Copyright (c) 2014, Roman Yepishev. All rights reserved. Website: http://www.keypressure.com
This project was forked by MediaFire with explicit permission from Roman Yepishev on 10.24.2014
This project is made under BSD license. See LICENSE file for more information.
MediaFire® is a registered trademark of the MediaFire, LLC.
Raw data
{
"_id": null,
"home_page": "",
"name": "mediafire",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "mediafire cloud files sdk storage api upload",
"author": "Roman Yepishev",
"author_email": "rye@keypressure.com",
"download_url": "https://files.pythonhosted.org/packages/0c/fe/491d7b3200f3c3cf894e8c05415be4ee5537bf318d9c04ddd53846edf6b3/mediafire-0.6.1.tar.gz",
"platform": null,
"description": "=========================\nMediaFire Python Open SDK\n=========================\n\n\nThis is a Python implementation of `MediaFire Core API`_ client.\n\n.. _MediaFire Core Api: http://www.mediafire.com/developers/core_api/\n\n==========\nInstalling\n==========\n\n.. code-block:: bash\n\n $ pip install mediafire\n\n==================\nWhat should I use?\n==================\n\nIf you are in a hurry, use ``MediaFireClient`` - it contains enough functions to\nget your uploads/downloads and file listings working. It does not have a stable API,\nand has rudimentary test coverage only.\n\nYou may want to stick to ``MediaFireApi`` and ``MediaFireUploader`` to have as much\ncontrol as possible over your application flow.\n\n======================\nmediafire.MediaFireApi\n======================\n\nAPI Client library provides an interface to MediaFire API. It handles\nrequests, responses, signatures and errors.\n\nUsage:\n\n.. code-block:: python\n\n from mediafire import MediaFireApi\n\n api = MediaFireApi()\n session = api.user_get_session_token(\n email='your.email@example.net',\n password='password',\n app_id='42511')\n\n # API client does not know about the token\n # until explicitly told about it:\n api.session = session\n\n response = api.user_get_info()\n print(response['user_info']['display_name'])\n\n # Or directly for methods that are not yet wrapped\n response = api.request(\"upload/add_web_upload\", {\n \"url\": \"http://forum.mediafiredev.com/images/mfforumlogo.png\",\n \"filename\": \"mfforumlogo.png\"})\n\n response = api.request(\"upload/get_web_uploads\",\n {\"key\": response['upload_key']})\n\n\nAPI Client library supports operation w/o session_token. In this case all\noperations that do require session_token will fail with Access denied error:\n\n.. code-block:: python\n\n from mediafire import MediaFireApi\n\n api = MediaFireApi()\n response = api.system_get_info()\n print(response) # prints system info\n\n response = api.user_get_info() # fails with \"Session token is missing\"\n\nOnce set, session token can be unset:\n\n.. code-block:: python\n\n api.session = None\n # or\n del api.session\n\nFor information on wrapped methods, see ``pydoc mediafire.api``. For\ndocumentation on actual values expected, see `MediaFire Core API`_\ndocumentation.\n\nAll wrapped methods follow the same naming convention, ``category_action``, so\nupload/instant is ``upload_instant``.\n\nYou can construct the call yourself easily:\n\n.. code-block:: python\n\n response = api.request(\"user/set_avatar\",\n {\"quick_key\": \"123456789012345\"})\n\nDownloading\n-----------\n\nAPI client does not handle regular file downloads because these are simple HTTP requests\nto URLs returned by \"file/get_links\". Here's how you can do that yourself:\n\n.. code-block:: python\n\n response = api.file_get_links('c94lcpx3vax6xp3')\n normal_download_url = response['links'][0]['normal_download']\n\n response = requests.get(normal_download_url, stream=True)\n with io.open(\"/tmp/green.jpg\", 'wb') as fd:\n for chunk in response.iter_content(chunk_size=4096):\n fd.write(chunk)\n\nIn case response is a file download, e.g. ``file/zip``, the response returned\nis a `requests.Response`_ object, which you can read from:\n\n.. code-block:: python\n\n ...\n response = api.request(\"file/zip\", {\"keys\": \"c94lcpx3vax6xp3\"})\n with io.open(\"/tmp/green.zip\", 'wb') as fd:\n for chunk in response.iter_content(chunk_size=4096):\n fd.write(chunk)\n ...\n\n.. _requests.Response: http://docs.python-requests.org/en/latest/api/#requests.Response\n\nSee Download_ documentation for more information.\n\n.. _Download: http://www.mediafire.com/developers/core_api/1.2/download/\n\n===========================\nmediafire.MediaFireUploader\n===========================\n\nMediaFire supports several upload methods and `MediaFireUploader` exposes a\nsingle `upload` method to make things easier:\n\n.. code-block:: python\n\n from mediafire import (MediaFireApi, MediaFireUploader)\n\n api = MediaFireApi()\n uploader = MediaFireUploader(api)\n\n # ... authenticate ...\n\n fd = open('/path/to/file', 'rb')\n\n result = uploader.upload(fd, 'Some filename.txt',\n folder_key='1234567890123')\n\n pprint(api.file_get_info(result.quickkey))\n\n``result`` is a ``mediafire.uploader.UploadResult`` instance.\n\nFileDrop\n--------\n\nFor FileDrop uploads (i.e. when filedrop_key is used) only ``upload/instant``\nresult has quickkey. ``upload/instant`` and ``upload/resumable`` return\n``None`` for all the fields, since ``upload/poll`` does not support\nencrypted upload key.\n\n\n======================================\nmediafire.media.ConversionServerClient\n======================================\n\nThis API is subject to change\n\nThis is a very thin layer on top of Image and Document conversion API.\n\n.. code-block:: python\n\n from mediafire.media import ConversionServerClient\n\n conv = ConversionServerClient()\n\n response = conv.request('2004', 'm8d6blce79xhxl5', 'i', size_id='1')\n with open('/tmp/example.jpg', 'rb') as fd:\n fd.write(response.content)\n\n\n================================\nmediafire.client.MediaFireClient\n================================\n\nThis API is subject to change\n\nHigh-level client library wraps API calls and presents simplified interface.\n\nSupported operations:\n\n* File upload\n* File download (direct download link)\n* Listing directories\n* Creating directories\n* Removing files and directories\n* Getting info about files and directories\n\nMediaFire resources can be referenced by path or by quickkey/folderkey.\n\n* **path**: ``mf:/Pictures/Sample.jpg`` or ``/Pictures/Sample.jpg``\n* **folder_key**: ``mf:6302u1a9p0a9x`` (``folder_key`` is 13 chars long)\n* **quick_key**: ``mf:46d3y4p8542kiyp`` (``quick_key`` is 15 chars long)\n\n.. code-block:: python\n\n from mediafire.client import (MediaFireClient, File, Folder)\n\n client = MediaFireClient()\n client.login(email='your.email@example.net',\n password='password',\n app_id='42511')\n\n client.upload_file(\"flower.jpg\", \"mf:/Pictures/\")\n client.download_file(\"mf:/Pictures/flower.jpg\",\n \"flower-from-mediafire.jpg\")\n\n for item in client.get_folder_contents_iter(\"mf:/Pictures\"):\n if type(item) is File:\n print(\"File: {}\".format(item['filename']))\n elif type(item) is Folder:\n print(\"Folder: {}\".format(item['name']))\n\nSee ``examples/mediafire-cli.py`` for high-level client usage.\n\nRequirements\n------------\n\n* python 2.7 or 3.4\n* six\n* requests\n* requests\\_toolbelt\n* responses (for testing)\n\nTests\n-----\n\nTest suite is located under ``tests/``\n\n.. code-block:: bash\n\n\n git clone https://github.com/MediaFire/mediafire-python-open-sdk.git\n cd mediafire-python-open-sdk\n # Run tests with python 3 interpreter\n PYTHONPATH=. python3 -munittest\n # Run tests with python 2 interpreter\n PYTHONPATH=. python -munittest discover\n\n================\nReporting issues\n================\n\nSee https://pypi.org/project/mediafire/ for the current maintainer.\n\n=================\nAbout and License\n=================\n\nCopyright (c) 2014, Roman Yepishev. All rights reserved. Website: http://www.keypressure.com\n\nThis project was forked by MediaFire with explicit permission from Roman Yepishev on 10.24.2014\n\nThis project is made under BSD license. See LICENSE file for more information.\n\nMediaFire\u00c2\u00ae is a registered trademark of the MediaFire, LLC.\n\n\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "Python MediaFire client library",
"version": "0.6.1",
"split_keywords": [
"mediafire",
"cloud",
"files",
"sdk",
"storage",
"api",
"upload"
],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "dc86379e96eb3c3fa0c7108bff031f6d",
"sha256": "2f237cc12cb7c10f8aa8efcced1de453512ebc97f603975e6e3a2a769bc93f5b"
},
"downloads": -1,
"filename": "mediafire-0.6.1-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "dc86379e96eb3c3fa0c7108bff031f6d",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 22858,
"upload_time": "2023-01-01T18:40:14",
"upload_time_iso_8601": "2023-01-01T18:40:14.826574Z",
"url": "https://files.pythonhosted.org/packages/dc/32/81bb519715b4d8c69edcb6c7301549b587bbf7b28ea342b6018293332b4a/mediafire-0.6.1-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "753e66ef168c2cc457db4c33288d1ab1",
"sha256": "a1adfeff43dfb611d560c920f6ec18a05b5197b2b15093b08591e45ce879353e"
},
"downloads": -1,
"filename": "mediafire-0.6.1.tar.gz",
"has_sig": false,
"md5_digest": "753e66ef168c2cc457db4c33288d1ab1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 24699,
"upload_time": "2023-01-01T18:40:16",
"upload_time_iso_8601": "2023-01-01T18:40:16.561396Z",
"url": "https://files.pythonhosted.org/packages/0c/fe/491d7b3200f3c3cf894e8c05415be4ee5537bf318d9c04ddd53846edf6b3/mediafire-0.6.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-01 18:40:16",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "mediafire"
}