Dropbox + AutoIt + utorrent

Good afternoon. I read about different bundles of Dropbox and utorrent, but not one of them suited me. Based on the experience of downloads earlier, there was only one thing, if you did not immediately indicate the place where to save and the desired file name, then it will remain in the “Unassembled” folder with the name “Avatar.2009.Extended.Collectors.Cut (1080p) .mkv ". Even if you then parse the downloaded, you will need to restart the torrent files and indicate a new path to the file in order to distribute them. And if you consider that in addition to me, parents and niece watch films at home, then this name could not be left.

So the necessary requirements for the program:


1. adding torrents remotely without connecting to a home computer (DK);
2. the ability to specify the path to the file on the recreation center;
3. the ability to specify the name of the downloaded file;
4. remotely track which files were downloaded, which completed the download.

How to solve the task


First point

We turn to the help utorrent.exe it turns out to add a torrent, you must run the following command:

C:\Program Files\uTorrent>uTorrent.exe /DIRECTORY "Директория куда сохранять" "Путь до торрент файла"

From the same help and search in google, as well as the forum utorrent it turned out that you can not specify the name of the downloaded file in the uTorrent command line. At first, I executed the command, but with further implementation of the program I had to remove it from the line /DIRECTORY "Директория куда сохранять", I will talk about this below.

Second point

It is necessary that the Dropbox folder has the same folder structure as on the home computer where the downloaded file is saved. Next, saving the torrent file to the desired directory of the Dropbox folder, we can add the torrent to the DC to the directory that we need. To do this, it was necessary to ensure automatic synchronization of the folder structure with the recreation center and the folder in DropBox. How exactly the search for torrent files and folder structure synchronization is implemented, I will not disassemble, because there is nothing special there.

After synchronization, the Dropbox folder looked like this:

image

Third point

There are problems with the file name. The name of the torrent file and the names of the files that are downloaded through this torrent are two different things. At the uTorrent command line when adding, it was also impossible to specify with what name to save the file. Again I began to search for information. It turned out that you can’t change the torrent file, because then it becomes “disabled” and cannot be added to the download. And here AutoIT comes to the rescue with its ability to access the form element of another program. Before that, I remove / DIRECTORY "Directory where to save" from the uTorrent command line so that a window appears about adding a torrent. Next, it was necessary to find out what the form element is called, where the path to save the file is indicated. Included with AutoIT is a program called AutoIT Window Info, thanks to which you can find out what form elements are called:

image

The field we need is called “ComboBox1”, so if you turn to it, you need to know the name of the window (Title) in which the element is located. In our case, the window name is as follows:

"Avatar.2009.Extended.Collectors.Cut (1080p) .mkv - Add a new torrent"

Since the name of the torrent file and the name with which it is added by default in the torrent client are two different things. And I just needed a name with which it is added by default. It was necessary to somehow pull it out of the torrent file. From the information received it followed that the torrent file was encoded in Bencode format, I did not find a library written for AutoIT, so I later parse it with a simple read. I needed the value of the name field. In our example, a piece of the file with the value I needed looked like this:

"Name46: Avatar.2009.Extended.Collectors.Cut (1080p) .mkv12: piece"

What is 12: piece and why it was found in all the files that I looked at the home computer, I did not understand. But since it was equally calmly called "Avatar.2009.Extended.Collectors.Cut (1080p) .mkv". Now we can get the name of the window in which the “ComboBox1” element is located. I take the file name from the name of the torrent, i.e. when saving a torrent file indicated the name "Avatar.torrent". Indication of the field value for the form in AutoIT is done as follows:

ControlSetText($Title, "", "ComboBox1", $NameTorrent)

We also send the command Left-click on the OK button.

ControlClick ($Title, "", "Button7")

Voila torrent was added with the name I need to the directory I need on the home computer.
It is also better in uTorrent Settings -> Interface to uncheck “Activate program window” so that the torrent is not added to the person who worked on the DC.

Fourth point

Everything is simple with him. We write to the log that is in the Dropbox folder about adding a torrent. In order to write about the completion of the download of a torrent, you need to do the following. Go to utorrent settings → Advanced → Run this program at the end of the torrent indicated its program with the parameters TorrentBot.exe% F -onlylog.

System in operation

The program (TorrentBot.exe) is running on the home computer. And let's say at work, I save the torrent to the folder “Dropbox \ DWND \ 1_Movies \ Cowboys vs. Aliens.torrent” the file is copied to the home computer using Dropbox tools, then the torrent is added to the download and deleted from Dropbox.

Source code

The source code of the program is attached, I ask you not to judge the submitted code strictly.
For those who want to run the program. The first time you run the exe file, config.ini is created in the same folder as the program. It is necessary to indicate the following in it: Where PathDWND is the path on the home computer where you want to save all the downloads; PathDropBox - the path in the Dropbox folder in which the folder structure from the PathDWND path will be located; TimeUpdate - time to check the appearance of new torrent files in the PathDropBox folder (in seconds) Mandatory requirement do not confuse PathDWND and PathDropBox in some places; otherwise, only the structure from PathDropBox will be in the PathDWND folder, and all files that were previously in PathDWND will disappear .
[options]
PathDWND=G:\DWND\
PathDropBox=G:\Dropbox\DWND\
TimeUpdate=30





Oh yes, use at your own risk.

Thanks for attention.

Used literature: utorrent help, AutoIt help, Google search.

TorrentBot.au3 .

Also popular now: