filebot/website/script.html
Reinhard Pointner 5b839d1ca8 * update samples
2013-10-17 07:11:32 +00:00

334 lines
22 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" itemscope itemtype="http://schema.org/Product">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="keywords" content="rename tv shows, rename movies, download subtitles, check sfv files" />
<title>Scripts and Automation</title>
<meta name="description" content="FileBot scripting allows to easily write scripts for any kind of automation in Groovy. There is no limits. Extract archives, download subtitles, rename episodes, fetch artwork and banners and delete left-behind clutter. All in one go." />
<meta itemprop="name" content="FileBot Scripting and Automation" />
<meta itemprop="description" content="FileBot scripting allows to easily write scripts for any kind of automation in Groovy. There is no limits. Extract archives, download subtitles, rename episodes, fetch artwork and banners and delete left-behind clutter. All in one go." />
<meta itemprop="image" content="http://www.filebot.net/images/icon.png" />
<link rel="stylesheet" href="base.css" type="text/css" />
<link rel="stylesheet" href="code.css" type="text/css" />
<link rel="icon" href="favicon.png" />
<!-- google analytics -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-25379256-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<!-- google +1 -->
<script type="text/javascript">
window.___gcfg = {lang: 'en-GB'};
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
<!-- twitter -->
<script type="text/javascript">
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
</script>
</head>
<body>
<!-- Facebook Like Button-->
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="adsense sidead first">
<script type="text/javascript">
<!--
google_ad_client = "ca-pub-2833958633371388";
google_ad_slot = "1531354934";
google_ad_width = 160;
google_ad_height = 600;
//-->
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<div class="adsense sidead second">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-2833958633371388";
/* FileBot SideAd Wide 2 */
google_ad_slot = "5493651869";
google_ad_width = 160;
google_ad_height = 600;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<div class="page">
<div class="navigation">
<div>
<ul>
<li><a href="http://www.filebot.net/forums/">Forums</a></li>
<li><a href="http://www.filebot.net/forums/viewtopic.php?f=3&amp;t=7">FAQ</a></li>
<li><a href="http://www.filebot.net/#download">Download</a></li>
</ul>
</div>
</div>
<div class="social">
<div class="twitter">
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.filebot.net/" data-text="FileBot - The ultimate tv renamer and subtitle downloader" data-via="filebot_renamer" data-lang="en"></a>
</div>
<div class="facebook">
<div class="fb-like" data-href="https://www.facebook.com/filebot" data-send="false" data-layout="button_count" data-width="80" data-show-faces="false"></div>
</div>
<div class="plusone">
<g:plusone callback="_gaq.push(['_trackEvent','Social networking','Google Plus One',document.title])" href="http://www.filebot.net/"></g:plusone>
</div>
</div>
<div class="header">
<a href="http://www.filebot.net"><img class="logo" alt="logo" src="images/icon.png" width="48" height="48" /></a>
<h1>
Scripts and Automation
<span class="description">Scripting interface usage manual</span>
</h1>
</div>
<div class="content">
<div class="section screenshot" style="border:none; box-shadow:none; background:white; margin-left: 20px">
<a href="http://www.filebot.net/scripts/" target="_blank"><img alt="See Examples" src="images/script.png" /></a>
<span class="quote">Anything is possible</span>
</div>
<div class="section about">
<h2>About</h2>
<p>
FileBot makes scripting and automation as easy as it gets. Just script everything in <a href="http://groovy.codehaus.org">Groovy</a>
instead of bothering with cumbersome cmd and bash scripts. It's the same on all platforms and much more powerful.
The provided <a href="#functions">functions</a> are the same as in the <a href="cli.html">CLI</a> and <a href="cli.html#arguments">parameter usage</a>
is also exactly the same.
</p>
<h2 id="examples">Examples</h2>
<h3 id="examples">Running Scripts</h3>
<p>
<code><span class="cmd">filebot</span> <span class="option">-script</span> <span class="argument">"path/to/script.groovy"</span> <span class="argument">args...</span></code>
Execute a given Groovy script. Parameters defined on the cmdline when starting a script will serve as default parameters
while running that script.
</p>
<h3>Script Repository</h3>
<div class="description">
Find scripts for common tasks <a href="http://www.filebot.net/forums/viewtopic.php?f=4&amp;t=5#p5">here</a>. You can just use these scripts straight
away or as a reference for building your own more advanced scripts. If you wrote a really useful script
please <a href="http://www.filebot.net/forums/viewtopic.php?f=4&amp;t=5">share it with us</a>.
</div>
<div style="margin: 12px 300px 20px 25px; padding: 5px; border: thin dotted lavender; background: #FDFDFF">
<span style="text-decoration: underline">Script Index:</span>
<ul style="margin: 0px"><li><a class="postlink" href="http://www.filebot.net/forums/viewtopic.php?f=4&amp;t=5#p802">µTorrent Integration</a></li><li><a class="postlink" href="http://www.filebot.net/forums/viewtopic.php?f=4&amp;t=5#p204">Fetch Artwork and Nfo for TV Shows</a></li><li><a class="postlink" href="http://www.filebot.net/forums/viewtopic.php?f=4&amp;t=5#p205">Fetch Artwork and Nfo for Movies</a></li><li><a class="postlink" href="http://www.filebot.net/forums/viewtopic.php?f=4&amp;t=5#p1341">The Cleaner - Delete left over files and folders</a></li><li><a class="postlink" href="http://www.filebot.net/forums/viewtopic.php?f=4&amp;p=2629#p2629">MyEpisodes.com Integration</a></li><li><a class="postlink" href="http://www.filebot.net/forums/viewtopic.php?f=4&amp;t=5#p53">Media Index CSV</a></li><li><a class="postlink" href="http://www.filebot.net/forums/viewtopic.php?f=4&amp;t=5#p2459">Query Rename History</a></li><li><a class="postlink" href="http://www.filebot.net/forums/viewtopic.php?f=4&amp;t=5#p2485">Revert Renamed Files to their Original Names</a></li><li><a class="postlink" href="http://www.filebot.net/forums/viewtopic.php?f=4&amp;t=5#p2211">Rename All Media Folder by Folder</a></li><li><a class="postlink" href="http://www.filebot.net/forums/viewtopic.php?f=4&amp;t=5#p512">Auto-Sort Tivo Recordings</a></li><li><a class="postlink" href="http://www.filebot.net/forums/viewtopic.php?f=4&amp;t=5#p52">Sort out TV Download Folder</a></li><li><a class="postlink" href="http://www.filebot.net/forums/viewtopic.php?f=4&amp;t=5#p132">Watch folder and rename new episodes</a></li><li><a class="postlink" href="http://www.filebot.net/forums/viewtopic.php?f=4&amp;t=5#p2100">Filename: Find &amp; Replace</a></li></ul>
</div>
<h3 id="examples">Example Scripts</h3>
<div class="description">
<pre><code>args.<span class="method">eachMediaFolder</span> {
<span class="method">getMissingSubtitles</span>(<span class="property">folder</span>:it)
<span class="method">rename</span>(<span class="property">folder</span>:it)
<span class="method">compute</span>(<span class="property">file</span>:it.<span class="method">listFiles</span>{ it.<span class="method">isVideo</span>() })
}</code></pre>Fetch subtitles, rename and compute checksums for all media folders in the file hierarchy.</div>
<div class="description">
<pre><code>[<span class="string">'E:/TV Shows'</span> as File].<span class="method">eachMediaFolder</span>{ <span class="method">rename</span>(<span class="property">folder</span>:it, <span class="property">db</span>:<span class="string">'TheTVDB'</span>) }
[<span class="string">'E:/Anime'</span> as File].<span class="method">eachMediaFolder</span>{ <span class="method">rename</span>(<span class="property">folder</span>:it, <span class="property">db</span>:<span class="string">'AniDB'</span>) }
[<span class="string">'E:/Movies'</span> as File].<span class="method">eachMediaFolder</span>{ <span class="method">rename</span>(<span class="property">folder</span>:it, <span class="property">db</span>:<span class="string">'TheMovieDB'</span>) }
</code></pre>Run rename on different folder hierarchies using different episode/movie datasources.</div>
<div class="description">
<pre><code>args.<span class="method">getFiles</span>{ it.<span class="method">isVideo</span>() }
.<span class="method">sort</span>{ a, b -> a.name.<span class="method">compareTo</span>(b.name) }
.<span class="method">each</span>{ println <span class="method">getMediaInfo</span>(<span class="property">file</span>:it, <span class="property">format</span>:<span class="string">'{fn} [{vf} {vc} {af}]'</span>) }
</code></pre>Print media info for all video files using the given format pattern.</div>
<div class="adsense adbox">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-2833958633371388";
/* FileBot Homepage MedBox */
google_ad_slot = "7829099391";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<h2 class="reference" id="functions">
Function Reference
<a href="https://sourceforge.net/p/filebot/code/HEAD/tree/trunk/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy?force=True" class="source" target="_blank">source</a>
</h2>
<div class="documentation">
<h4>Rename media files</h4>
<pre><span class="return">File[]</span> <span class="method">rename</span>(<span class="property">folder</span>|<span class="property">file</span>, <span class="property">query</span>, <span class="property">output</span>, <span class="property">format</span>, <span class="property">db</span>, <span class="property">lang</span>, <span class="property">strict</span>)</pre>
<div class="text">Match files with episode/movie data and rename according to given naming scheme.</div>
<dl>
<dt>Parameters:</dt>
<dd><span class="property">folder</span> - process media files in this folder</dd>
<dd><span class="property">file</span> - process these media files</dd>
<dd><span class="property">action</span> - rename action name or closure</dd>
<dd><span class="property">conflict</span> - define conflict handling</dd>
<dd><span class="property">output</span> - output folder, if format expression is not absolute</dd>
<dd><span class="property">format</span> - episode/movie naming scheme</dd>
<dd><span class="property">db</span> - episode/movie database</dd>
<dd><span class="property">query</span> - force series/movie name, auto-detect if not set</dd>
<dd><span class="property">sortOrder</span> - episode sort order</dd>
<dd><span class="property">filter</span> - episode filter expression</dd>
<dd><span class="property">lang</span> - preferred language for episode/movie titles</dd>
<dd><span class="property">strict</span> - turn on/off strict matching</dd>
</dl>
</div>
<div class="documentation">
<h4>Fetch subtitles for media files</h4>
<pre><span class="return">File[]</span> <span class="method">getSubtitles</span>(<span class="property">folder</span>|<span class="property">file</span>, <span class="property">query</span>, <span class="property">lang</span>, <span class="property">output</span>, <span class="property">encoding</span>, <span class="property">strict</span>)</pre>
<div class="text">
Download subtitles for the given files. Lookup subtitles via hash or match by filename. If you only want to download
missing subtitles you should use <pre style="font-size:inherit;display:inline"><span class="method">getMissingSubtitles</span></pre>
so subtitles that have already been downloaded will not be downloaded again overridding existing subtitle files.
</div>
<dl>
<dt>Parameters:</dt>
<dd><span class="property">folder</span> - process media files in this folder</dd>
<dd><span class="property">file</span> - process these media files</dd>
<dd><span class="property">db</span> - database filter expression (e.g. opensubtitles|subscene)</dd>
<dd><span class="property">query</span> - lookup subtitles by series/movie name</dd>
<dd><span class="property">lang</span> - subtitle language</dd>
<dd><span class="property">output</span> - force output format (e.g. srt)</dd>
<dd><span class="property">encoding</span> - force output charset</dd>
<dd><span class="property">strict</span> - enable matching subtitles via filename</dd>
</dl>
</div>
<div class="documentation">
<h4>File verification</h4>
<pre><span class="return">boolean</span> <span class="method">check</span>(<span class="property">folder</span>|<span class="property">file</span>)</pre>
<div class="text">Check given sfv/md5/sha1 files.</div>
<dl>
<dt>Parameters:</dt>
<dd><span class="property">folder</span> - check the sfv/md5/sha1 files in this folder</dd>
<dd><span class="property">file</span> - check these sfv/md5/sha1</dd>
</dl>
<hr/>
<pre><span class="return">File</span> <span class="method">compute</span>(<span class="property">folder</span>|<span class="property">file</span>, <span class="property">output</span>, <span class="property">encoding</span>)</pre>
<div class="text">Compute sfv/md5/sha1 for the given files.</div>
<dl>
<dt>Parameters:</dt>
<dd><span class="property">folder</span> - compute checksums for files in this folder</dd>
<dd><span class="property">file</span> - compute checksums for these files</dd>
<dd><span class="property">output</span> - absolute or relative output file or just output format (sfv, md5 or sha1)</dd>
<dd><span class="property">encoding</span> - output charset, defaults to UTF-8</dd>
</dl>
</div>
<div class="documentation">
<h4>Other</h4>
<pre><span class="return">File[]</span> <span class="method">extract</span>(<span class="property">folder</span>|<span class="property">file</span>, <span class="property">output</span>)</pre>
<div class="text">Extract files from single-volume or multi-volume archives (.zip, .rar, .7z, etc).</div>
<dl>
<dt>Parameters:</dt>
<dd><span class="property">folder</span> - extract all archives that are in this folder</dd>
<dd><span class="property">file</span> - extract this archive</dd>
<dd><span class="property">output</span> - output folder, defaults to archive path</dd>
<dd><span class="property">conflict</span> - define conflict handling</dd>
</dl>
<hr/>
<pre><span class="return">String[]</span> <span class="method">fetchEpisodeList</span>(<span class="property">query</span>, <span class="property">format</span>, <span class="property">db</span>, <span class="property">lang</span>)</pre>
<div class="text">Fetch episode data for the given tv show and format episode names.</div>
<dl>
<dt>Parameters:</dt>
<dd><span class="property">query</span> - tv series name</dd>
<dd><span class="property">format</span> - episode naming scheme</dd>
<dd><span class="property">db</span> - episode database</dd>
<dd><span class="property">sortOrder</span> - episode sort order</dd>
<dd><span class="property">lang</span> - preferred language for episode titles</dd>
</dl>
<hr/>
<pre><span class="return">String</span> <span class="method">getMediaInfo</span>(<span class="property">file</span>, <span class="property">format</span>)</pre>
<div class="text">Get mediainfo as defined by the given format.</div>
<dl>
<dt>Parameters:</dt>
<dd><span class="property">file</span> - get info for this file</dd>
<dd><span class="property">format</span> - media naming scheme</dd>
</dl>
</div>
<div class="documentation">
<h4>Extras</h4>
<div>
<a href="https://sourceforge.net/p/filebot/code/HEAD/tree/trunk/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy?force=True" target="_blank">ScriptShell.lib.groovy</a> also defines lots extra useful functions
and there is example code in the <a href="http://www.filebot.net/scripts/">script repository</a>.
</div>
</div>
</div>
<p class="suggestion">
Need some help getting started? Check the <a href="http://www.filebot.net/forums/viewforum.php?f=4">forums</a>.
</p>
<div class="metrics">
<script type="text/javascript" src="http://www.ohloh.net/p/16945/widgets/project_partner_badge.js"></script>
</div>
<div class="footer">
<div id="flattr">
<!-- flattr -->
<script type="text/javascript">
/* <![CDATA[ */
(function() {
var s = document.createElement('script'), t = document.getElementsByTagName('script')[0];
s.type = 'text/javascript';
s.async = true;
s.src = 'http://api.flattr.com/js/0.6/load.js?mode=auto';
t.parentNode.insertBefore(s, t);
})();
/* ]]> */
</script>
<a class="FlattrButton" rev="flattr;button:compact;" href="http://www.filebot.net"></a>
</div>
<div id="donate">
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="display:inline" target="_blank">
<input type="hidden" name="cmd" value="_s-xclick" />
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHNwYJKoZIhvcNAQcEoIIHKDCCByQCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYBOY1pI25A2C4SZ+iVDHkFo19SvO81rJPwLrh+e13RWDAg+qbo4HbMgbyhiAT+rYw+8nD7Iegs7A2IZJ2Fc5B2Z7qBTfAjjin6HbEyuJTdbZUBbosYAiihhutTkSR94tWbNqH9Fpvl502zutMviTRcAy4EGQfTcQP3TQmLZC9cxxTELMAkGBSsOAwIaBQAwgbQGCSqGSIb3DQEHATAUBggqhkiG9w0DBwQIwkN+XtfUJTmAgZDp17/1C1h5m7tGRoMTdffNByh5GElib5j+wWtZQbvAms/t/6y7PGRGNp3Ad7W31caczjF4e4jso5gAxAVlAOyfB1o9xB/IjNoSf/5v6cIByR6TQROIdq+2zUAZ5zSsnnlLX0JjUD+8pHGB3AdsQxmnW5v7i1onpVdB9YYFgriqYNPycDC8cJyzShUR2AJ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dgIONth+8kSK//Y/4ihuE4Ymvzn5ceE3S/iBSQQMjyvb+s2TWbQYDwcp129OPIbD9epdr4tJOUNiSojw7BHwYRiPh58S1xGlFgHFXwrEBb3dgNbMUa+u4qectsMAXpVHnD9wIyfmHMYIBmjCCAZYCAQEwgZQwgY4xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLUGF5UGFsIEluYy4xEzARBgNVBAsUCmxpdmVfY2VydHMxETAPBgNVBAMUCGxpdmVfYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwuY29tAgEAMAkGBSsOAwIaBQCgXTAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0xMDExMDgwNzE1MjlaMCMGCSqGSIb3DQEJBDEWBBQxOz+EhIKN690rQ57KLzHBZDiMEzANBgkqhkiG9w0BAQEFAASBgCa61dPlT6Y8ZQSkQs8DXuuGFqZhTPVCp6wAx0qyDhNi6rAdPsOQwoBiUEEFz327g7rUn+HcCVBGqEwv4ExMrZThz9ZHROWc9PbAC1dHHtrrA3SInH0HpIZG5RgDhLcgH1agjGbGGv4k/eKr9Bffte3kf6l3Qd92ZX5AUS1Rf/dD-----END PKCS7-----" />
<input onclick="_gaq.push(['_trackPageview', '/donate/paypal'])" type="image" src="images/donate.png" name="submit" alt="PayPal - The safer, easier way to pay online." />
</form>
</div>
Hosted on <a href="http://sourceforge.net/projects/filebot/">sourceforge.net</a> | Creative Commons License: Attribution-NonCommercial-ShareAlike © 2012
</div>
</div>
</div>
</body>
</html>