Jump to content

uTorrent - Auto Labeler (Automatically labels new added Torrent's)


mukunku

Recommended Posts

Hello everyone,

I would like to share a program i wrote for myself that i like to call 'Autolabeler'. Clever ey?

Now also with Tracker Support!

Program Description:

'Autolabeler' runs in the windows background checking for new torrent additions. When a new torrent is added to uTorrent, the program compares the name and/or trackers, of the torrent to be added, to settings that the user has defined earlier.

Meaning, your torrent's will all be automatically labeled when you first add them.

Program Purpose:

I wrote this program for myself because I got kinda tired of always selecting a label for my new torrents. And since i download ~5 torrents daily, I thought it was high time i did something about it.

Also, upon request, i added support for labeling by tracker's.

How to Use:

Please direct your attention to the image below:

labelersettings.png

Once you run the program for the first time, a file called 'Labeler_Settings.ini' is created. With a preset layout, similar to the image above. Users can modify this file to suit their needs.

Basic Format:

LabelName=Keyword1,Keyword2,Keyword3, ...etc

-Keywords must not have spaces in the beginning and/or end. Spaces between words are allowed.

-Comma's are used to seperate keywords "," (Without the quotes)

-Characters are not case sensitive. ( A = a )

So whenever the program detects 'Keyword1' in the torrent title, the label for the newly added torrent is automatically changed to 'LabelName'.

How it Works:

The program checks the 'Torrent Name' of all newly added torrent's.Or if you download the program with 'Tracker Support', the program also checks the torrents trackers. Then the program searches for 'Keywords' in the name and/or trackers. If a match is found, the matching 'Label Name' for that keyword is assigned to the new torrent.

For example, look at the image below:

newtorrent.png

In my 'Labeler_Settings.ini' file i have:

TV-Shows=House,Conan,Chuck,American Dad,Family Guy,Futurama,Castle,Daily Show,Mythbusters,Philadelphia,Simpsons

I put the keyword 'Philadelphia' in because it's rare to ever download another torrent with the word 'Philadelphia' in it. If you would like to be more precise, you can write the full title of the show so the program is more accurate. Example: 'its always sunny in philadelphia'.

Tracker Support:

38tyx.png

For tracker support, just add any part of the tracker as a Keyword. Example:

Movies=thepiratebay.org,tracker.zamunda.net,tracker.somerandomtracker.net

Important Note: When labeling according to Torrent Name's, Period's "." (Without the quotes) are automatically converted to 'Space' characters. So "The.Daily.Show" will be read by the program as = "The Daily Show". This is NOT the case with trackers.

Important Note 2: Labeling priority is top-down. Meaning the first matching label will be used. So if you would like to give a certain KEYWORD or LABEL higher priority, put that higher in the INI file.

Tested on Utorrent version: 3.1.3

I can't guarantee it will work with previous versions.

Download(No Tracker Support):

Download: http://grj.sf.net/Utorrent_AutoLabeler.exe

Download (with Tracker Support):

Download: http://grj.sf.net/Utorrent_AutoLabeler_wTrackerSupport.exe

Virus Scan: http://www.virustotal.com/file-scan/report.html?id=a96275e340843b2b16606e7e6279b3bf755680c4c534bcc855b77fc8dce56e0e-1325793115

Virus Scan 2: https://www.virustotal.com/file/75e46354f4483fdc4fbe19e8f6e79726205aa81cbf5023db87895b94d0c996c2/analysis/1339690262/

Recommended Usage: Copy the program to a place where you most likely wont move it. Then create a shortcut to the program and place it in your 'Startup' folder. This way the program will run when ever you open your PC and automatically detect new torrent's whenever you need it to. After you can run the exe once to create the 'Labeler_Settings.ini' file and configure it to fulfill your needs.

Parting Words:

Written in AutoHotkey. You can decompile the program and check out the source code. Though I wouldn't recommend it, because the code is a bit of a mess :P

I hope some people get good use out of this program.

Update: After adding tracker labeling support, i added another download link. Because to label according to trackers, the 'Advanced..' settings window is must be opened for a second to get the torrents tracker list.This is done automatically and the window is closed immediately, but it can get annoying if you don't want this feature. So if you don't want tracker support, download the one without the tracker support.

Best Regards,

Mukunku

Link to comment
Share on other sites

  • 3 weeks later...
Very nice. Too bad for me I am not running PC.

What if instead of using keywords the program would just look at the tracker. I know many people have one site for music, one for tv, etc.. so it could assume all torrents from one tracker to be similar.

That's a good idea. If I ever decide to improve this, I will definitely keep that in mind as a functionality.

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...
I tried to decompile this to see if I could easily get it to look at the tracker field instead of the label name, and it says NotARC, so it's either corrupted or not an autohotkey file? Ah well. Here's another request to look at the tracker instead of label name.

#Persistent
#SingleInstance,Force
#NoTrayIcon

SetTitleMatchMode,2

var_PreviousWindows := ""
if !(FileExist("Labeler_Settings.ini")) {
GoSub,sub_IniWrite
}

SetTimer,sub_CheckNewTorrent,250
SetTimer,sub_ClearPreviousWindows,20000 ;This will clear the string that holds: Previous Windows that had their Labels set. So Let's say a window with the id 0x0efab2 had it's label set to 'Movie'. Then this window's id is added to the string so it's label isn't constantly updated. Every 20 seconds we clear this string, to improve long term runnability.
Return

sub_CheckNewTorrent:
var_WinID := WinExist("Add New Torrent ahk_class #32770")
if (var_WinID)
{
if var_PreviousWindows contains %var_WinID% ;checks if this windows label was set previously within 20 seconds.Prevents the program from frequently updating the label of the same window
Return

SetTimer,sub_CheckNewTorrent,OFF
GOGOGO(var_WinID,var_PreviousWindows)
SetTimer,sub_CheckNewTorrent,ON
}
Return


GOGOGO(winid,ByRef previouswindowsstring) {

;First Let's get the File Name from 'Static2'.Should work for Multiple File torrents. Like 'Seasons 1-4 of House MD'
ControlGetText,var_FileName,Static2,Add New Torrent ahk_id %winid%

;Next let's replace the '.' (period) 's from the file name. Since this is quite common among torrent files.
StringReplace,var_FileName,var_FileName,.,%A_Space%,1

;Now get the Labels and the keywords assigned to that label in one giant string.
IniRead,var_IniOut,Labeler_Settings.ini,LABELS
if !(FileExist("Labeler_Settings.ini")) {
GoSub,sub_IniWrite
}

j := 0
;First loops parses the giant string by line feeds.so we have 'LABEL1=KEYWORDS1', then next loop 'LABEL2=KEYWORDS2' ,.. etc
Loop,Parse,var_IniOut,`n,
{
asd := A_LoopField
Loop,Parse,asd,=,
{
;This Loop seperates the Label and the Keyword list. For this example let's say LABEL1 and KEYWORDS1.
if (j = 0)
var_Label := A_LoopField ;LABEL1
else
var_LabelList := A_LoopField ;KEYWORDS1
j++
}
j := 0
;Now Let's Check if any of KEYWORDS1 is present in the file name.
if var_FileName contains %var_LabelList%
{
previouswindowsstring .= " " winid " "
;One of the keywords from KEYWORDS1 was matched in the file name.So LABEL1 must be selected from the combobox.
Control,ChooseString,%var_Label%,ComboBox2,Add New Torrent ahk_id %winid%
Break ;Break since we don't need to check LABEL2,LABEL3,..etc
}
}

}

sub_IniWrite:
IniWrite,House`,How I Met Your Mother`,The Big Bang Theory,Labeler_Settings.ini,LABELS,TV-Shows
Return

sub_ClearPreviousWindows:
var_PreviousWindows := ""
SetTimer,sub_ClearPreviousWindows
Return



^r::
reload
return

I don't know why you got an error while decompiling. So here's the code for you =)

I was going to look into the tracker based sorting. But i got too busy with other matters. If you happen to implement this. Do share, please.

Sincerely,

mukunku

Link to comment
Share on other sites

It's not perfect but, I added another download link with Tracker support. You can find the link in my original post. Please read all the details in my first post to get a general idea on how it works.

Again you can decompile the program if you want. Here's a link to the decompiler: http://www.autohotkey.com/download/Exe2Ahk.exe

I didn't have much time to test it. So any feedback would be greatly appreciated.

Regards,

Mukunku

Link to comment
Share on other sites

  • 4 weeks later...

Just a thought, but what about expanding the keyword handling to include wildcards or boolean logic. That way, rather than having to enter every single TV show name, you could simply enter something which all TV shows have in common: season and episode info.

Entering a keyword such as...

s??.e??

... would mean any TV shows would be picked up.

Similarly, since most movie files have the production date between (...), you could enter...

(19??),(20??),

... to pick up any movie files.

Link to comment
Share on other sites

Download links are down.

They seem to be working for me?

Just a thought, but what about expanding the keyword handling to include wildcards or boolean logic. That way, rather than having to enter every single TV show name, you could simply enter something which all TV shows have in common: season and episode info.

Entering a keyword such as...

s??.e??

... would mean any TV shows would be picked up.

Similarly, since most movie files have the production date between (...), you could enter...

(19??),(20??),

... to pick up any movie files.

That sounds like a good idea, and can be implemented with Regular Expressions. But that would require the end-user to learn Regular Expression. Other solutions are possible but are much more complex. If i get around to it,i'll definitely try that out.

Link to comment
Share on other sites

mukunku:

File Blocked for Violation.

The file you requested has been blocked for a violation of our Terms of Service.

If you believe you have reached this page in error, please contact support.

Click here to view our help resources

I got that when I try to download the labeler. Can you upload it again? :D:):rolleyes: Thank you for such great invention.

Link to comment
Share on other sites

  • 2 months later...
I can`t download from both of the site u :( Don`t work for me no matter what i try.

Can someone reupload them to any different host like mediafire or sharebeast, rapidshare is fine too!

Thanks in advance :D

I uploaded it to one of my project servers. Hopefully no download problems will occur in the future.

Link to comment
Share on other sites

  • 4 weeks later...

Thanks it works well as long as the "Show a window when adding a torrent" option is enabled in utorrent preferences.

I suppose because of the macro scripting it would not be possible to do it if the window was not opened. So it is not yet fully automatic, but still an improvement.

Utorrent really should have this feature included and also automatic moving of torrent contents download location when a label is changed.

Link to comment
Share on other sites

  • 3 weeks later...

Thanks, this helps a lot with sorting torrents. Especially with torrents that usually finishes faster than you manually get time to label them (First world problems, hooo), and as such the automatic label sorting doesn't work.

Is it possible to make it work on magnet links as well though? It doesn't seem to label them right now, probably because the torrent has the magnet link as a name before it starts downloading the file(s).

EDIT:Also, a couple of groups use "_" instead of "." or " " between words, which probably also should be added as something that would be converted into spaces.

I realize i could simply add

StringReplace,var_FileName,var_FileName,_,%A_Space%,1

just next to

StringReplace,var_FileName,var_FileName,.,%A_Space%,1

based on the old code a few posts above to make this work, but just like johcagaorl i couldn't decompile the newer version of the program to make this change for myself. NotARC error again.

Link to comment
Share on other sites

Thanks it works well as long as the "Show a window when adding a torrent" option is enabled in utorrent preferences.

I suppose because of the macro scripting it would not be possible to do it if the window was not opened. So it is not yet fully automatic, but still an improvement.

Utorrent really should have this feature included and also automatic moving of torrent contents download location when a label is changed.

Yes unfortunately this is quite a simple script. You need the "torrent adding window" in order to label the new torrent.

I really don't understand why uTorrent hasn't implemented this yet. Since it's such a simple feature. I've been looking into uTorrent apps to see if I could design one that accomplished this feature in a "fully automatic" fashion. But I really haven't had much time =]

Link to comment
Share on other sites

Thanks, this helps a lot with sorting torrents. Especially with torrents that usually finishes faster than you manually get time to label them (First world problems, hooo), and as such the automatic label sorting doesn't work.

Is it possible to make it work on magnet links as well though? It doesn't seem to label them right now, probably because the torrent has the magnet link as a name before it starts downloading the file(s).

EDIT:Also, a couple of groups use "_" instead of "." or " " between words, which probably also should be added as something that would be converted into spaces.

I realize i could simply add

StringReplace,var_FileName,var_FileName,_,%A_Space%,1

just next to

StringReplace,var_FileName,var_FileName,.,%A_Space%,1

based on the old code a few posts above to make this work, but just like johcagaorl i couldn't decompile the newer version of the program to make this change for myself. NotARC error again.

I haven't really ever downloaded a magnet link =P Thepiratebay is banned in my country and i really felt no need to use magnet links before. Not anytime soon but, i'll try to check that out..

As for the updated source code:

#Persistent
#SingleInstance,Force
#NoTrayIcon

SetTitleMatchMode,2

var_PreviousWindows := ""
if !(FileExist("Labeler_Settings.ini")) {
GoSub,sub_IniWrite
}

SetTimer,sub_CheckNewTorrent,250
SetTimer,sub_ClearPreviousWindows,40000 ;This will clear the string that holds: Previous Windows that had their Labels set. So Let's say a window with the id 0x0efab2 had it's label set to 'Movie'. Then this window's id is added to the string so it's label isn't constantly updated. Every 20 seconds we clear this string, to improve long term runnability.
Return

sub_CheckNewTorrent:
var_WinID := WinExist("Add New Torrent ahk_class #32770")
if (var_WinID)
{
if var_PreviousWindows contains %var_WinID% ;checks if this windows label was set previously within 40 seconds.Prevents the program from frequently updating the label of the same window
Return

SetTimer,sub_CheckNewTorrent,OFF
GOGOGO(var_WinID,var_PreviousWindows)
SetTimer,sub_CheckNewTorrent,ON
}
Return


GOGOGO(winid,ByRef previouswindowsstring) {

;First Let's get the File Name from 'Static2'.Should work for Multiple File torrents. Like 'Seasons 1-4 of House MD'
;ControlGetText,var_FileName,Static2,Add New Torrent ahk_id %winid%
WinGetTitle, var_FileName, Add New Torrent ahk_id %winid%

;Now let's get tracker list for the torrent file. Unfortunately we have to open the 'Advanced..' window, to see trackers..
ControlClick,Button12,Add New Torrent ahk_id %winid%
WinWait,Torrent Properties ahk_class #32770,,2.0
var_PropertiesWinID := WinExist("Torrent Properties ahk_class #32770")
if (var_PropertiesWinID)
{
ControlGetText,var_TrackerList,Edit1,Torrent Properties ahk_id %var_PropertiesWinID%
WinKill,Torrent Properties ahk_id %var_PropertiesWinID%
}

;Next let's replace the '.' (period) 's from the file name. Since this is quite common among torrent files.
StringReplace,var_FileName,var_FileName,.,%A_Space%,1

;Now get the Labels and the keywords assigned to that label in one giant string.
if !(FileExist("Labeler_Settings.ini")) {
GoSub,sub_IniWrite
}
IniRead,var_IniOut,Labeler_Settings.ini,LABELS

j := 0
;First loops parses the giant string by line feeds.so we have 'LABEL1=KEYWORDS1', then next loop 'LABEL2=KEYWORDS2' ,.. etc
Loop,Parse,var_IniOut,`n,
{
asd := A_LoopField

Loop,Parse,asd,=,
{
;This Loop seperates the Label and the Keyword list. For this example let's say LABEL1 and KEYWORDS1.
if (j = 0)
var_Label := A_LoopField ;LABEL1
else
var_LabelList := A_LoopField ;KEYWORDS1
j++
}
j := 0
;First let's check if any of KEYWORDS1 is present in the Torrents Trackers
if var_TrackerList contains %var_LabelList%
{
previouswindowsstring .= " " winid " "
;One of the keywords from KEYWORDS1 was matched with a tracker in the torrent. So LABEL1 must be selected from the combobox.
Control,ChooseString,%var_Label%,ComboBox2,Add New Torrent ahk_id %winid%
Return ; Return since we don't need to check LABEL2,LABEL3,..etc
}
;Now Let's Check if any of KEYWORDS1 is present in the file name.
if var_FileName contains %var_LabelList%
{
previouswindowsstring .= " " winid " "
;One of the keywords from KEYWORDS1 was matched in the file name.So LABEL1 must be selected from the combobox.
Control,ChooseString,%var_Label%,ComboBox2,Add New Torrent ahk_id %winid%
Return ; Return since we don't need to check LABEL2,LABEL3,..etc
}
}

}

sub_IniWrite:
IniWrite,House`,How I Met Your Mother`,The Big Bang Theory,Labeler_Settings.ini,LABELS,TV-Shows
Return

sub_ClearPreviousWindows:
var_PreviousWindows := ""
SetTimer,sub_ClearPreviousWindows
Return


You can compile this with the compiler at Autohotkey.com =] Add any thing you like.

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

This is really great and the closest I've seen anyone get to almost getting this done. But alas, I say almost because it only (semi)works for me.. It changes to the right label at the pop screen (which is an improvement),but doesn't close it automatically. I have to.

Any ideas as to why? Was this intended?

Link to comment
Share on other sites

  • 3 weeks later...
That's an amazing app!

I'm not an AutoHotKey programmer, Is there too much to do to port it to 3.2?

Thanks! :D

I can't work on the code right now but if you were to change this line:

ControlClick,Button12,Add New Torrent ahk_id %winid%

to:

ControlClick,Button13,Add New Torrent ahk_id %winid%

and then compile it,The program will work on 3.2 too.

This is really great and the closest I've seen anyone get to almost getting this done. But alas, I say almost because it only (semi)works for me.. It changes to the right label at the pop screen (which is an improvement),but doesn't close it automatically. I have to.

Any ideas as to why? Was this intended?

It was intended that way because the user may want to select which files to download. But that's a good functionality that could be added. Again, I can't work on the original code right now, but if you were to edit the code (post #20) and compile it, you could achieve this functionality yourself.

Note: This will work for uTorrent 3.2

To achieve your requested functionality, change:

		;First let's check if any of KEYWORDS1 is present in the Torrents Trackers
if var_TrackerList contains %var_LabelList%
{
previouswindowsstring .= " " winid " "
;One of the keywords from KEYWORDS1 was matched with a tracker in the torrent. So LABEL1 must be selected from the combobox.
Control,ChooseString,%var_Label%,ComboBox2,Add New Torrent ahk_id %winid%
Return ; Return since we don't need to check LABEL2,LABEL3,..etc
}
;Now Let's Check if any of KEYWORDS1 is present in the file name.
if var_FileName contains %var_LabelList%
{
previouswindowsstring .= " " winid " "
;One of the keywords from KEYWORDS1 was matched in the file name.So LABEL1 must be selected from the combobox.
Control,ChooseString,%var_Label%,ComboBox2,Add New Torrent ahk_id %winid%
Return ; Return since we don't need to check LABEL2,LABEL3,..etc
}

To:

		;First let's check if any of KEYWORDS1 is present in the Torrents Trackers
if var_TrackerList contains %var_LabelList%
{
previouswindowsstring .= " " winid " "
;One of the keywords from KEYWORDS1 was matched with a tracker in the torrent. So LABEL1 must be selected from the combobox.
Control,ChooseString,%var_Label%,ComboBox2,Add New Torrent ahk_id %winid%
ControlClick,Button14,Add New Torrent ahk_id %winid%
Return ; Return since we don't need to check LABEL2,LABEL3,..etc
}
;Now Let's Check if any of KEYWORDS1 is present in the file name.
if var_FileName contains %var_LabelList%
{
previouswindowsstring .= " " winid " "
;One of the keywords from KEYWORDS1 was matched in the file name.So LABEL1 must be selected from the combobox.
Control,ChooseString,%var_Label%,ComboBox2,Add New Torrent ahk_id %winid%
ControlClick,Button14,Add New Torrent ahk_id %winid%
Return ; Return since we don't need to check LABEL2,LABEL3,..etc
}

I'm going to work on this program in the near future and try to add all the requested functionalities. Hopefully with some gui ;)

Link to comment
Share on other sites

  • 4 weeks later...

hey this is good and all :D but i have edited the .ini file and started the labeler.exe and it its not working my .ini looks like this:

[LABELS]

TV-Shows=American Dad,How I Met Your Mother,The Big Bang Theory,Burn Notice,Castle,Family Guy,Merlin,Shameless,Star Wars The Clone Wars,Supernatural,The Mentalist,The Simpsons,Two and a Half Men,The Middle

can u tell me why its not working?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...