📜 ⬆️ ⬇️

Notification of downloaded torrents via SMS

image One evening, waiting for the download of your favorite LOST and Breaking Bad, I wanted to stroll through the warm evening Minsk towards Gorky Park. But here's an ill luck, the approximate download time of the torrent jumps up and down, an objective forecast obviously will not work.
Here, I came up with, in my opinion, a good idea - why not make a notification about the downloaded torrent via SMS? Then you can never bother with anxious waiting and do your own thing. :)

That's what came out of it...

image
')
Since I use the uTorrent torrent client, I have at my disposal a Web API through which you can receive information and manage all client parameters. It is important to check Use Web interface and second checkbox to allow guest access.


The Web API issues everything in json format, so there was almost no problem with parsing the dictionary. I was interested in torrents, which, of course, have not yet downloaded. From all that is transmitted - we take the remaining time or the percentage of completion (as you like), we check it periodically, quite simply:

ss := TStringStream.Create( '' );
idhttp1. get ( 'http://localhost:' + port + '/gui/token.html' , ss);
token := ss.DataString;
token := copy(token, pos( ';' '>' , token) + 3, length(token));
token := copy(token, 1, pos( '<' , token) - 1);
url := 'http://localhost:' + port + '/gui/?token=' + token +
'&list=1' ;
idhttp1.Get(url, ss);


* This source code was highlighted with Source Code Highlighter .


Next parsim that produces a torrent:
"torrents": [
[
(),
STATUS* ( ),
(),
( ),
( ),
( ),
( ),
... , , .


What in reality looks like:
{"build":19648,"label": ['#$A']'#$A',"torrents": ['#$A#$A'["08FAC4E006CBEB094D637849EC89023778BE7B55",201,"Patch",19257463,0,0,0,0,0,0,-1,"",0,11,0,0,0,1,19257463]]'#$A',"torrentc": "1014060939"}'#$A

Okay, the list of torrents received, we must now still send SMS. I took for this the ready-made library of AvisoSMS, by the way, quite simply it turned out to be screwed, I did not expect it. DLL reference

login := Edit1.Text;
pass := Edit2.Text;
sAdress := Edit3.Text;
dAdress := Edit4.Text;
if (dAdress = '' ) then
dAdress := 'AvisoSMS' ;
SendMessage(Pchar(login), PChar(pass), PChar(dAdress), PChar(sAdress), PChar( ' ' + torName + ' ' ));


* This source code was highlighted with Source Code Highlighter .


We test on something lightweight ...


Cheers cheers.

image Later I decided to finalize the program so that it could hide in the tray, have a decent GUI, work on tracking not only one torrent. Led in a separate thread check. True, I could not defeat the cracking of the Cyrillic download titles. Apparently affects the WebUI of the torrent client.

Resulting: I was surprised by the cunning system of markers for security, but I must say, in the case. Authorization is standard ... 401, so there were no problems either with the torrent API or with sms. Written in CodeGear Rad Studio 2007. The interface, of course, is not so hot, but for the first time it will come down. Ready to develop the program together with everyone, the source code and the working version below.

Sources: Download from Yandex.Disk
Working version in XP / Vista / 7: Download from Yandex.Disk


PS I would be grateful for the invite to the author of the article and this program - Oleg Tanasyuk. Written specifically for Habr.

Source: https://habr.com/ru/post/95149/


All Articles