At dinner, it is interesting to see something explosive, patronal, or from a late one.
And it’s completely unpleasant when the table is set, and you start frantically checking on all the distributions “whether something new has appeared.”
And at best, the inscription in uTorrent - “5-10-15 minutes left” will continue. And the table gets cold.
So things are not done.
Task:
- automatic download of only new series / releases of torrent distributions with rutracker and rutor
- notification of new downloads
- do only Windows and third-party console programs
Decision:
Creating a file list of distributions with the numbers of the last downloaded series (get.txt).
')
Run the bat-script (get.bat), which for each distribution:
- downloads a torrent file
- checks "is there anything new?"
- downloads only the new (and not the entire distribution),
- updates the number of the last series in the settings file (get.txt),
- creates an entry in the download log (log.txt),
- copies the shortcut to the “download log” in the “panel at the start”
Result:
If a new series is loaded, a shortcut to the download log will be copied to the Links panel (the icon in the picture is a yellow star).
If after viewing the entire "star" delete with your hands, then the sign will work:
"There is an asterisk - there is a new movie, there is no asterisk - there is no new one".


Installation:
- Create a program folder (for example, d: \ AutoTorrent) #
- Download console utility to download curl torrent files #
- Download a console utility for working with torrent-files aria2c #
- Download bat-script for checking new episodes ( get.bat ) #
- Adjust the settings of the bat-script (login-password at rutracker.org)
- Create a file-list of monitored hands (get.txt) #
- Create log file (log.txt) #
- Create a label for the magazine (New series.lnk) #
- Schedule periodic script execution #
More details:
1. Program folder
Since, in addition to the bat-script, other files and folders are created and used, it is convenient to localize all this in a separate place.
2. curl utility
Used to download torrent files.
To download a torrent file with rutracker, add the
bb_dl=%torrent_id%
parameter to cookies.
Aria2 can also upload files, but rutracker didn’t make friends with cookies.
3. Utility aria2c
Able to download individual files from the distribution.
Due to the torrent features, when downloading a separate file, adjacent files are partially downloaded, so the appearance of pieces of adjacent files may appear in the distribution folder.
It also turned out that the files in the hands can go out of order. Therefore, to identify new files, sorting by file name is used.
An example of an unordered distribution.*** BitTorrent File Information ***
Comment:
rutracker.org/forum/viewtopic.php?t=4400218Files:
idx | path / length
=== + ============================================== =============================
1 | ./ Game of Thrones Season 3 (LostFilm) /Game.of.Thrones.s03e10.avi
| 609MiB (638,871,552)
--- + ---------------------------------------------- -----------------------------
2 | ./ Game of Thrones Season 3 (LostFilm) /Game.of.Thrones.s03e07.avi
606MiB (635,699,200)
--- + ---------------------------------------------- -----------------------------
3 | ./ Game of Thrones Season 3 (LostFilm) /Game.of.Thrones.s03e08.avi
| 604MiB (634,238,976)
--- + ---------------------------------------------- -----------------------------
4 | ./ Game of Thrones Season 3 (LostFilm) /Game.of.Thrones.s03e02.avi
| 602MiB (631,814,144)
--- + ---------------------------------------------- -----------------------------
5 | ./ Game of Thrones Season 3 (LostFilm) /Game.of.Thrones.s03e04.avi
| 602MiB (631,265,280)
--- + ---------------------------------------------- -----------------------------
6 | ./ Game of Thrones Season 3 (LostFilm) /Game.of.Thrones.s03e06.avi
| 601MiB (631.037.952)
--- + ---------------------------------------------- -----------------------------
7 | ./ Game of Thrones Season 3 (LostFilm) /Game.of.Thrones.s03e03.avi
| 601MiB (630,517,760)
--- + ---------------------------------------------- -----------------------------
8 | ./ Game of Thrones Season 3 (LostFilm) /Game.of.Thrones.s03e05.avi
| 601MiB (630,310,912)
--- + ---------------------------------------------- -----------------------------
9 | ./ Game of Thrones Season 3 (LostFilm) /Game.of.Thrones.s03e01.avi
| 598MiB (627,965,952)
--- + ---------------------------------------------- -----------------------------
10 | ./ Game of Thrones Season 3 (LostFilm) /Game.of.Thrones.s03e09.avi
557MiB (584,220,672)
--- + ---------------------------------------------- -----------------------------
>>> Printing the contents of the file 'rutracker_4400218.torrent' ...
4. bat script get.bat
Written on the bat of sports interest.
There were difficulties in working with Cyrillic — with editing a file in Notepad, displaying it on the screen, and writing it to a log file. Therefore, multiple feints with
chcp
.
Due to the complexity of using local variables, many
call - exit /b
subroutines have appeared.
In the help
if /?
the comparison operator
EQL
is issued, although
bat
swears at it and perceives
EQU
. // Microsoft Windows [Version 6.1.7601]
5. Settings bat-script get.bat
In the text of the script there is a group of parameters for which you need to set actual values:
- workdir = _workdir - A working folder for saving temporary files and downloaded torrent files is created automatically when you run the bat-script.
- rutracker_login = login - login on the tracker rutracker.org .
- rutracker_password = password - Password on the tracker rutracker.org .
- video_dir = d: \ video - Folder where to save downloadable distribution files (when loading distribution folder structure is recreated as usual).
- lnk_name = "New series.lnk" - Label on the log file downloads log.txt.
- lnk_dest = “C: \ Users \ Admin \ Favorites \ Links” - Path where the shortcut is copied when downloading a new file. In this example, this is the path to my toolbar near the Start button.
6. File-list of monitored hands (get.txt)
Line format:
- tracker code - rutor or rutracker
- distribution code - number from the distribution link (eg rutracker.org/forum/viewtopic.php?t=3192884 )
- the number of the last downloaded series - the counter will increase as new series are downloaded
- comment - any text for clear list
An example of the get.txt file:
rutor 227513 24 " " ( 6) rutracker 3799523 19 rutracker 4400218 10
7. Download log (log.txt)
It contains information about the downloaded new files. New entries are added on top.
When you click on the "asterisk", this journal opens in a notebook.
Sample content05/21/2013 21: 16: 57.50: [rutracker 3799523 13 Posner] ./Pozner-2_[rutracker.org[/P2-141_Maksim_Kantor.avi
05/21/2013 20: 07: 44.66: [rutor 227513 24 “The Big Bang Theory” (Season 6)] ./The.Big.Bang.Theory.S06.1080p.WEB-DL.Rus.Eng.HDCLUB/The.Big .Bang.Theory.S06E24.1080p.WEB-DL.Rus.Eng.HDCLUB.mkv
05/21/2013 19: 03: 35.11: [rutracker 86939 46 ### for the ### test] ./ Brother -1, Brother-2/2001 - Brother 1/13 - Nautilus Pompilius - People on the hill (demo) .mp3
05/20/2013 19: 03: 35.08: [rutracker 86939 45 ### for the ### test] ./ Brother -1, Brother-2/2001 - Brother 1/12 - Nautilus Pompilius - Beast.mp3
8. Magazine shortcut (.lnk)
To notify about downloading a new one, copy the shortcut to a prominent place - “Desktop”, the “Links” panel. The shortcut itself must be created in the folder of the bat-script. If the log file does not already exist, then you need to create it.
9. Scheduling a job
For periodic execution of the bat-script, you need to create a task in the task scheduler (Control Panel \ All Control Panel Items \ Administration \ Task Scheduler).
From the unusual - the full path to the script is indicated in quotes, and the working folder without. Although there are gaps in the way.
Each time the script is executed, a cmd window opens.
If Cyrillic is not readable - for the cmd window you need to select the font Lucida in the properties.
If you want to run without cmd-window, you can call
get.vbs .
Total
Everything works without intervention for more than a month.
To sit, simply open the downloaded torrent file in uTorrent.
References:
habrahabr.ru/sandbox/51123ubuntu.opentomsk.net/discussion/viewtopic.php?id=3220Files:
get.bat @echo off rem rem 13.05.2013 Tucker56 http://habrahabr.ru/post/180173/ rem rem / torrent- rem rem : rem - - get.txt ( ) rem - log.txt rem - ( .lnk) log.txt rem - ( ) rem - rem rem ( ): rem - (%video_dir%) rem - rem rem : rem - Є«« , Lucida @SetLocal EnableDelayedExpansion rem CMD, cp1251, for /f "tokens=2 delims=:" %%a in ('chcp') do set /a chcp_cmd=%%a rem chcp 1251 >nul rem , (chcp) for /f "tokens=2 delims=:" %%a in ('chcp') do set /a chcp=%%a rem -------------------------------------------------------------- rem - --------------------------------------- rem workdir=_workdir - , torrent- rem rutracker_login=login - http://rutracker.org rem rutracker_password=password - http://rutracker.org rem video_dir=d:\video - ( torrent-) rem lnk_name=" .lnk" - log.txt rem lnk_dest="C:\Users\Admin\Favorites\" - set workdir=_workdir set rutracker_login=login set rutracker_password=password set video_dir=d:\Video set lnk_name=" .lnk" set lnk_dest="C:\Users\Admin\Favorites\" rem - ------------------------------------------ rem get.txt - c torrent- rem ----- rem : rem _{rutracker, rutor} _{ URL} ___{ } rem ----- rem get.txt: rem rutracker 86939 46 rem rutracker 4400218 7 rem rutor 227513 22 rem -------------------------------------------------------------- rem -------------------------------------------------------------- rem , mkdir !workdir! >nul 2>nul rem RuTracker, cookie- torrent- curl -s -c "%workdir%\cookie_rutracker.txt" -A "Opera/10.00 (Windows NT 5.1; U; ru)" ^ -d "login_username=!rutracker_login!&login_password=!rutracker_password!&login=%C2%F5%EE%E4" ^ "http://login.rutracker.org/forum/login.php" > nul del /q !workdir!\~get.txt.new.tmp 2>nul rem get.txt for /F "tokens=1,2,3*" %%i in (get.txt) do ( set tracker_id=%%i set torrent_id=%%j set last_file_id=%%k set torrent_comment=%%l set torrent_file=!tracker_id!_!torrent_id!.torrent set err= rem torrent- RuTracker RuTor echo !tracker_id! !torrent_id! !last_file_id!: '!torrent_file!' if "%%i" == "rutracker" ( curl -s -A "Opera/10.00 (Windows NT 5.1; U; ru)" ^ -b "%workdir%\cookie_rutracker.txt" ^ -b "bb_dl=!torrent_id!" ^ "http://dl.rutracker.org/forum/dl.php?t=!torrent_id!" -o "!workdir!\!torrent_file!" ) else ( if "%%i" == "rutor" ( curl -s -A "Opera/10.00 (Windows NT 5.1; U; ru)" ^ "http://d.rutor.org/download/!torrent_id!" -o "!workdir!\!torrent_file!" ) else ( set err=X echo !tracker_id! !torrent_id! !last_file_id!: : '!tracker_id!' ) ) if !err! NEQ X ( rem torrent- call, for in --show-files !workdir!\!torrent_file! call :process !torrent_file! ) rem ( get.txt) echo !tracker_id! !torrent_id! !last_file_id! !torrent_comment!>> !workdir!\~get.txt.new.tmp echo. ) rem (get.txt) move /y !workdir!\~get.txt.new.tmp get.txt >nul 2>nul rem aria2c del /Q !video_dir!\*.aria2 >nul 2>nul rem "" - if /? EQL WTF?! if "!has_new!" EQU "X" copy /Y %lnk_name% %lnk_dest% >nul rem CMD chcp !chcp_cmd! >nul rem , rem pause exit /b rem torrent- - , rem %1 - torrent- = !torrent_file!, %1 for in :process echo !tracker_id! !torrent_id! !last_file_id!: '!torrent_file!' rem [ ] CMD /U chcp 866 find /c "+" for /f "tokens=1" %%a in ('aria2c.exe --show-files %workdir%^\%1 ^| findstr /R "^---+----*" ^| find /c "+"') do set cnt=%%a rem , if !last_file_id! LSS !cnt! ( rem torrent- (http://rutracker.org/forum/viewtopic.php?t=4400218), rem del /q !workdir!\~sort.tmp 2>nul for /f "tokens=1,2 delims=|" %%x in ('aria2c.exe --show-files %workdir%^\%1 ^| findstr /BRC:"^[ ]*[0-9][0-9]*"') do echo %%y ^| %%x >> !workdir!\~sort.tmp set /a skip=last_file_id rem . call, skip=%skip% call :download_new_files ) else ( echo !tracker_id! !torrent_id! !last_file_id!: ) exit /b rem :download_new_files rem 1-3) UTF-8, chcp 65001 > nul rem - for /f "skip=%skip% tokens=1,2 delims=|" %%o in ('sort %workdir%^\~sort.tmp') do ( rem 2-3) 65001 chcp !chcp! >nul set /a down=%%p rem call rem 1) echo , , , rem 2) %time% call :down_file %%o ) rem 3-3) 65001 chcp !chcp! >nul rem del /q !workdir!\~sort.tmp 2>nul exit /b rem rem %* = :down_file set /a last_file_id=last_file_id+1 echo !tracker_id! !torrent_id! !last_file_id!: '%*' aria2c --dir=!video_dir! ^ --seed-time=0 ^ --file-allocation=none ^ --summary-interval=0 ^ --console-log-level=error ^ --max-overall-download-limit=1M ^ --allow-overwrite=true ^ --select-file=!down! ^ !workdir!\!torrent_file! rem - : rem --quiet=true ^ rem , rem --allow-overwrite=true ^ rem , torrent-, rem torrent- rem , rem log.txt - rem %time% for, , call copy log.txt !workdir!\~log.txt.tmp >nul 2>nul echo %date% %time%: [!tracker_id! !torrent_id! !last_file_id! !torrent_comment!] %* >log.txt type !workdir!\~log.txt.tmp >>log.txt 2>nul del /q !workdir!\~log.txt.tmp >nul 2>nul rem set has_new=X exit /b
get.vbs Dim oShell Set oShell = WScript.CreateObject ("WSCript.shell") oShell.run "get.bat", 0 Set oShell = Nothing