群暉的NAS一直口碑都不錯榛了,主要是安全性和功能都比較完善,可玩性比較高煞抬。最近在學(xué)Python霜大,就想著拿PhotoStation的API來練練手,看看能不能搗鼓出一些新的功能來革答。
結(jié)果上網(wǎng)這么一查战坤,沒想到群暉竟然沒有提供官方的API文檔(倒是提供了File Station API Guide)真是讓人大跌眼鏡,是擔(dān)心被玩壞呢還是怎么想残拐。好不容易從其他地方找到了一些資料途茫,這里給大家做下分享,也是拋磚引玉溪食,如果有人找到官方的API囊卜,也請留言,多謝。
1栅组、API接口
接口API主要由以下5個基本要素組成
- API name: Name of the API requested
- version: Version of the API requested
- path: path of the API. The path information can be retrieved by requesting SYNO.API.Info
- method: Method of the API requested
- _sid: Authorized session ID. Each API request should pass it, which is retrieved from the
response of /webapi/auth.cgi, via either HTTP/HTTPS GET/POST method with “_sid”
argument. Otherwise, if you pass it within “id” value of cookie of HTTP/HTTPS header, this
parameter can be ignored.
語法
GET /webapi/<CGI_PATH>?api=<API_NAME>&version=<VERSION>&method=<METHOD>[&<PARAMS>][&_sid=<SID>]
例子
http://myds.com:port/webapi/query.cgi?api=SYNO.API.Info&version=1&method=query&query=all
API name: SYNO.API.Info
version: 1
path: query.cgi
method: query
params: query=all
調(diào)用步驟
PhotoStation API 列表
{
"SYNO.PhotoStation.Auth": {
"path": "auth.php",
"minVersion": 1,
"maxVersion": 1,
"methods": {
"1": ["login", "logout", "checkauth"]
}
},
"SYNO.PhotoStation.Info": {
"path": "info.php",
"minVersion": 1,
"maxVersion": 1,
"methods": {
"1": ["getinfo"]
}
},
"SYNO.PhotoStation.Album": {
"path": "album.php",
"minVersion": 1,
"maxVersion": 1,
"methods": {
"1": ["list", "getinfo", "create", "edit", "delete", "arrangeitem", "move", "cleararrangeitem", "cancel"]
}
},
"SYNO.PhotoStation.Permission": {
"path": "permission.php",
"minVersion": 1,
"maxVersion": 1,
"methods": {
"1": ["getalbum", "editalbum", "editgroup", "list_public_share", "edit_public_share"]
}
},
"SYNO.PhotoStation.Photo": {
"path": "photo.php",
"minVersion": 1,
"maxVersion": 1,
"methods": {
"1": ["list", "listexif", "listfeatureditem", "listgpsgroup", "listgpsgroupeditem", "getinfo", "getexif", "edit", "delete", "copy", "cancel"]
}
},
"SYNO.PhotoStation.Thumb": {
"path": "thumb.php",
"minVersion": 1,
"maxVersion": 1,
"methods": {
"1": ["get", "get_dsm_thumb"]
}
},
"SYNO.PhotoStation.Cover": {
"path": "cover.php",
"minVersion": 1,
"maxVersion": 2,
"methods": {
"1": ["set"],
"2": ["set","setsmart"]
}
},
"SYNO.PhotoStation.SmartAlbum": {
"path": "smart_album.php",
"minVersion": 1,
"maxVersion": 1,
"methods": {
"1": ["list", "getinfo", "create", "edit", "delete"]
}
},
"SYNO.PhotoStation.File": {
"path": "file.php",
"minVersion": 1,
"maxVersion": 1,
"methods": {
"1": ["uploadphoto", "uploadvideo"]
}
},
"SYNO.PhotoStation.Download": {
"path": "download.php",
"minVersion": 1,
"maxVersion": 1,
"methods": {
"1": ["getphoto", "getvideo", "getitem"]
}
},
"SYNO.PhotoStation.Category": {
"path": "category.php",
"minVersion": 1,
"maxVersion": 1,
"methods": {
"1": ["list", "getinfo", "create", "edit", "delete", "arrangecategory", "listitem", "additem", "removeitem", "arrangeitem"]
}
},
"SYNO.PhotoStation.About": {
"path": "about.php",
"minVersion": 1,
"maxVersion": 1,
"methods": {
"1": ["get", "set", "set_visibility"]
}
},
"SYNO.PhotoStation.Tag": {
"path": "tag.php",
"minVersion": 1,
"maxVersion": 1,
"methods": {
"1": ["list", "getinfo", "create", "edit", "delete", "searchplace", "delete_unconfirmed_tag"]
}
},
"SYNO.PhotoStation.PhotoTag": {
"path": "photo_tag.php",
"minVersion": 1,
"maxVersion": 1,
"methods": {
"1": ["list", "people_tag", "geo_tag", "desc_tag", "delete", "people_tag_confirm"]
}
},
"SYNO.PhotoStation.Comment": {
"path": "comment.php",
"minVersion": 1,
"maxVersion": 1,
"methods": {
"1": ["list", "create", "delete"]
}
},
"SYNO.PhotoStation.Timeline": {
"path": "timeline.php",
"minVersion": 1,
"maxVersion": 1,
"methods": {
"1": ["getindex"]
}
},
"SYNO.PhotoStation.Group": {
"path": "group.php",
"minVersion": 1,
"maxVersion": 1,
"methods": {
"1": ["list", "get", "get_dsm_group", "getmember", "create", "edit", "editmember", "delete"]
}
},
"SYNO.PhotoStation.Rotate": {
"path": "rotate.php",
"minVersion": 1,
"maxVersion": 1,
"methods": {
"1": ["set"]
}
},
"SYNO.PhotoStation.SlideshowMusic": {
"path": "slideshow_music.php",
"minVersion": 1,
"maxVersion": 1,
"methods": {
"1": ["list", "get", "add", "edit", "delete"]
}
},
"SYNO.PhotoStation.DsmShare": {
"path": "dsm_share.php",
"minVersion": 1,
"maxVersion": 1,
"methods": {
"1": ["list", "copy", "copymusic"]
}
},
"SYNO.PhotoStation.SharedAlbum": {
"path": "shared_album.php",
"minVersion": 1,
"maxVersion": 1,
"methods": {
"1": ["list", "getinfo", "getinfo_public", "create", "edit", "delete", "add_items", "remove_items", "edit_public_share", "get_single_item", "set_single_item"]
}
},
"SYNO.PhotoStation.PhotoLog": {
"path": "log.php",
"minVersion": 1,
"maxVersion": 1,
"methods": {
"1": ["list", "clear", "export"]
}
},
"SYNO.PhotoStation.Path": {
"path": "path.php",
"minVersion": 1,
"maxVersion": 1,
"methods": {
"1": ["getpath", "checkpath"]
}
},
"SYNO.PhotoStation.Watermark": {
"path": "watermark.php",
"minVersion": 1,
"maxVersion": 1,
"methods": {
"1": ["getshare", "listshare", "upload", "copy", "delete", "remove"]
}
},
"SYNO.PhotoStation.Public": {
"path": "public.php",
"minVersion": 1,
"maxVersion": 1,
"methods": {
"1": ["list"]
}
},
"SYNO.PhotoStation.Migration": {
"path": "migration.php",
"minVersion": 1,
"maxVersion": 1,
"methods": {
"1": ["export_blog"]
}
},
"SYNO.PhotoStation.ACL": {
"path": "acl.php",
"minVersion": 1,
"maxVersion": 1,
"methods": {
"1": ["get", "set"]
}
}
}
2雀瓢、開源Python 項目(一個芬蘭人寫的)
https://github.com/skarppi/python-photostation
https://pypi.org/project/photostation/
用法也很簡單,不過作者實(shí)現(xiàn)的功能也不多玉掸,主要就是對照片的元數(shù)據(jù)進(jìn)行修改之類刃麸。
具體就不多說了,大家可以上github上下代碼看看
3司浪、API 可以用來做什么
- 給照片或者視頻批量打標(biāo)簽泊业、評分、修改日期等等
- 批量上傳圖片和視頻
- 其他還可以做什么啊易,需要開下腦洞