DonationCoder.com Forum

DonationCoder.com Software => Coding Snacks => Finished Programs => Topic started by: ak_ on August 17, 2007, 06:00 PM

Title: SubDude, a subtitle renaming program
Post by: ak_ on August 17, 2007, 06:00 PM
Here's a little program i made for myself to automatically rename subtitles files to match video files because i was tired of doing it by hand. I guess this program will not be very useful to english-speaking people but it might be to the others.

Here's the situation : you have a folder containing a few episodes or a whole season of a (100% free to download :-[) tv show. You download subtitles files for it and you realize the names of the of the video files and the names of the subtitles files don't match (ie Serie.s01e12.avi & Serie1x12.srt). If you want your media player to automatically load subtitles, you have to rename every subtitles files by hand.

Now, here's SubDude !

Just give SubDude a folder (by using the gui, context-menu or 'Send to') and he will check every video file and look for a corresponding subtitle, and rename it. If you don't trust SubDude, you can tell him to generate an "UnDude" file so you can revert changes in case things were done the wrong way.

subdude.zip (http://soft.wopah.com/subdude/downloads/subdude.zip)

Known restrictions :
Any feedback or bug report will be appreciated :)

[ You are not allowed to view attachments ]

The ahk source is available here but i'm afraid it's very messy and undocumented.
subdude.ahk (http://soft.wopah.com/subdude/downloads/subdude.ahk)
Title: Re: SubDude, a subtitle renaming program
Post by: mouser on August 17, 2007, 06:26 PM
clever  :up:
Title: Re: SubDude, a subtitle renaming program
Post by: ak_ on August 18, 2007, 10:35 AM
Actually, i forgot to say something in my previous message.

To detect episode number, i use regular expressions* based of what i've found in different filenames. Until now, i've seen these templates :


I don't know if many of you use subtitle files, but if you've ever encountered another template, please tell me know so i'll add it in the ini file. Thanks :)

* actually, this project was an opportunity for me to learn about regular expressions and i've been pleased to see that it was less complicated that expected.
Title: Re: SubDude, a subtitle renaming program
Post by: Darwin on August 18, 2007, 11:00 AM
Looks good, ak_ My wife's family are Korean and don't speak/read much English: this will help in making video more accessible to them.

 :Thmbsup:

PS What do you use for regex searches (just curious)?
Title: Re: SubDude, a subtitle renaming program
Post by: ak_ on August 18, 2007, 11:13 AM
PS What do you use for regex searches (just curious)?
If you're asking which function i use : RegExMatch (http://www.autohotkey.com/docs/commands/RegExMatch.htm)

I use it once to isolate the season+episode string (like "s01e05", matching the regex "s\d+e\d+" ), then in this string, i isolate the episode number (here "05", matching "(?<=e)\d+" ). I have to do this in two steps (i guess) because :
The bad news is that most regex flavors do not allow you to use just any regex inside a lookbehind, because they cannot apply a regular expression backwards. Therefore, the regular expression engine needs to be able to figure out how many steps to step back before checking the lookbehind.

Therefore, many regex flavors, including those used by Perl and Python, only allow fixed-length strings. You can use any regex of which the length of the match can be predetermined. This means you can use literal text and character classes. You cannot use repetition or optional items. You can use alternation, but only if all options in the alternation have the same length.

So i can't look for "(?<=e)\d+" directly on the filename and not expect to get weird results (for example, if the serie's called "AirForce1", the last two letters would match). Maybe there's another solution, i dunno, i just learnt regex yesterday :)
Title: Re: SubDude, a subtitle renaming program
Post by: Darwin on August 18, 2007, 04:35 PM
Ah - thank ak_ I have nothing profound to say now, I really was simply curious! I am a regex "twit" I have several apps that will allow me to search and repace using regex, but I've never really taken the time to learn it  :-[
Title: Re: SubDude, a subtitle renaming program
Post by: lanux128 on August 18, 2007, 09:35 PM
thanks ak_, i've been searching for something like this, after manually renaming one whole season of a certain famous tv show. ;) cool icon too, downloading now.. what can i say - thanks, dude! :Thmbsup:

P.S. a screenshot would be nice..

Title: Re: SubDude, a subtitle renaming program
Post by: ak_ on August 19, 2007, 04:40 AM
P.S. a screenshot would be nice..
True, i just added one :) Thanks.
Title: Re: SubDude, a subtitle renaming program
Post by: lanux128 on August 19, 2007, 08:31 AM
True, i just added one :) Thanks.
cool! one more request, what about posting a link to this thread in the SubDude gui? would be easier to make comments and suggestions.. :)
Title: Re: SubDude, a subtitle renaming program
Post by: ak_ on August 19, 2007, 10:45 AM
cool! one more request, what about posting a link to this thread in the SubDude gui? would be easier to make comments and suggestions.. :)
Good idea, done :)
Title: Re: SubDude, a subtitle renaming program
Post by: ak_ on September 04, 2007, 06:48 PM
Subdude update !

What's new :

You can get it here :
subdude.zip (http://soft.wopah.com/subdude/downloads/subdude.zip)

And ahk source is here :
subdude.ahk (http://soft.wopah.com/subdude/downloads/subdude.ahk)

Please report any bug, problem or suggestion :)
Title: Re: SubDude, a subtitle renaming program
Post by: Dude Spell on October 27, 2007, 11:20 AM
Great idea! :Thmbsup:
But link is dead, can you re up them, please?
Title: SubDude, a subtitle renaming program - And a great band!
Post by: edbro on October 27, 2007, 02:06 PM
OT alert:
You guys do realize that The Subdudes are about the best band you've never heard of? I love these guys. Saw them in concert 2 weeks ago.

http://www.subdudes.com/
Title: Re: SubDude, a subtitle renaming program
Post by: ak_ on October 27, 2007, 06:49 PM
Dude Spell> the link are working now, thanks :)
Title: Re: SubDude, a subtitle renaming program
Post by: Dude Spell on October 31, 2007, 12:35 AM
Dude Spell> the link are working now, thanks :)
I thank you, my friend.  :Thmbsup:
Title: Re: SubDude, a subtitle renaming program
Post by: ovehal on January 20, 2009, 02:12 PM
A great program. It would save me a lot of work if I could get it to work.

My files looks like this:
The O C Season 1 Episode 07 The Escape -Tvep.avi
The.O.C.S01E07.The.Escape.DVDRip.XviD-TVEP.srt

I guess it can be solved by editing the regexp in the inifile, so I hope some regexp expert could help me out...

EDIT: The download link did  not work, but I found it at: http://soft.wopah.com/subdude/subdude.zip

Best regards
Ove B-)
Title: Re: SubDude, a subtitle renaming program
Post by: lanux128 on March 26, 2009, 10:23 PM
ak_: just want to say that SubDude has been a big help for me. along with the subtitle renaming, i've been using SubSude for renaming episode thumbs as well as nfo files by adding those extensions in the ini file. thanks again. :Thmbsup:

[Formats]
video=avi;mpg;mpeg;rmvb;asf;asx
subtitles=srt;txt;sub;nfo;tbn;jpg
Title: Re: SubDude, a subtitle renaming program
Post by: ak_ on March 27, 2009, 10:30 AM
Thanks Lanux :) I'm glad you found your own way of using SubDude.

I've been thinking about improving SubDude for quite some time now, mainly because sometimes files are named in a way that SubDude can't handle (like : TVShow-Season-Name of the episode-Episode number), but the regular expression give me a headache :) I'm thinking about some kind of "learning mode" so you can indicate where the season and episode numbers are in one file and then the program finds them in the other files (i hope i'm clear). I hope i'll get the time and the courage to work on that some day :)
Title: Re: SubDude, a subtitle renaming program
Post by: lanux128 on March 27, 2009, 10:53 AM
yeah sometimes they are named quite bizarrely, even dedicated media scrapers can't get around those. :)
Title: Re: SubDude, a subtitle renaming program
Post by: jonker1541 on March 29, 2009, 11:29 AM
Registered to say thanks for this app.

It just renamed 4 seasons worth of tv for my gf, that I ordinarily rename by hand :-)

A question: Subdude seems unable to link the following two files:

01x01 - Pilot.srt

and

Series Name 101 - Pilot.avi

Is that due to the fact that the series name is not in the srt file name? Or is it unable to link 01x01 with 101. (unfortunately I have another 4 seasons that are formatted this way :-))
Title: Re: SubDude, a subtitle renaming program
Post by: ak_ on March 29, 2009, 12:16 PM
Hi jonker :)

The problem is that i didn't add support for "101" filenames yet. I suppose it could be easily done, but it seemed tricky to me when i coded SubDude (i had never dealt with regular expressions before). When i face this particular problem, i use a batch renaming program to rename the files first (in this case, i would replace "Series Name 1" with "Series Name 1x"), then i use SubDude.

I'll try to fix this problem soon :)
Title: Re: SubDude, a subtitle renaming program
Post by: jonker1541 on March 29, 2009, 01:31 PM
That indeed worked perfectly. Took me 5 minutes to download and figure out a batch renamer.

Then Subdude figured out how to do it  :)

Thanks again for programming this, and making it available for everyone, and replying to questions so quickly...

Title: Re: SubDude, a subtitle renaming program
Post by: superture on August 19, 2009, 04:38 PM
Seems great but doesn't work with mkv files? I'd like exactly the same but with .mkv files aswell!
Title: Re: SubDude, a subtitle renaming program
Post by: lanux128 on August 19, 2009, 08:42 PM
Seems great but doesn't work with mkv files? I'd like exactly the same but with .mkv files aswell!

as i mentioned in my post above, you can add as many different extensions in the INI file. just exit subdude, edit the ini file and start again.

[Formats]
video=avi;mpg;mpeg;rmvb;asf;asx;mkv
subtitles=srt;txt;sub;nfo;tbn;jpg
Title: Re: SubDude, a subtitle renaming program
Post by: superture on August 20, 2009, 02:41 AM
Seems great but doesn't work with mkv files? I'd like exactly the same but with .mkv files aswell!

as i mentioned in my post above, you can add as many different extensions in the INI file. just exit subdude, edit the ini file and start again.

[Formats]
video=avi;mpg;mpeg;rmvb;asf;asx;mkv
subtitles=srt;txt;sub;nfo;tbn;jpg
Sorry for my ignorance, now it works with mkv files.
Title: Re: SubDude, a subtitle renaming program
Post by: jonker1541 on December 19, 2009, 10:07 AM
ak, I have a suggestion, just in case you decide to tweak the app a little in the future. I figured it wouldn't be to much work to implement. My suggestion is to add the option of naming the avi files after the srt's. Cause the srt's I download are very often nicely labelled with episode names and everything, and the avi files you get on torrent or often very messy in their naming.

However, I understand if your priorities have shifted to other projects. Just wanted to let you know people still use and enjoy subdude.