fedarovich / qbittorrent-cli

Command line interface for QBittorrent
MIT License
303 stars 16 forks source link

Windows | Trying to check if torrent hash has seeds #55

Closed C0nw0nk closed 2 years ago

C0nw0nk commented 2 years ago

So i have been trying to see if a torrent hash has active seeders >=1 in windows command line

The issue is trying to split the output up so i can grab the seeder value.

here is my code

@ECHO OFF & setLocal EnableDelayedExpansion
color 0A
%*

TITLE QBT-CLI

set username="admin"
set password="pass"
set webUI=http://localhost:8080
set torrent_hash=099e4a3240ba5aa0a42d3b40afa257b50cdc3b

SET root_path=%~dp0

For /f "delims=" %%a in ('
%root_path%qbitorrent-cli\qbt.exe torrent properties %torrent_hash% --username %username% --password %password% --url %webUI%
') do set torrent_=%%a
set "torrent_=!torrent_:: = ^:^:^: !"
set "torrent_=!torrent_:  =^~!"
set "torrent_=!torrent_: =!"
set "torrent_=!torrent_:^~^~^~=^~!"
set "torrent_=!torrent_:^~^~=^~!"
set "torrent_=!torrent_:^~^~=^~!"
set "torrent_=!torrent_:^~^~=^~!"
set "torrent_=!torrent_:^~^~=^~!"
set "torrent_=!torrent_:^~= !"
set "torrent_=!torrent_:^:^:^: =^: !"
echo %torrent_%

for /f "tokens=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46 delims=" %%a in ("%torrent_%") do echo Seeder value is %%b

pause

What i planned to do is delete the torrent if it has no seeders and also if the torrent last seen completed time was years ago or never then delete it in that circumstance too.

fedarovich commented 2 years ago

I guess it is easier to parse the result if the command returns CSV (use --format csv arguments) or JSON (--format json)