feat: support qbittorrent (close #3087 in #3333)

* feat(qbittorrent): authorization and logging in support

* feat(qbittorrent/client): support `AddFromLink`

* refactor(qbittorrent/client): check authorization when getting a new client

* feat(qbittorrent/client): support `GetInfo`

* test(qbittorrent/client): update test cases

* feat(qbittorrent): init qbittorrent client on bootstrap

* feat(qbittorrent): support setting webui url via gin

* feat(qbittorrent/client): support deleting

* feat(qbittorrent/client): parse `TorrentStatus` enum when unmarshalling json in `GetInfo()`

* feat(qbittorrent/client): support getting files by id

* feat(qbittorrent): support adding qbittorrent tasks via gin

* refactor(qbittorrent/client): return a `Client` interface in `New()` instead of `*client`

* refactor: task handle

* chore: fix typo

* chore: change path

---------

Co-authored-by: Andy Hsu <i@nn.ci>
This commit is contained in:
kdxcxs
2023-02-14 15:20:45 +08:00
committed by GitHub
parent 46b2ed2507
commit c28168c970
14 changed files with 930 additions and 237 deletions

View File

@ -89,28 +89,10 @@ func admin(g *gin.RouterGroup) {
setting.POST("/delete", handles.DeleteSetting)
setting.POST("/reset_token", handles.ResetToken)
setting.POST("/set_aria2", handles.SetAria2)
setting.POST("/set_qbittorrent", handles.SetQbittorrent)
task := g.Group("/task")
task.GET("/down/undone", handles.UndoneDownTask)
task.GET("/down/done", handles.DoneDownTask)
task.POST("/down/cancel", handles.CancelDownTask)
task.POST("/down/delete", handles.DeleteDownTask)
task.POST("/down/clear_done", handles.ClearDoneDownTasks)
task.GET("/transfer/undone", handles.UndoneTransferTask)
task.GET("/transfer/done", handles.DoneTransferTask)
task.POST("/transfer/cancel", handles.CancelTransferTask)
task.POST("/transfer/delete", handles.DeleteTransferTask)
task.POST("/transfer/clear_done", handles.ClearDoneTransferTasks)
task.GET("/upload/undone", handles.UndoneUploadTask)
task.GET("/upload/done", handles.DoneUploadTask)
task.POST("/upload/cancel", handles.CancelUploadTask)
task.POST("/upload/delete", handles.DeleteUploadTask)
task.POST("/upload/clear_done", handles.ClearDoneUploadTasks)
task.GET("/copy/undone", handles.UndoneCopyTask)
task.GET("/copy/done", handles.DoneCopyTask)
task.POST("/copy/cancel", handles.CancelCopyTask)
task.POST("/copy/delete", handles.DeleteCopyTask)
task.POST("/copy/clear_done", handles.ClearDoneCopyTasks)
handles.SetupTaskRoute(task)
ms := g.Group("/message")
ms.POST("/get", message.HttpInstance.GetHandle)
@ -139,6 +121,7 @@ func _fs(g *gin.RouterGroup) {
g.PUT("/form", middlewares.FsUp, handles.FsForm)
g.POST("/link", middlewares.AuthAdmin, handles.Link)
g.POST("/add_aria2", handles.AddAria2)
g.POST("/add_qbit", handles.AddQbittorrent)
}
func Cors(r *gin.Engine) {