diff --git a/internal/api/qbit.go b/internal/api/qbit.go index 3a5f8fc..19ab21b 100644 --- a/internal/api/qbit.go +++ b/internal/api/qbit.go @@ -1,6 +1,7 @@ package api import ( + "mime" "net/http" "net/url" "os" @@ -113,9 +114,18 @@ func (s *Server) handleQBitTransferInfo(w http.ResponseWriter, r *http.Request) } func (s *Server) handleQBitAdd(w http.ResponseWriter, r *http.Request) { - if err := r.ParseMultipartForm(8 << 20); err != nil { // 8 MB; torrent files are typically < 1 MB - http.Error(w, err.Error(), http.StatusBadRequest) - return + contentType := r.Header.Get("Content-Type") + mediaType, _, _ := mime.ParseMediaType(contentType) + if mediaType == "multipart/form-data" { + if err := r.ParseMultipartForm(8 << 20); err != nil { // 8 MB; torrent files are typically < 1 MB + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + } else { + if err := r.ParseForm(); err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } } category := strings.TrimSpace(r.PostFormValue("category")) diff --git a/internal/compat/qbit.go b/internal/compat/qbit.go index c544b08..397dc7e 100644 --- a/internal/compat/qbit.go +++ b/internal/compat/qbit.go @@ -50,6 +50,8 @@ type QBitTorrentInfo struct { Priority int `json:"priority"` Progress float64 `json:"progress"` Ratio float64 `json:"ratio"` + RatioLimit float64 `json:"ratio_limit"` + SeedingTime int64 `json:"seeding_time"` SavePath string `json:"save_path"` Size int64 `json:"size"` State string `json:"state"` @@ -120,6 +122,8 @@ func ProjectQBitTorrent(job *store.Job) QBitTorrentInfo { Priority: 0, Progress: progress, Ratio: 0, + RatioLimit: 0, + SeedingTime: 0, SavePath: savePath, Size: max(total, done), State: state,