Skip to content

TyVik/YaDiskClient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YaDiskClient

image

image

image

image

image

image

Client for Yandex.Disk based on WebDav.

Install

pip install YaDiskClient

Source code

github

explanatory article

Passwords and tokens

You must use application password, not account password! Details - https://yandex.ru/support/id/authorization/app-passwords.html

Also, you can create OAuth-token for your application. Details - https://yandex.ru/dev/disk/doc/dg/concepts/quickstart.html

Both methods are supported. You should use method set_login or set_token before start.

Using API

from YaDiskClient.YaDiskClient import YaDisk
disk = YaDisk()
disk.set_auth(login, password)

"""
Library also supports token authorization via:
disk.set_token(token)
"""

disk.df() # show used and available space

disk.ls(path) # list of files/folder with attributes
disk.mkdir(path) # create directory

disk.rm(path) # remove file or directory
disk.cp(src, dst) # copy from src to dst
disk.mv(src, dst) # move from src to dst

disk.upload(src, dst) # upload local file src to remote file dst
disk.download(src, dst) # download remote file src to local file dst

disk.publish_doc(path) # return public url
disk.hide_doc(path) # remove public url form Yandex Disk

Tests

For run tests:
  1. Set Yandex username and password in file tests/test_YaDiskClient.py
  2. python -m unittest discover -s tests -t tests