Add album/track releases with audio analysis, AnalyzeAlbumRelease RPC, Docker path auto-resolution, release parsing decision tree
This commit is contained in:
@@ -173,8 +173,8 @@ func filterLocally(torrents []TorrentInfo, opts FindOptions) []TorrentInfo {
|
||||
return result
|
||||
}
|
||||
|
||||
func (c *QbittorrentClient) AddTorrent(file TorrentFile) error {
|
||||
log.Trace().Str("filename", file.Filename).Int("size", len(file.Data)).Msg("qbittorrent adding torrent file")
|
||||
func (c *QbittorrentClient) AddTorrent(file TorrentFile, savePath string) error {
|
||||
log.Trace().Str("filename", file.Filename).Int("size", len(file.Data)).Str("save_path", savePath).Msg("qbittorrent adding torrent file")
|
||||
|
||||
var buf bytes.Buffer
|
||||
writer := multipart.NewWriter(&buf)
|
||||
@@ -190,6 +190,12 @@ func (c *QbittorrentClient) AddTorrent(file TorrentFile) error {
|
||||
return fmt.Errorf("writing torrent data: %w", err)
|
||||
}
|
||||
|
||||
if savePath != "" {
|
||||
if err := writer.WriteField("savepath", savePath); err != nil {
|
||||
return fmt.Errorf("writing savepath field: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := writer.Close(); err != nil {
|
||||
return fmt.Errorf("closing multipart writer: %w", err)
|
||||
}
|
||||
@@ -205,14 +211,17 @@ func (c *QbittorrentClient) AddTorrent(file TorrentFile) error {
|
||||
return c.doAdd(req, file.Filename)
|
||||
}
|
||||
|
||||
func (c *QbittorrentClient) AddMagnet(magnetURI string) error {
|
||||
func (c *QbittorrentClient) AddMagnet(magnetURI string, savePath string) error {
|
||||
truncated := magnetURI
|
||||
if len(truncated) > 80 {
|
||||
truncated = truncated[:80] + "..."
|
||||
}
|
||||
log.Trace().Str("magnet", truncated).Msg("qbittorrent adding magnet")
|
||||
log.Trace().Str("magnet", truncated).Str("save_path", savePath).Msg("qbittorrent adding magnet")
|
||||
|
||||
data := url.Values{"urls": {magnetURI}}
|
||||
if savePath != "" {
|
||||
data.Set("savepath", savePath)
|
||||
}
|
||||
req, err := http.NewRequest("POST", c.baseURL+"/api/v2/torrents/add", strings.NewReader(data.Encode()))
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("qbittorrent creating magnet add request failed")
|
||||
@@ -303,3 +312,28 @@ func (t *QbittorrentListItem) toTorrentInfo() TorrentInfo {
|
||||
Availability: t.Availability,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *QbittorrentClient) DefaultSavePath() (string, error) {
|
||||
req, err := http.NewRequest("GET", c.baseURL+"/api/v2/app/defaultSavePath", nil)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("creating request: %w", err)
|
||||
}
|
||||
req.AddCookie(&http.Cookie{Name: "SID", Value: c.sid})
|
||||
|
||||
resp, err := c.client.Do(req)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("requesting default save path: %w", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return "", fmt.Errorf("default save path returned status %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("reading response: %w", err)
|
||||
}
|
||||
|
||||
return strings.TrimSpace(string(body)), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user