A little script that i made (rename tv-shows)
#1
I got fed up with most of my tv-episodes hade the wrong episodenumber in there names (ppl seams to improvise pretty much on what number should be using) and the library in XBMC gets realy messy.

I tossed together my first pythonscript ever (not pretty but it works ;P)

What it does is that it scans a dir and checks the Episodename on tvdb, creates a Seriename/Season #/ in the destinationdir and renames the file to correct naming (in my case: S#E#.Episode.Name).
No errorhandling at all and the code is abit messy (was reading alot of tutorials and api-docs while writing this).

Well well.. hope anyone got some use for it.

http://www.otherland.nu/projects/fixmese...eseries.py

(Dunno if this is the correct forum to put it in)
Reply
#2
Please consider using os.path.join to create dir/file names instead of "dir/" + "anotherdir"

also use os.sep to get the separator (if you need to), it will get the path separator for the os running on.

This way you ensure it's runnable on both linux, windows and xbox.
Reply
#3
ah nice, thanks for the tip, still learning Wink
Reply
#4
updated
Reply
#5
Updated to 0.02.

Changelog:
** Made it class-based.
** Added Copyright info
** Fixed some minor buggs
** Made a better usage display
** Added operator -v: Will do a detailed ouput
** Added operator -m: User kan make their own rename masks.
** Added operator -n: Don't create season directorys in target
** Added operator -c: Will only do a checkup, will not rename or move files.


Code:
    fixmeseries.py 0.02 - Simple-to-use batch renamer of tv-series. Checks for episodenames in filenames and tries to do a lookp agains tvtdb-database (www.tvdb.com) for information and move/rename the file to correct season- and episode-number
    
    Copyright (C) 2008 Ztripez Hellström ([email protected])
    
    This program comes with ABSOLUTELY NO WARRANTY; it may be copied or modified
    under the terms of the GNU General Public License version 2 as published by
    the Free Software Foundation.
    
    Usage fixmeseries.py [options] WORKDIR TARGETDIR
    -h --help        Prints this
    -v --verbose        Detailed output
    -n --nodir        Don't create season directorys in TARGETDIR
    -c --check        Will only do a lookup, will not move/rename the files
    -m --mask(format)    Format string on how the file will be renamed. Defaul mask is [p].S[s]E[e].[t].[x]
                Formatoptions:
                [p]: Series title
                [s]: Season number
                [e]: Episode number
                [t]: Episode title
                [x]: File extension, without the begining dot (ex: avi)
                Unrecognized characters in the format string will be printed as-is
                
                Ex:
                --mask [p].S[s]E[e].[t].[x] will output Futurama.S3E4.Parasites Lost.avi

http://www.otherland.nu/projects/fixmese...eseries.py
Reply
#6
can you provide a working example?

i don't quite get what to put in the working dir and the target dir
Reply
#7
Oh of cause

Lets use Futurama as an example.

1. Make a dir called Futurama somewhere (ex /home/ztripez/Futurama)

2. Copy/move all episodes you whant to fix into that dir (the script dosen't look in subdirs atm).

3. Run some kind of batch rename to make all filenames lowercases.

4. Create a target dir somewhere (but you don't need to create a Futurama dir, the script makes that for you)

5. Run the script (i suggest you run it with the -c and v flag first so you don't mess things up on the first run)

ex. ./fixmeseries -cv /home/ztripez/series/Futurama /home/series/fixed

5. If you are happy with the result; Run the script again without the -c flag.

The script will use the Workingsdir as name of the serie in the Lookup.
It will also create a Futurama dir in the target dir.

If you use the -v flag the script will output what it does and you can se if you get any matches.

Rember that the script only checks for Serie/Episode-name with a 100% match.

As you can se the script is lacking some abilites and i'll be happy to get suggestions on improvment.

Hope this made things abit clearer (if not i'll try to explain again later, i'm in middle of a hangover atm)
Reply
#8
So what does this error message mean?
"media was not found, creating"

c:\Python25>fixmeseries.py -v "C:\media\road runner" "C:\media\road runner\fixed
"
Trying to get ID for media
Fetching: http://www.thetvdb.com/api/GetSeries.php...name=media
ID: 82616
Fetching: http://www.thetvdb.com/api/ADA280576227F...all/en.xml
Parsing episodes

Does the script use the top level folder for showname matching?


This is not matching for me, what am I doing wrong?

Filename:
road runner - beep beep - 1952.mpg

Input:
c:\Media>fixmeseries.py -v "road runner" "road runner\fixed"

Output:
Trying to get ID for road+runner
Fetching: http://www.thetvdb.com/api/GetSeries.php...oad+runner
ID: 77600
Fetching: http://www.thetvdb.com/api/ADA280576227F...all/en.xml
Parsing episodes
Looking for episode: Beep Beep
road runner*Beep?Beep*.*
road runner*beep?beep*.*
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#9
Heh Smile Nice job :-) I've done almost exactly same script by myself but in perl Smile

Anyway, there is an another tool for that on pypi: http://pypi.python.org/pypi?:action=sear...mit=search
Reply
#10
Nice job :-) I've done almost exactly same script by myself but in perl Smile

Anyway, there is an another tool for that on pypi: http://pypi.python.org/pypi?:action=sear...mit=search
Reply

Logout Mark Read Team Forum Stats Members Help
A little script that i made (rename tv-shows)0