Python HTTP API wrapper for Yandex Disk.
Project description
What is this?
This is pyandex-disk, a Python HTTP API wrapper for Yandex Disk.
Starting up
-
Get your access token here
-
Install the module
pip install pyandex-disk -
Enjoy
pyandex-disk, it has all the docs!
Example usage:
from pyandex_disk.client import DiskClient
disk = DiskClient("my_token")
# get info about my disk
info = disk.get_disk_info()
# get meta info about file/directory in my app directory/trash
meta_info = disk.get_meta_info(
path="path/to/my/file.jpg",
preview_size="100x100",
)
# get audio files list in my disk
files_info = disk.get_files_list(
limit=50,
media_type="audio",
)
# get last uploaded files list
last_uploaded = disk.get_last_uploaded(
limit=10,
media_type="video",
)
# set meta data to file in your app directory
setted_result = disk.set_meta_to_resource(
"my/file/to/extra/meta/data.txt,
data={"Custom Header": "custom value"},
)
# upload file to yandex disk
with open("/path/to/my/file.txt", "rb") as f:
disk.upload_file(
f,
path="app:/directory/file.txt",
overwrite=True
)
# upload file to disk by url
disk.upload_file_from_url(
"http://example.com/sitemap.xml",
path="app:/sitemap_example.xml",
)
# download file content from yandex.disk
content = disk.download_file(
"app:/sitemap_example.xml",
stream=False,
)
# copy resource in disk
disk.copy_resource(
from_path="app:/sitemap_example.xml",
to_path="app:/sitemap_example_copy.xml",
)
# move resource in your disk
disk.move_resource(
from_path="app:/sitemap_example_copy.xml",
to_path="app:/sitemap_example_movied_copy.xml",
)
# delete resource
disk.delete_resource(
"app:/sitemap_example_movied_copy.xml",
permanently=False, # to trash
)
# create folder in your disk
disk.create_folder(
"app:/new_folder",
)
# publish
disk.publish_resource("app:/new_folder")
# unpublish
disk.unpublish_resource("app:/new_folder")
# fully empty trash
disk.empty_trash()
# or remove file from trash
disk.empty_trash("app:/sitemap_example_movied_copy.xml")
# restore resource from trash
disk.restore_from_trash("app:/sitemap_example_movied_copy.xml")
# upload dir to disk
disk.upload_directory("/path/to/source", "app:/path/to/disk", overwrite=True)
Can I contribute to this project?
Of course, we welcome all contributions to this library. Just ensure you write an awesome code!
License
Read the LICENSE file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyandex_disk-1.0.0a0.tar.gz
(20.1 kB
view details)
File details
Details for the file pyandex_disk-1.0.0a0.tar.gz.
File metadata
- Download URL: pyandex_disk-1.0.0a0.tar.gz
- Upload date:
- Size: 20.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.7.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d327fa9ebb1771155576ece6aa0352589217932711673a7989d897aaac92a4e
|
|
| MD5 |
0ce137008e2a939e3360e53c145711c7
|
|
| BLAKE2b-256 |
f0bf5e83cb8cdbdb39924bd46064113538e6942145807481f70825f4aced8980
|