This is my script.
Code: Select all
import sys
import subprocess
# configuration
output = 'D:/Plex Media Server'
# custom formats (use / instead of \ as directory separator)
movieFormat = "D:/Plex Media Server/Movies/{n.replaceTrailingBrackets().colon(' - ')}{' ('+y+')'}/{n.replaceTrailingBrackets().colon(' - ')}{' ('+y+')'}{' (Part '+pi+')'}{' ['+{source+'-'+vf}+{' '+vc}+{' '+ac}+{' '+bitdepth+'bit'}+']'}{'.'+lang}"
seriesFormat = "D:/Plex Media Server/Series/{n.replaceTrailingBrackets().colon(' - ')}{' ('+y+')'}{' [tvdb-'+id+']'}/{'Season ' + s}/{n.replaceTrailingBrackets().colon(' - ')}{' ('+y+')'}{' - '+s00e00.lower()}{' - '+t.colon(' - ')}{' ['+{source+'-'+vf}+{' '+vc}+{' '+ac}+{' '+bitdepth+'bit'}+']'}{' ['+group+']'}{'.'+lang}"
animeFormat = "D:/Plex Media Server/Anime/{primarytitle.colon(' - ')}{' [anidb-'+id+']'}/{primarytitle.colon(' - ')}{' - S' + special.pad(3)}{' - E' + absolute.pad(3)}{' - '+t.colon(' - ')}{audioLanguages =~ ',' ? ' [Dual Audio]' : null}{' ['+vf+' '+bitdepth+'bit'+']'}{' ['+group+']'}"
# required args
label, state, title, kind, file, directory = sys.argv[1:7]
command = [
'filebot', '-script', 'fn:amc',
'--output', output,
'--action', 'duplicate',
'--conflict', 'index',
'-non-strict',
'--log-file', 'D:/Other/Filebot-amc.log',
'--def',
'unsorted=y',
'movieFormat=' + movieFormat,
'seriesFormat=' + seriesFormat,
'animeFormat=' + animeFormat,
'ut_label=' + label,
'ut_state=' + state,
'ut_title=' + title,
'ut_kind=' + kind,
'ut_file=' + file,
'ut_dir=' + directory
]
# execute command only for certain conditions (disabled by default)
if label == "Anime" or label == "TV" or label == "Movie":
# execute command (and hide cmd window)
subprocess.run(command, creationflags=0x08000000)
else:
print('Aborting due to label: ' + label)
sys.exit(0)
Code: Select all
Microsoft Windows [Version 10.0.19041.450]
(c) 2020 Microsoft Corporation. All rights reserved.
C:\Python\Python37>python "D:\Other\Filebot-qBittorrent.pyw" "Movie" "5" "Avatar" "multi" "" "X:\Files\Avatar"
Traceback (most recent call last):
File "D:\Other\Filebot-qBittorrent.pyw", line 35, in <module>
subprocess.run(command)
File "C:\Python\Python37\lib\subprocess.py", line 472, in run
with Popen(*popenargs, **kwargs) as process:
File "C:\Python\Python37\lib\subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "C:\Python\Python37\lib\subprocess.py", line 1178, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
C:\Python\Python37>