Anime TheTVDB Rename Script
Posted: December 4th, 2008, 8:36 am
I'd like to share my post-proccessing that renames anime files in a directory to a proper to be scraped tv episode for use in for example XBMC.
Anime Rename Script 1.0
Transforms
[Conclave-Mendoi]_Mobile_Suit_Gundam_00_S2_-_02_[1280x720_H.264_AAC][C1A7E11B].mkv
to
[Conclave-Mendoi]_Mobile_Suit_Gundam_00_S2_-_02_[1280x720_H.264_AAC][C1A7E11B].S02E02.mkv
It searches www.thetvdb.com for the show and absolute episode number and renames the file accordingly.
It can handle subdirectories and only handles .mkv/.avi/.mp4 files.
Help output:
Anime Rename script v1.0
Searches directory recursively for .mkv/.avi/.mp4 video files.
When found it tries to find the season and episode on www.thetvdb.com to rename
the file so it can be correctly scraped by XBMC's TvDB scraper.
Can be used for SABnzbd and or as standalone script
Requires:
- PHP-CLI (ubuntu apt-get install php5-cli)
- Correct permissions.
Could work for windows not tested.
Example command:
php -f procanime.php -- '/storage/Anime/Mobile Suit Gundam 00/'
How to install?
Unfortunately this is a php script.
So you have to install php5-cli (apt-get install php5-cli) to use the phpscript.
Shell script:
Create a file procanime.sh and give it proper permissions.
Copy these three lines to it:
#!/bin/bash
# $1 (source path) is provided by sabnzbd+ upon execution
php -f procanime.php -- $1
PHP script:
Download the php script from http://pastebin.com/f126072bd
Rename it to procanime.php
Give it proper permissions.
And your ready to go!
Here's an example:
[DB]_Bleach_196_[3FDE9706].avi
Show name: Bleach 196
Possible season number:
Episode number: 196
Clean Show Name: Bleach
TheTVDB Series Name: Bleach
TheTVDB Series ID: 74796
TheTVDB Series Season: 9
TheTVDB Series Episode: 7
SUCCESS, Renamed from /storage/Anime/Bleach/[DB]_Bleach_196_[3FDE9706].avi to /storage/Anime/Bleach/[DB]_Bleach_196_[3FDE9706].S09E07.avi
[DB]_Bleach_197_[6578B411].avi
Show name: Bleach 197
Possible season number:
Episode number: 197
Clean Show Name: Bleach
TheTVDB Series Name: Bleach
TheTVDB Series ID: 74796
TheTVDB Series Season: 9
TheTVDB Series Episode: 8
SUCCESS, Renamed from /storage/Anime/Bleach/[DB]_Bleach_197_[6578B411].avi to /storage/Anime/Bleach/[DB]_Bleach_197_[6578B411].S09E08.avi
[gSS]_Gundam_00_S2_-_08_[1D99B542].mkv
Show name: Gundam 00 S2 08
Possible season number: 2
Episode number: 08
Clean Show Name: Gundam 00
TheTVDB Series Name: Mobile Suit Gundam 00
TheTVDB Series ID: 80675
TheTVDB Series Season: 2
TheTVDB Series Episode: 08
SUCCESS, Renamed from /storage/Anime/Mobile Suit Gundam 00/Season 2/[gSS]_Gundam_00_S2_-_08_[1D99B542].mkv to /storage/Anime/Mobile Suit Gundam 00/Season 2/[gSS]_Gundam_00_S2_-_08_[1D99B542].S02E08.mkv
Things to know:
1. It only renames if there is no 'S02E08' tag in the filename, it also returns an error if the anime can't be found on www.thetvdb.com same with the absolute episode number.
2. It doesn't find your show or episode? then add it to www.thetvdb.com!
3. It doesn't handle double episodes yet, something for the near future
If you use this script in your own package or script please send me an email
Greetz
Anime Rename Script 1.0
Transforms
[Conclave-Mendoi]_Mobile_Suit_Gundam_00_S2_-_02_[1280x720_H.264_AAC][C1A7E11B].mkv
to
[Conclave-Mendoi]_Mobile_Suit_Gundam_00_S2_-_02_[1280x720_H.264_AAC][C1A7E11B].S02E02.mkv
It searches www.thetvdb.com for the show and absolute episode number and renames the file accordingly.
It can handle subdirectories and only handles .mkv/.avi/.mp4 files.
Help output:
Anime Rename script v1.0
Searches directory recursively for .mkv/.avi/.mp4 video files.
When found it tries to find the season and episode on www.thetvdb.com to rename
the file so it can be correctly scraped by XBMC's TvDB scraper.
Can be used for SABnzbd and or as standalone script
Requires:
- PHP-CLI (ubuntu apt-get install php5-cli)
- Correct permissions.
Could work for windows not tested.
Example command:
php -f procanime.php -- '/storage/Anime/Mobile Suit Gundam 00/'
How to install?
Unfortunately this is a php script.
So you have to install php5-cli (apt-get install php5-cli) to use the phpscript.
Shell script:
Create a file procanime.sh and give it proper permissions.
Copy these three lines to it:
#!/bin/bash
# $1 (source path) is provided by sabnzbd+ upon execution
php -f procanime.php -- $1
PHP script:
Download the php script from http://pastebin.com/f126072bd
Rename it to procanime.php
Give it proper permissions.
And your ready to go!
Here's an example:
[DB]_Bleach_196_[3FDE9706].avi
Show name: Bleach 196
Possible season number:
Episode number: 196
Clean Show Name: Bleach
TheTVDB Series Name: Bleach
TheTVDB Series ID: 74796
TheTVDB Series Season: 9
TheTVDB Series Episode: 7
SUCCESS, Renamed from /storage/Anime/Bleach/[DB]_Bleach_196_[3FDE9706].avi to /storage/Anime/Bleach/[DB]_Bleach_196_[3FDE9706].S09E07.avi
[DB]_Bleach_197_[6578B411].avi
Show name: Bleach 197
Possible season number:
Episode number: 197
Clean Show Name: Bleach
TheTVDB Series Name: Bleach
TheTVDB Series ID: 74796
TheTVDB Series Season: 9
TheTVDB Series Episode: 8
SUCCESS, Renamed from /storage/Anime/Bleach/[DB]_Bleach_197_[6578B411].avi to /storage/Anime/Bleach/[DB]_Bleach_197_[6578B411].S09E08.avi
[gSS]_Gundam_00_S2_-_08_[1D99B542].mkv
Show name: Gundam 00 S2 08
Possible season number: 2
Episode number: 08
Clean Show Name: Gundam 00
TheTVDB Series Name: Mobile Suit Gundam 00
TheTVDB Series ID: 80675
TheTVDB Series Season: 2
TheTVDB Series Episode: 08
SUCCESS, Renamed from /storage/Anime/Mobile Suit Gundam 00/Season 2/[gSS]_Gundam_00_S2_-_08_[1D99B542].mkv to /storage/Anime/Mobile Suit Gundam 00/Season 2/[gSS]_Gundam_00_S2_-_08_[1D99B542].S02E08.mkv
Things to know:
1. It only renames if there is no 'S02E08' tag in the filename, it also returns an error if the anime can't be found on www.thetvdb.com same with the absolute episode number.
2. It doesn't find your show or episode? then add it to www.thetvdb.com!
3. It doesn't handle double episodes yet, something for the near future
If you use this script in your own package or script please send me an email
Greetz