1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-24 16:58:51 -05:00

* refactoring

This commit is contained in:
Reinhard Pointner 2011-11-30 05:23:43 +00:00
parent 549209ac9c
commit 2bf8270b17
3 changed files with 34 additions and 43 deletions

View File

@ -62,10 +62,6 @@ def execute(String... args) {
} }
// Script helper
def require(cond) { if (!cond()) throw new Exception('Require failed') }
// CLI bindings // CLI bindings
def rename(args) { args = _defaults(args) def rename(args) { args = _defaults(args)
_guarded { _cli.rename(_files(args), args.query, args.format, args.db, args.lang, args.strict) } _guarded { _cli.rename(_files(args), args.query, args.format, args.db, args.lang, args.strict) }

View File

@ -2,141 +2,124 @@
<media-types> <media-types>
<!-- Application --> <!-- Application -->
<type name="application/torrent"> <type name="application/torrent">
<extension>torrent</extension> <extension>torrent</extension>
<extension>tor</extension> <extension>tor</extension>
</type> </type>
<type name="application/list"> <type name="application/list">
<extension>list</extension> <extension>list</extension>
<extension>txt</extension> <extension>txt</extension>
</type> </type>
<type name="application/nfo"> <type name="application/nfo">
<extension>nfo</extension> <extension>nfo</extension>
</type> </type>
<!-- Verification --> <!-- Verification -->
<type name="verification/sfv"> <type name="verification/sfv">
<extension>sfv</extension> <extension>sfv</extension>
</type> </type>
<type name="verification/md5sum"> <type name="verification/md5sum">
<extension>md5</extension> <extension>md5</extension>
</type> </type>
<type name="verification/sha1sum"> <type name="verification/sha1sum">
<extension>sha1</extension> <extension>sha1</extension>
<extension>sha</extension> <extension>sha</extension>
</type> </type>
<!-- Archives -->
<type name="archive/zip">
<extension>zip</extension>
</type>
<type name="archive/rar">
<extension>rar</extension>
</type>
<type name="archive/gzip">
<extension>gzip</extension>
<extension>gz</extension>
</type>
<type name="archive/tar">
<extension>tar</extension>
</type>
<!-- Audio --> <!-- Audio -->
<type name="audio/mp3"> <type name="audio/mp3">
<extension>mp3</extension> <extension>mp3</extension>
</type> </type>
<type name="audio/mp4"> <type name="audio/mp4">
<extension>mp4</extension> <extension>mp4</extension>
<extension>m4a</extension> <extension>m4a</extension>
</type> </type>
<type name="audio/flac"> <type name="audio/flac">
<extension>flac</extension> <extension>flac</extension>
</type> </type>
<type name="audio/wma"> <type name="audio/wma">
<extension>wma</extension> <extension>wma</extension>
</type> </type>
<type name="audio/ogg"> <type name="audio/ogg">
<extension>ogg</extension> <extension>ogg</extension>
</type> </type>
<!-- Video --> <!-- Video -->
<type name="video/avi"> <type name="video/avi">
<extension>avi</extension> <extension>avi</extension>
</type> </type>
<type name="video/mkv"> <type name="video/mkv">
<extension>mkv</extension> <extension>mkv</extension>
</type> </type>
<type name="video/ogm"> <type name="video/ogm">
<extension>ogm</extension> <extension>ogm</extension>
</type> </type>
<type name="video/mp4"> <type name="video/mp4">
<extension>mp4</extension> <extension>mp4</extension>
<extension>m4v</extension> <extension>m4v</extension>
</type> </type>
<type name="video/mov"> <type name="video/mov">
<extension>mov</extension> <extension>mov</extension>
</type> </type>
<type name="video/divx"> <type name="video/divx">
<extension>divx</extension> <extension>divx</extension>
</type> </type>
<type name="video/mpeg"> <type name="video/mpeg">
<extension>mpg</extension> <extension>mpg</extension>
<extension>mpeg</extension> <extension>mpeg</extension>
<extension>ts</extension> <extension>ts</extension>
</type> </type>
<type name="video/wmv"> <type name="video/wmv">
<extension>wmv</extension> <extension>wmv</extension>
</type> </type>
<type name="video/flash"> <type name="video/flash">
<extension>flv</extension> <extension>flv</extension>
</type> </type>
<type name="video/realmedia"> <type name="video/realmedia">
<extension>rm</extension> <extension>rm</extension>
<extension>rmvb</extension> <extension>rmvb</extension>
</type> </type>
<type name="video/tivo"> <type name="video/tivo">
<extension>tivo</extension> <extension>tivo</extension>
</type> </type>
<type name="video/WindowsRecordedTV"> <type name="video/WindowsRecordedTV">
<extension>wtv</extension> <extension>wtv</extension>
</type> </type>
<!-- Subtitles --> <!-- Subtitles -->
<type name="subtitle/SubRip"> <type name="subtitle/SubRip">
<extension>srt</extension> <extension>srt</extension>
</type> </type>
<type name="subtitle/MicroDVD"> <type name="subtitle/MicroDVD">
<extension>sub</extension> <extension>sub</extension>
</type> </type>
<type name="subtitle/SubViewer"> <type name="subtitle/SubViewer">
<extension>sub</extension> <extension>sub</extension>
</type> </type>
<type name="subtitle/SubStationAlpha"> <type name="subtitle/SubStationAlpha">
<extension>ssa</extension> <extension>ssa</extension>
<extension>ass</extension> <extension>ass</extension>
</type> </type>
<type name="subtitle/SAMI"> <type name="subtitle/SAMI">
<extension>smi</extension> <extension>smi</extension>
<extension>sami</extension> <extension>sami</extension>
</type> </type>
<type name="subtitle/VobSub"> <type name="subtitle/VobSub">
<extension>sub</extension> <extension>sub</extension>
<extension>idx</extension> <extension>idx</extension>

View File

@ -5,18 +5,30 @@ def movieDir = "X:/in/Movies"
def episodeFormat = "X:/out/TV/{n}{'/Season '+s}/{episode}" def episodeFormat = "X:/out/TV/{n}{'/Season '+s}/{episode}"
def movieFormat = "X:/out/Movies/{movie}/{movie}" def movieFormat = "X:/out/Movies/{movie}/{movie}"
def exclude(f) { f =~ /\p{Punct}(chunk|part)/ } def incomplete(f) { f =~ /[.]chunk|[.]part$/ }
// run cmdline unrar (require -trust-script) // run cmdline unrar (require -trust-script) on multi-volume rar files (foo.part1.rar, foo.part2.rar, ...)
[episodeDir, movieDir].getFiles().findAll{ !exclude(it) && it.hasExtension('rar') }.each { [episodeDir, movieDir].getFiles().findAll{ it =~ /[.]part01[.]rar$/ }.each { rarP1 ->
execute("unrar", "x", "-y", it.getAbsolutePath(), it.getPathWithoutExtension() + "/") // extract name from name.part01.rar
def name = rarP1.getName()[0 .. -12];
// find all volumes of the same name
def volumes = rarP1.getParentFile().listFiles{ it.getName().startsWith(name) && it =~ /[.]part\d{2}[.]rar/ }
// find all incomplete volumes
def incomplete = volumes.findAll{ incomplete(it) }
// all volumes complete, call unrar on first volume
if (incomplete.isEmpty()) {
execute("unrar", "x", "-y", "-p-", rarP1.getAbsolutePath(), rarP1.getPathWithoutExtension() + "/")
}
} }
/* /*
* Fetch subtitles and sort into folders * Fetch subtitles and sort into folders
*/ */
episodeDir.eachMediaFolder() { dir -> episodeDir.eachMediaFolder() { dir ->
def files = dir.listFiles { !exclude(it) } def files = dir.listFiles { !incomplete(it) }
// fetch subtitles // fetch subtitles
files += getSubtitles(file:files) files += getSubtitles(file:files)
@ -26,7 +38,7 @@ episodeDir.eachMediaFolder() { dir ->
} }
movieDir.eachMediaFolder() { dir -> movieDir.eachMediaFolder() { dir ->
def files = dir.listFiles { !exclude(it) } def files = dir.listFiles { !incomplete(it) }
// fetch subtitles // fetch subtitles
files += getSubtitles(file:files) files += getSubtitles(file:files)