k20human / synology

[WIP] Python binding to Synology DSM API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Synology

Build Status Requirements Status

Python3 binding to Synology DSM API. I refer to the following document: Synology_File_Station_API_Guide.pdf. Any help is welcome, please fork this repo and make a pull request, or contact me directly.

API coverage

Implemented

Endpoint Description
SYNO.FileStation.Info Provide File Station info
SYNO.FileStation.List List all shared folders, enumerate files in a shared folder,and get detailed file information
SYNO.FileStation.DirSize Get the total size of files/folders within folder(s)
SYNO.FileStation.MD5 Get MD5 of a file
SYNO.FileStation.CreateFolder Create folder(s)
SYNO.FileStation.Rename Rename a file/folder
SYNO.FileStation.Delete Delete files/folders
SYNO.FileStation.Search Search files on given criteria
SYNO.FileStation.Thumb Get a thumbnail of a file
SYNO.FileStation.CheckPermission Check if the file/folder has a permission of a file/folder or not
SYNO.FileStation.Upload Upload a file
SYNO.FileStation.Download Download files/folders

TODO

Endpoint Description
SYNO.FileStation.VirtualFolder List all mount point folders of virtual file system, ex: CIFS or ISO
SYNO.FileStation.Favorite Add a folder to user’s favorites or do operations on user’s favorites
SYNO.FileStation.Sharing Generate a sharing link to share files/folders with other people and perform operations on sharing links
SYNO.FileStation.CopyMove Copy/Move files/folders
SYNO.FileStation.Extract Extract an archive and do operations on an archive
SYNO.FileStation.Compress Compress files/folders
SYNO.FileStation.BackgroundTask Get information regarding tasks of file operations which are run as the background process including copy, move, delete, compress and extract tasks or perform operations on these background tasks.

Install

pip install [--upgrade] https://github.com/satreix/synology/tarball/master#egg=synology

I do need to publish a PyPi version.

Usage

import config

from synology.api import Api
from synology.filestation import FileStation
from synology.utils import jsonprint

logging.basicConfig(level=logging.INFO)

# Instanciate directly
syno = Api(config.host, config.user, config.passwd)
syno.req('SYNO.API.Info', query='all')
syno.req('SYNO.FileStation.Info', end='info', extra='FileStation/',
    method='getinfo')
syno.jsonprint(syno.req(syno.endpoint('SYNO.FileStation.List',
    cgi='FileStation/file_share.cgi', method='list_share')))
syno.jsonprint(syno.req(syno.endpoint('SYNO.FileStation.Info',
    cgi='FileStation/info.cgi', method='getinfo')))

# Instanciate a FileStation
filestation = FileStation(config.host, config.user, config.passwd)
filestation.jsonprint(filestation.get_info())
filestation.jsonprint(filestation.get_shares())

Other implementations

The following projects I found on PyPI:

I would like to merge some of them together into one library and multiple apps using it.

About

[WIP] Python binding to Synology DSM API

License:MIT License


Languages

Language:Python 100.0%