-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from ludviglundgren/feat/pause-torrents
Feat: pause and resume all torrents
- Loading branch information
Showing
4 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/ludviglundgren/qbittorrent-cli/internal/config" | ||
"github.com/ludviglundgren/qbittorrent-cli/pkg/qbittorrent" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// RunPause cmd to pause torrents | ||
func RunPause() *cobra.Command { | ||
var command = &cobra.Command{ | ||
Use: "pause", | ||
Short: "Pause all torrents", | ||
Long: `Pause all torrents`, | ||
} | ||
command.Run = func(cmd *cobra.Command, args []string) { | ||
qbtSettings := qbittorrent.Settings{ | ||
Hostname: config.Qbit.Host, | ||
Port: config.Qbit.Port, | ||
Username: config.Qbit.Login, | ||
Password: config.Qbit.Password, | ||
} | ||
qb := qbittorrent.NewClient(qbtSettings) | ||
|
||
err := qb.Login() | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "ERROR: connection failed: %v\n", err) | ||
os.Exit(1) | ||
} | ||
|
||
err = qb.Pause(nil) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "ERROR: could not pause torrents %v\n", err) | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
return command | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/ludviglundgren/qbittorrent-cli/internal/config" | ||
"github.com/ludviglundgren/qbittorrent-cli/pkg/qbittorrent" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// RunResume cmd to resume torrents | ||
func RunResume() *cobra.Command { | ||
var command = &cobra.Command{ | ||
Use: "resume", | ||
Short: "Resume all torrents", | ||
Long: `Resume all torrents`, | ||
} | ||
|
||
command.Run = func(cmd *cobra.Command, args []string) { | ||
qbtSettings := qbittorrent.Settings{ | ||
Hostname: config.Qbit.Host, | ||
Port: config.Qbit.Port, | ||
Username: config.Qbit.Login, | ||
Password: config.Qbit.Password, | ||
} | ||
qb := qbittorrent.NewClient(qbtSettings) | ||
|
||
err := qb.Login() | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "ERROR: connection failed: %v\n", err) | ||
os.Exit(1) | ||
} | ||
|
||
err = qb.Resume(nil) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "ERROR: could not resume torrents %v\n", err) | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
return command | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters