Page 4 of 6
Re: Need setup help to auto-extract torrent files
Posted: Sat May 28, 2016 7:07 pm
by Galana
I haven't come across one yet in my testing - I usually get those from one of my different sites that hasn't posted one of the titles I'm looking for.
And the problem with the N vs NX, is most torrents are named something along the lines of:
show
.season0episode0
.resolution
.encoding
.crackteam
with the %~n selection, you get this result:
show.season0episode0.resolution.encoding
since it truncates the extension (even if it isn't a real extension). Therefore you need the %~nx parameter in order to contain the entire directory name. It's an odd (likely) torrent-specific condition, only because periods are used as space indicators. If they were commas or underscores, you would be absolutely correct.
And it's confirmed - the script won't launch until the Completion Move has been completed. Just downloaded a 4Gb file, and had to wait ~30 seconds for the script to launch. <sad>

Re: Need setup help to auto-extract torrent files
Posted: Sat May 28, 2016 7:12 pm
by tekko
w:\a.b vs w:\a.b\
%~n would be a
The example is of file, so it's not wrong.
Dunno if it's slower or faster. Copy back to ramdisk to do the extraction.

Re: Need setup help to auto-extract torrent files
Posted: Sat May 28, 2016 8:28 pm
by Galana
Right. However, in the w:\a.b example, b is a file extension... In w:\a.b\, b is part of the file path. Therefore striking out the .b from a file path would cause the path to no longer be accurate. Remember that the core data being pulled is from %F, which is a path, not an individual file.
Re: Need setup help to auto-extract torrent files
Posted: Sat May 28, 2016 8:34 pm
by tekko
I'm just saying that the handling is different. I'm not saying u're doing it wrong.
If I recall correctly %F is a file path, not a folder path, for a single file torrent.
u might need a whole different part of code for that.
Re: Need setup help to auto-extract torrent files
Posted: Sat May 28, 2016 8:57 pm
by Galana
And that's why I kept the nx coding in on the single file - since it will have to include the extension. Hypothetically, I'll be right
What I would love to see in a near-future version of the software is an option to run the script before or after the completion move. Shouldn't be s difficult coding, should it? Just setting an order of operations based on a 0/1 parameter?
Re: Need setup help to auto-extract torrent files
Posted: Sat May 28, 2016 9:22 pm
by tekko
This one goes to github as a wishlist, I guess...
Re: Need setup help to auto-extract torrent files
Posted: Sun May 29, 2016 9:33 pm
by KitKat
[quote="Galana"]
Shouldn't be s difficult coding, should it? Just setting an order of operations based on a 0/1 parameter?
[/quote]
Pretty much yeah.
I dont know whether this will actually be implemented however as it seems to be a very very user specific request and would (most likely) require the addition of an extra config line to qbittorent.ini/conf and another option under either advanced or a checkbox somewhere else.
(GUI changes are the time consumer here, not the actual logic)
May i suggest in the meantime modifying your .bat/exe script so it also performs the move operation?
maybe do operations like so extract > play > move.
Extract happens instantly, playing the extracted file happens immediately after (no conflicts) and then it takes its time to move the source file to the NAS for seeding.
Would all seem instantaneous to the user.
Im retarded, this would break seeding.
By the way you can directly call a .bat file with qbittorents commandline like so cmd.exe /c C:\Path\to\batch\file.bat args
May make testing/modifying alot easier for you.
And lastly in the longterm having a functional script + method to call it that does EVERYTHING you want it to do while only requiring the client itself to allow it to run a script on completion would also increase your choices for torrent clients in the event you want to checkout a new client.
Re: Need setup help to auto-extract torrent files
Posted: Mon May 30, 2016 4:05 pm
by Galana
This is an interesting idea. When the torrent gets picked up by the NAS, its internal Transmission software picks up the seeding. So actually, the move gets a lot more viable, since I'm not counting on QT to continue the long-term seeding.
As for the viability of the work, if it's an easy fix, then hopefully it can be picked up just to clear a wishlist item. And as mentioned by the follow-up poster, that anyone looking to do secondary seeding is going to have issues with this order of operations.
Re: Need setup help to auto-extract torrent files
Posted: Mon May 30, 2016 4:22 pm
by tekko
I don't think it's just a switch. There are many other stuff to consider.
There has to be addtional code to check if the script has modfied/ deleted the data. If the torrent becomes incompleted after the script has been executed. What to do next...
qbt gives error since it can't be seeded? move what is not deleted/ modified back to the temp. location and download all over again?
It's much more complicated.
Re: Need setup help to auto-extract torrent files
Posted: Mon May 30, 2016 5:14 pm
by Galana
Definitely not wrong - but then you're catering to the lowest common denominator. One would think that if someone knows how to build a script, they would understand about file-management after-the-fact. And it's easy enough to solve - after the script executes, have it do an Auto-Check (which should be done on a complete torrent anyway, (and I believe is done after a completion move?). If it passes, then seed as always. If it fails, then it's put into Pause mode for the user to resolve.
Re: Need setup help to auto-extract torrent files
Posted: Mon May 30, 2016 5:47 pm
by tekko
I always try to think of the worst case scenario, to prevent my computer to catch on fire.

Re: Need setup help to auto-extract torrent files
Posted: Mon May 30, 2016 11:06 pm
by Galana
I'm probably going to try getting rid of QBT handing the completion moving completely - it's just causing more issues than it solves w/r/t the folder issues in the auto-loading-torrents, and the whole scripting thing (meaning I can put r:\ back as an auto-load location). I can do everything that Completion Moving does built into the script, and since I use a different torrent client on the NAS anyway, putting the .torrent file in the auto-start folder via completion move or by script is ultimately irrelevant. I'll play with this later tonight/tomorrow.
Re: Need setup help to auto-extract torrent files
Posted: Tue May 31, 2016 10:22 am
by Galana
Well, it took over 4 hours (and thank f__k for that link to run the BAT directly instead of always converting it!)... Including the time tweaking & testing as I typed out everything below... And we have ~98% success overall - I've put the line-by-line comments in-line, with the full BAT file as an attachment if anyone wants to pull it off (editing as required):
Save Files & Save Incomplete Files -
R:\TorTemp*
Watch Folder -
R:\
Copy .torrent for completed -
R:\TorTemp
Run External Program -
cmd.exe /c "I:\qBittorrent\script.bat" "%F"
*Note: In setting the Auto-Load / Watched Folder to R:\ (which is my Temp & default Web-download folder), the file Completion Moves to R:\ from R:\TorTemp. It's just what QBT does, and there's never been a logical reason why aside from the fact it's a RAMdrive possibly causing it - so the below script accommodates that oddity. And the reverse is true, the .torrent file MUST be completion-moved outside the R:\ (or else it doesn't re-generate), so I dumped that into TorTemp.
:Part1 (Transfer Cycle)
if exist "R:\%~nx1\*.r*" ("R:\TorTemp\WinRAR\WinRAR.exe" x -ibck -inul "R:\%~nx1\*.r*" "D:\TV") &goto:Part2
- If it's a RAR'd file, this recognizes it, and extracts directly into my TV folder, completing the "Transfer" Cycle
if exist "R:\%~nx1\%~n1.mkv" (copy /v "R:\%~nx1\%~nx1.mkv" "D:\TV") &goto:Part2
if exist "R:\%~nx1\%~n1.mp4" (copy /v "R:\%~nx1\%~nx1.mp4" "D:\TV") &goto:Part2
- If it's a standalone MKV / MP4 file (actual file, not just a Sample) INSIDE a folder, this recognizes it, and copies to my TV folder, completing the "Transfer" Cycle.
if exist "R:\%~n1.mkv" (copy /v "R:\%~n1.mkv" "D:\TV\") &goto:Part2
if exist "R:\%~n1.mp4" (copy /v "R:\%~n1.mp4" "D:\TV\") &goto:Part2
- If it's a standalone MP4 file (actual file, not just a Sample) NOT INSIDE a folder, this recognizes it, etc, etc... (note the %~n tag in the file portion, not %~nx, since you are forcing the recognition of a specific file extension)
if exist "R:\%~nx1" (md "D:\TV\%~nx1")
- If it's a standalone file (NOT INSIDE a folder, AND not MKV/MP4), OR non-mkv/mp4 files INSIDE a folder, this will create a folder in D:\TV - examples of this would be music and games
if exist "R:\%~nx1" (copy /v "R:\%~nx1" "D:\TV\%~nx1") &goto:Part2
- based on the criteria above, this will copy the file(s) (either stand-alone, or inside a folder) to the newly created folder, completing the "Transfer" Cycle
:Part2 (Completion Move - Files)
pause
- Just to make sure the above worked right
if exist "R:\%~nx1\*" (md "V:\Completed\%~nx1")
- If there's a torrent folder, then Create the same folder on the Completion drive
if exist "R:\%~nx1\*" (copy /y "R:\%~nx1\*" "V:\Completed\%~nx1\") &goto:Part3
- Copy contents from the download folder to the completion folder
*** I had an RD (Remove Directory) command here to remove the original, but since it's still being seeded by QBT, it gives an IO error
if exist "R:\%~nx1" (copy /y /v "R:\%~nx1" "V:\Completed\") &goto:Part3
- If it's a standalone file, then copy (NOT move, due to the *** above) to the Completion drive
:Part3 Torrent Move
pause
- Just to make sure the above worked right, again
move /y "R:\TorTemp\%~nx1.torrent" "V:\Torrents\"
- Moves the Torrent file to the completion drive, in the folder designated to pick up new torrents by the NAS. File checking is successful due to the successful Part 2, and long-term seeding can commence!
*** Note: this step has to be in the script, after the Completion Move. If it's set to transfer in QBT, then that event will trigger before the script, the NAS would pick up the torrent, create the folders and start downloading, all before the script triggered
pause
- Holy crap, it worked
exit
The only flaw here that QBT Completion Moving does successfully finish the deletion of the "source" folder. Here, one has to go into QBT and manually delete the torrent (which I do anyway, since it's seeded on the NAS),
but also remembering to also check the box for Delete Files.
Bloody hell, it's been like a full time job getting this thing set up how I want it. Hopefully I won't be the only one to use it!
Re: Need setup help to auto-extract torrent files
Posted: Fri Jun 03, 2016 9:19 pm
by KitKat
*downloads script*
Thank you very much and great job!
@tekko
Any improvements/quality of life code cleanups you can see in his batch file?
Re: Need setup help to auto-extract torrent files
Posted: Fri Jun 03, 2016 11:15 pm
by tekko
[quote="KitKat"]
@tekko
Any improvements/quality of life code cleanups you can see in his batch file?
[/quote]
:Part1
if exist "R:\%~nx1\*.r*" ("R:\TorTemp\WinRAR\WinRAR.exe" x -ibck -inul "R:\%~nx1\*.r*" "D:\TV") &goto:Part2
if exist "R:\%~nx1\%~nx1.mkv" (copy /v "R:\%~nx1\%~nx1.mkv" "D:\TV") &goto:Part2
if exist "R:\%~nx1\%~nx1.mp4" (copy /v "R:\%~nx1\%~nx1.mp4" "D:\TV") &goto:Part2
if exist "R:\%~n1.mkv" (copy /v "R:\%~n1.mkv" "D:\TV") &goto:Part2
if exist "R:\%~n1.mp4" (copy /v "R:\%~n1.mp4" "D:\TV") &goto:Part2
if exist "R:\%~nx1" (
md "D:\TV\%~nx1"
copy /v "R:\%~nx1" "D:\TV\%~nx1"
)
:Part2
Pause
if exist "R:\%~nx1\*" (
md "V:\Completed\%~nx1"
copy /v "R:\%~nx1\*" "V:\Completed\%~nx1"
goto:Part3
)
if exist "R:\%~nx1" (copy /v "R:\%~nx1" "V:\Completed")
:Part3
Pause
move /y "R:\TorTemp\%~nx1.torrent" "V:\Torrents"
Pause
exit