[Windows] uTorrent - Sharing my automated Vbscript

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
skullzy
Power User
Posts: 50
Joined: 07 Jan 2015, 22:19

[Windows] uTorrent - Sharing my automated Vbscript

Post by skullzy »

[17/10/2015]
I've been trying to figure out how to convert my vbscript to groovy, this got me thinking about cleaning up the script even more as my previous vbscript was more of a rush job than anything else, so while I work on making a groovy version this is a new improved and overall better version.

This script has the following features.

The Filter -

Episode Age!
The filter has been improved a lot thanks to Rednoah for suggesting to use the age feature instead of airdate.timestamp, which means it will now only look into the past, i've even added the ability for those using this script to easily change how far back, "in days", to check for that episode. Min 1 day Max 6 days default is 4, if you attempt to set a day less than 1 or greater than 6 then the default value of 4 will be set in it's place.

Labels
The filter it'self is a hell of a lot faster now that I've switched from using arrays to using vbs's dictionairy object (known as map in groovy), in my old script I would use a list of labels and loop through them looking for the label set by utorrent, now it simply checks to see if it exists, this also reduces filesize.

Manual series search
I've added the ability to set up custom labeling that will be used to manually search for a series, this will eradicate an issue I had with naming some shows. This works thanks to the --q feature in filebot.

The Log -
I've changed the function of how my script verifies the filebot log, I have created a function that will check the logs last line and verify it has completed successfuly, if for some reason filebot failed it will now pause the torrent instead of popping up with an error message. This allows me to check the log when I get home to find out what caused the problem.

The Clean Up -
Once the torrent completed successfully and reaches the finnished state, this script will delete the filebot log + Torrent & Data.

The following arguments remain the same in utorrent.
When torrent finishes

Code: Select all

C:\AutoMate.vbs "Fb" "%L" "%S" "%N" "%K" "%F" "%D" "%I"
When torrent changes state

Code: Select all

C:\AutoMate.vbs "Wb" "%L" "%S" "%N" "%K" "%F" "%D" "%I"
It is also important that you go to Queueing in uTorrent preferences and set a seeding goal, I use Minimum ratio % 200. Also go to Advanced -> UI Extras and add the default label tvnew|tvold|movies so that you have the ability to simply right click and select the label, which will prevent typos, then go to WebUI, enable and set a username and password.

Download Automate.vbs via dropbox.

Here is a breakdown of the script settings.

Essentially these are the default labels set-up for filebot to determine whether or not to use the age filter or whether not to process the torrent, example: if the torrent that downloaded doesn't contain a primary label of tvnew, tvold or movies (or the custom labels I'll show you in a second), then the script will not run. In utorrent the label isn't case sensitive, so you can set a label like so tvnew, TvNew, TVNEW.. as long as it's spelt corectly it will work ;)

Code: Select all

Option Explicit
' Default Label Setup - DON'T EDIT; unless you know what you're doing.
	Dim Label, ObjShell, UsrDir, Filebot, Special, Ep_Age, WebUI
	
	' Dictionary Object
	Set Label = CreateObject("Scripting.Dictionary")
	
	Label.Add "tvnew","tvnew" ' Recently Aired episodes within Age range.
	Label.Add "tvold","tvold" ' Old Episodes outisde of Age range.
	Label.Add "movies","movies" ' Movies :)

For obvious reasons don't edit were it says not to edit, the following code is your filebot settings, now the important settings for this script to work have been added later, these are the settings you have control over, by default I have action as test, as I assume you'll want to try it out before you actually use it, I would recommend using copy for the action setting as the script will auto-delete the torrent and data once the seeding goal has been reached, essentially you already know what seriesFormat and movieFormat is, I never added anime because I don't download it, however it would be a simple case of adding that option in then including it in the main part of the script.

Code: Select all

' FileBot Setup
	' DON't Edit THIS >
	Set ObjShell = WScript.CreateObject("WScript.Shell")
		
	' UserDir = C:/Users/Bob
	UsrDir = replace(ObjShell.expandEnvironmentStrings("%userprofile%"), "\", "/")
	
	' Dictionary Object
	Set Filebot = CreateObject("Scripting.Dictionary")
	' < DON't Edit THIS
	
	' Settings
		' --action test | copy
	Filebot.Add "action", "test"
		' --output C:/Users/Bob/Documents
	Filebot.Add "output",UsrDir & "/Documents"
		' seriesFormat=C:/Users/Bob/Documents/Tv/Dexter/Season 1/Dexter - s01e01 - Dexter.mp4
	Filebot.Add "seriesformat","/Tv/{n}/Season {s}/{n} - {s00e00} - {t}"
		' movieFormat=C:/Users/Bob/Documents/Movies/Jurassic World (2015).mp4
	Filebot.Add "movieformat","/Movies/{n} ({y})"
		' uTorrent and script settings are preset in the main script
Okay so this is the custome label you can set to manually search for a series in filebot, to use this is fairly simple, you have a Key and a Value, the Key is what the label in utorrent has to be and the value is what you want to input for the search. Special.Add "label_here", "Series Name"

So let's say in my RSS feed I had American Dad, I would set it up with a label like American_Dad or whatever I want it to be, so when my RSS auto-downlaods the show it will have that label, in my special label setup I then add this like so --> Special.Add "american_dad", "American Dad!", I would do this between the "> Add/Remove series here >" comments.

The special labels are just like the tvnew label except it adds the manual search. So instead of filebot auto-detecting the series name, it will look for American Dad! and try to find the last episode aired in the past 4 days.

Code: Select all

' Special Label Setup
	' Dictionary Object
	Set Special = CreateObject("Scripting.Dictionary")
	
	' Change the following value to 0 if you wish to disable this feature
	Special.Add "enable","1" ' Value: 1 = true, Value: 0 = false
		
	' > Add/Remove here >
	Special.Add "forever_us","Forever 2014"
	Special.Add "american_dad","American Dad!"
	' < Add/Remove here <
The comments for this are self explanatory, but remember that if you set a value that is outside of the min/max days allowed, it will use the default in order to prevent issues.

Code: Select all

' Series Episode Age
	' Change this in order to decrease or increase how far back to look for the episode.
	' Minimum 1 : Maximum 6 : Default 4
	Ep_Age = 4 ' Days
This allows my script to pause and or remove torrent+data within utorrent.

Code: Select all

' Controlling uTorrent via WebUI
	' Dictionary Object
	Set WebUI = CreateObject("Scripting.Dictionary")
	
	WebUI.Add "user","user" 		' WebUI username 
	WebUI.Add "pass","webui"		' WebUI password
	WebUI.Add "host","localhost"	' WebUI URL localhost|127.0.0.1, local connection is recommended
	WebUI.Add "port","12345"		' WebUI uTorrent listening Port
I should also note that the function for verifying logs will use the default location, which is %appdata%\filebot\logs

If you notice any bugs let me know, although this has been up and running on two seperate machines and both appear to be running smoothly, in fact this script is faster than it's predecessor. Enjoy :)
nytram
Posts: 30
Joined: 12 Feb 2014, 04:34

Re: [Windows] uTorrent - Sharing my automated Vbscript

Post by nytram »

Hi

Thanks for sharing

looks like you spent a bit of time on this, i have written a total of two programs in vb hate it with a passion so thanks

Martyn
User avatar
rednoah
The Source
Posts: 23002
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [Windows] uTorrent - Sharing my automated Vbscript

Post by rednoah »

1.
VBS, CMD, even bash... it was so horrible and limited in every way I had to include a Groovy engine, and never looked back. :ugeek:

2.
The "Fear the Walking Dead" issues should be fixed by next month or so. Now the show should have sufficient ratings/popularity so the next time I index all TV shows it should be in the list.

3.
Very nice to see people starting to use an age --filter in their automated setups. :D
:idea: Please read the FAQ and How to Request Help.
skullzy
Power User
Posts: 50
Joined: 07 Jan 2015, 22:19

Re: [Windows] uTorrent - Sharing my automated Vbscript

Post by skullzy »

rednoah wrote:1.
VBS, CMD, even bash... it was so horrible and limited in every way I had to include a Groovy engine, and never looked back. :ugeek:

2.
The "Fear the Walking Dead" issues should be fixed by next month or so. Now the show should have sufficient ratings/popularity so the next time I index all TV shows it should be in the list.

3.
Very nice to see people starting to use an age --filter in their automated setups. :D
1. I love the amc.groovy script :), sure I even added in a fix for one of my shows that kept screwing up the when renaming.

Code: Select all

def MyList = [foreverus:'Forever 2014']
def Key = "$group.tvs".replaceAll("\\s","")
I wouldn't even know were to start with groovy otherwise if I could and if I knew how to I would build my script around the amc script :D

2. Fear the walking dead actually shows up.. I think it's due to the non-strict command.. but without that my bypass filter option TVOLD, wouldn't work as well as I'd like it, although I can't remember why I set this.. I think it was to help with older episodes for American Dad and Family Guy.. I'll have to run some tests.. Anyway here is what the script would look like.

Code: Select all

-script FbGroovy C:/amc.groovy --output "userdirectory/Documents"
--log-file "Fear.The.Walking.Dead.S01E01.XviD-AFG.log"
--action copy
--conflict override
-non-strict -no-xattr
--filter ""(now.time - airdate.timeStamp < 345600000) '<== only if label is TVNEW

--def "clean=y"
seriesFormat="userdirectory/Documents/Tv/{n}/Season {s}/{n} - {s00e00} - {t}"
movieFormat="userdirectory/Documents/Movies/{n} {y}"


ut_label="TVOLD" ut_state="11" ut_title="Fear.The.Walking.Dead.S01E01.XviD-AFG" ut_kind="multi" ut_file="Fear.The.Walking.Dead.S01E01.XviD-AFG.avi" ut_dir="userdirectory/Downloads\utorrent\Complete\Fear.The.Walking.Dead.S01E01.XviD-AFG"

Code: Select all

Auto-detected query: [Fear, Fear The Walking Dead, The Walking Dead]
Fetching episode data for [Fear Factor]
Fetching episode data for [Fear Itself]
Fetching episode data for [Fear Clinic]
Fetching episode data for [Fear Factor (UK)]
Fetching episode data for [Fear Factor: Khatron Ke Khiladi]
Fetching episode data for [Fear the Walking Dead]
Fetching episode data for [The Walking Dead]
Fetching episode data for [Talking Dead]
Now if the --filter was being used then it would automatically use Fear the Walking dead since it would be the only series that would closely relate the title and Season/Episode info.. But that actually gives me an idea.. ;) be back with updates if possible lol.

3- --filter feature saved me a butt load of headaches :D
Post Reply