Modifications to mdhiggins' version:
This is work in progress. A lot of what I think is useful FOR MY NEEDS is implemented. The following is an incomplete list of things open:
- If launched directly from Sickrage during PostProcess via postConversion.py things are not working as expcted just yet. This is mainly due to the Staging logic not properly implemented in postConversion.py just yet.
- DO NOT RUN postConversion.py. Rather schedule manual.py and use the Sickrage post_process plugin to trigger TORNADO processing via SR API (you only need to configure Sickrage in autoProcess.ini as usual, everything else happens on it's own)
- If using the CouchPotato plugin things are not working as expected, rather use manual.py.
- Generally speaking my ultimate usage pattern is to have manual.py on schedule, scavenge all new files, process them and make them available to Sickrage and CouchPotato via a 'release' folder that these 2 can monitor. As soon as manual.py finishes converting a file a trigger should fire PostProcessing in Sickrage and CouchPotato using API calls. I'm no fan of having SR and CP trigger mp4 conversions themselves in an uncontrolled fashion.
That being said here goes the changes so far:
Levenhstein
- Runpip install python-Levenshtein
. Needed for distance matching during tagging.
- Encoding:
meks-metadata = <string>
- (String) - Allows to specify ffmpeg metadata information that should be included during transcode.meks-same-vcodec-copy = True
- (True|False) - Allow copying of a video stream if input and output codec is the same, check Finer grained conrol of codec processingmeks-same-acodec-copy = True
- (True|False) - Same as for video, but for audio streams, check Finer grained control of codec processingmeks-aac-adtstoasc = False
- (True|False) - Convert AAC ADTS streams to ASC, even if the stream is set to be copied.
- Encoding / H.264 - see h264 Preset and Quality
meks-video-quality = 23
- (Integer) - Enable quality-based transcodingmeks-h264-preset = medium
- (String) - Specify the H.264 encoding preset
- Encoding / H.264 / QSV - see h264 QSV changes
meks-qsv-lookahead = 1
- (Integer) - Enable the Look Ahead rate control method using the specified value
- Batch processing - see Recursive mass-processing
meks-walk-ignore = ignore.part,ignore.skip,recode.ignore,recode.skip
- (List of file names, seperated by ,) - Allows to specify ignore-filesmeks-walk-ignore-self = True
- Skip files that were processed alreadymeks-transcode-ignore-names = sample
- (List of file name parts, seperated by ,) - File names to ignore in a batch runmeks-transcode-ignore-size = 0
- (Float) - File sizes in bytes to ignore in a batch run
- Staging:
meks-staging = True
- (True|False) - Enables staged transcodingmeks-staging-extension = part
- (String) - Extension to add to files during transcoding-stage
- Tagging:
meks-nfosearch = True
- (True|False) - Enable parsing of nfo files to search for a IMDB IDmeks-nfopaths = ..
(List of paths, seperated by |) - Paths to search for nfo filesmeks-id3v2vers = 3
- (Integer) - Specify the ID3v2 version that should be used for taggingmeks-tag-rename = False
- (True|False) - Enable automatic renaming of the output file based on tagged datameks-tag-language-auto = False
(True|False) - Enable to automatically identify the language for tagging based on audio streamsmeks-tag-mandatory = False
(True|False) - Specify if tagging is mandatory and if processing should abort if tagging is impossible.
- Misc:
move_to = True
- (True|False) - This was changed to boolean. Specify if you want to move or copy a file after processing, see Copy-To and Move-To by file type
Convert an input-file to a part-file and only transition to mp4 just before replication (Copy-To/Move-To) This allows to exclude files from 3rd party apps while they're being converted. The part file will be transitioned after all write operations are finished (that is after conversion, tagging, relocate atoms, ...).
Staging can be defined in autoProcess.ini using:
meks-staging = True|False
(default: True; make use of the staging logic or revert to traditional processing)meks-staging-extension = part
(default: part; extension to append during staging)
Staging workflow:
- Input file
- Conversion => Outputfile + ".part"
- Write operations => Tagging on part-File => Atom operations (MOOV) on part-File
- Transition => Rename to final mp4 file
- Replication => Copy-To => Move-To
Using meks_same-vcodec-copy = True|False
same-video-codec copy operations can be disabled (default: True, enabled.).
If disabled a video transcode is forced even if the input file already has one of the desired video-codec
s, otherwise the video stream is copied to the output file, ignoring any quality settings specified.
Similarily, using meks_same-acodec-copy = True|False
same-audio-codec copy operation can be disabled (default: True, enabled.)
Specify if ADTS should be converted to ASC using meks-aac-adtstoasc = True|False
(default: True). If input audio codec is AAC and same-acodec-copy is True, then convert an ADTS stream to ASC using ffmpeg bitstream filters.
There are 2 new options in autoProcess.ini available for specifying preset and quality during conversions:
meks-video-quality = 20
meks-h264-preset = medium
Note: If video-bitrate was specified then this turns into ffmpeg -maxrate. See https://trac.ffmpeg.org/wiki/Encode/H.264
- Specify
video-codec = h264qsv
to enable QSV encoding. - The same h264 values for quality, maxrate and preset apply for h264qsv.
- QSV look_ahead is now customizable with
meks-qsv-lookahead = (int)
(default: 0). - quality (normally ffmpeg -crf) turns into -q IF
meks-qsv-lookahead = 0
- quality is omitted if
meks-qsv-lookahead = 1..31
as they are different rate methods and can't be used together.
use-qsv-decoder-with-encoder = False
will force the input decoder to be h264_qsv if the input codec is h264, in other words if True and video-codec = h264qsv then both decode and encode will be handled by QSV.
The manual processor (manual.py) has an option to specify an input folder rather than a file (nothing new). However the processor walks the complete hierarchy below this folder.
If you are like me and have all sorts of stuff in your incoming/download folder and don't want to have the converter attempt to process eg ISO images or EXE files, then a full hierarchy walk is pointless.
Therefore autoProcess.ini now supports specifying:
meks-walk-ignore = <ignore-files>
- eg: recode.ignore,ignore.part,ignore.skip
During hierarchy walk the processor automatically skips a folder and all of it's subfolders and files if a file was found that matches .
Example, say you have the following situation:
meks-walk-ignore = ignore.part,recode.skip
- Hierarchy as follows
Download
Download/Apps - [ignore.part]
Download/Videos
Download/ISO - [recode.skip]
A hierarchy walk would then skip all files and subfolders in Apps/* and ISO/* and only allow processing of files directly in Download as well as Videos/*
Furthermore in mass processing mode, one can ignore files based on name and size restrictions:
meks-transcode-ignore-names = sample,example
(default: sample)meks-transcode-ignore-size = 40000000
(in Bytes, default: 0)
Another option is to ignore files that were already processed/encoded by ourselves (read: this encoder). This can be helpful if, for whatever reason, encoding was aborted and needs to be resumed at a later point. You could then specify the same hierarchy and skip all files that were already processed in an earlier run. This feature makes use of the encoder
MP4 tag. If the encoder tag matches our signature than that file is skipped during batch processing. You can control this feature with
meks-walk-ignore-self = True|False
(default: True)
Note that these restrictions do not apply if a file is targeted directly. They are only applied during hierarchy walk.
Suppose you use this converter for converting and tagging movies as well as TV shows. Further down the chain, after conversion is finished and the file is ready for post processing by SR/CP, it might be useful to separate the output files in folders for movies and TV shows. Originally this was not possible as you could either copy all files or move all files to one or multiple folders, but you would end up with all files in the same folder.
You could (and still can) specify "multi-purpose" folders using
copy-to = /path/to/folder1|/path/to/folder2|/path/to/folderX
However in favor of having tag-based destinations, this was changed so that Copy-to now allows the following syntax for folders by type:
copy-to = movie:/path/to/moviefolder|tv:/path/to/tvfolder|/path/to/generic/folder
Following the above example, this would result in all files which were tagged as movies to be copied to /path/to/moviefolder and /path/to/generic/folder and all TV shows to /path/to/tvfolder and /path/to/generic/folder.
If a movie or TV show can not be tagged, then all type-folders will be ignored and only the "multi-purpose" generic folders are taken into account. If no generics are defined then Copy-to would behave as if it wasn't set at all.
Furthermore I saw no need in being able to specify Move-to. The Move-to option originally behaved the same as Copy-to but would delete (read: move away) the file from the original output location during replication, whereas Copy-to would only create copies and leave the file in the original output location. So since both options are roughly the same,
- I made
move-to = True|False
instead of String.
By specifying setting it to True
all Copy-to operations transform into Move-to. So if you specified a type-folder for movies and enabled move-to then all your converted and tagged movie files would first be copied to the movie type folder and deleted after copy was successful.
- Fire CouchPotato Renamer using API (only fire if file was tagged as movie)
- Fire Sickrage PostProcessor using API (only fire if file was tagged as TV show)
- Dump ffprobe data to log after conversion (for keeping a log of conversions)
All scripts were enabled to properly utilize logging facilities and no longer send to stdout but rather send output using loggers.
meks-metadata = <metadata-options>
can be used to call ffmpeg with the -metadata
argument to edit/change metadata during conversion.
This fork uses Celia Okley's tmdbsimple, a completely different TMDB API which enables greater flexibility in searches (e.g. include year in search).
This is a drop-in replacement on the extension side as all methods from tmdb_mp4.py are still the same. However if you accessed the original TMDB API then those things would need to be adapted. Due to this switch the whole GuessIt parsing features have improved too.
1. Tagging via command line arguments
Options for -imdb
and -tmdb
as well as any IMDB and/or TMDB related tagging attempts can be fully applied to either TMDB or TVDB data, depending on the class that is being returned from TMDB.
So for example if you specified a TV show via -tmdb 47110815
then that lookup would yield a "series" answer from TMDB and that request would be proxied to a TVDB title search. The same is valid for: TV show via -imdb, Movie via -imdb.
In other words, you can specify -imdb movie_or_tv
, -tmdb movie_or_tv
, -tvdb tv
. If you specified a TV show you can use all 3 options and end up using the TVDB results. This is helpful if using manual.py in batch processing mode. You can just let it handle the ID's itself instead of having to distinguish between movie or TV before launching manual.py.
2. Tagging via nfo file
.nfo support was added via meks-nfosearch = True|False
.
Set to True to include a nfo file if one exists, search for an IMDB link in it and use that for tagging.
nfo files will always be searched in the same path as the inputfile. In addition, paths can be extended using meks-nfopaths = path|path
(eg ..
for parent dir)
Only the first nfo file with a valid IMDB link only the first IMDB link in that file will be used for tagging. Any subsequent nfo files or multiple links within the same file are disregarded.
Regular Expressions used for parsing NFO files:
((?:http\:\/\/)?www\.imdb\.(?:com|de)/(?:title/)?(tt\d+))
- ex:
http://www.imdb.com/title/tt123456
- ex:
(<id>(tt\d+)</id>)
3. Tagging via GuessIt
The python GuessIt library can be used to guess information based on the input filename. Upon parsing the file different search queries are directed towards TMDB in order to load further information.
4. Tagging via metadata
If an input file is already tagged with a title tag, then that tag will be used to acquire furhter information from TMDB/TVDB. The input file is analyzed using ffprobe -show_format
. Metadata has low priority as some files contain title tags of a release group or such. Honoring that too much for the sake of tagging would result in that are completely wrong.
5. No tags
Well. Tough luck, but yes.
Tagging order is: (1) manual.py arguments > (2) nfo > (3) GuessIt > (4) Metadata > (5) no tag ***
The tagging processes ends as soon as enough information is collected to reliably tag the file.
Option to rename a file based on tagging information
Specify meks-tag-rename = True|False
(default: False) to enable renaming of tagged files using 2 basic renaming schemes:
- Movie:
%(title)s.(%(year)s).%(lang)s.%(format)s.%(videoCodec)s%(sep)s%(releaseGroup)s.%(ext)s
e.g.: Movie.Name.(2014).English.HDTV.h264-FLEET.mp4 - TV:
%(show)s.S%(season)sE%(episode)s.%(title)s%(year)s.%(lang)s.%(format)s.%(videoCodec)s%(sep)s%(releaseGroup)s.%(ext)s
e.g.: Series.Name.S02E18.Episode.Title.2012.English.HDTV.h264-FLEET.mp4
Note (1): All spaces in any of the expanded variables will be replaced by dots. So Movie Name will be replaced with Movie.Name
Note (2): PROPER tags are not applied during renaming at the moment.
Options for tagging files
- The ID3v2 version can be specified using
meks-id3v2vers = <int>
(default: 3 (=ID3v2.3), for compatibility with Windows) - The tagging language can be dynamically determined based on input stream language. You can use
meks-tag-language-auto = True|False
(default: False) to specify whether the tagging language should be determined by the following:- If the FIRST audio stream of an input file has a language identifier set, then that language will be used for loading and writing metadata information after transcode.
- If no or an invalid identifier was found then the language configured using
tag-language
will be used as a fallback.
- If tagging is so important to you that you want a file to be tagged under any circumstances, then you can achieve that by specifying
meks-tag-mandatory = True
(default: False). Any processing will abort if it isn't possible to fetch valid metadata.
-
Config-files specified using -c or --config must be located within the application and cannot be stored outside the application directory.
-
Threads setting removed as it is deprecated and completely removed on newer ffmpeg versions
-
Access to autoSettings.ini is unified:
from readSettings import settingsProvider
settingsProvider().defaultSettings
This can be extended using multiple providers for multiple configurations (say: different configs for Movies and TV shows), e.g.:
settingsProvider().settingsMovies
settingsProvider().settingsTV
-
Furthermore,
settingsProvider(config_file=<config_file>)...
can be used to specify an alternative configuration file. Be aware that<config_file>
must not be outside the application directory, hence config_file is relative to the script's path, for example conf/autoProcessGerman.ini. -
Similarily, access to logging is unified, eg:
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
from _utils import LoggingAdapter
log = LoggingAdapter.getLogger()
anotherlog = LoggingAdapter.getLogger("testLogger")
-
Media file validation unified to
MkvtoMp4().validSource()
, takes into account ffprobe information rather than just file extensions -
If an input file was detected as bad then move it out of the way by renaming it to ".bad"
-
If
delete_original = False
then a rename operation automatically kicks in that appends ".recoded" to the input file. It's either delete or rename, leaving it untouched is no option. -
manual.py adapted to Python logging rather than print()
- Deluge, uTorrent, NZBGET, SABNZBD, Sonarr are problably not working - not tested though (don't use them)
- Plex refresh works, however personally I have set SR and CP to handle Plex so I don't make use of the Plex interface.
Automatically converts media files downloaded by various programs to mp4 files, and tags them with the appropriate metadata from theTVDB or TMDB.
Works on Windows, OSX, and Linux
Media Managers Supported:
- Sickbeard
- SickRage
- CouchPotato
- Sonarr
Downloaders Supported:
- SABNZBD
- NZBGet
- uTorrent
- Deluge Daemon
- Python 2.7
- Python 3 beta support has arrived. Feel free to begin testing and report bugs
- FFMPEG and FFPROBE binaries
- Python setup_tools
- See PIP packages for additional requirements
- Video - H264
- Audio - AAC 2.0 with additional AC3 track when source has >2 channels (ex 5.1)
- Subtitles - mov_text
Note: Windows users should enter commands in Powershell - using '<' doesn't work in cmd
VC for Python 2.7
(Windows Users Only) - Download and install - http://www.microsoft.com/en-us/download/details.aspx?id=44266setup_tools
- https://pypi.python.org/pypi/setuptools#installation-instructionsrequests
- Runpip install requests
requests security package
- Runpip install requests[security]
requests-cache
- Runpip install requests-cache
babelfish
- Runpip install babelfish
guessit
- Runpip install "guessit<2"
to use manual.py (requires guessit version 1, version 2 is a complete rewrite, still in alpha, and not backwards compatible)subliminal
- Runpip install "subliminal<2"
to enable automatically downloading subtitlesstevedore
- Runpip install stevedore
(this will be automatically installed with subliminal)dateutil
- Runpip install python-dateutil
(this will be automatically installed with subliminal)deluge-client
Runpip install deluge-client
if you plan on using Delugeqtfaststart
Runpip install qtfaststart
to enable moving moov atom
- Rename autoProcess.ini.sample to autoProcess.ini
- Set the MP4 variables to your desired output
ffmpeg
= Full path to FFMPEG.exeffprobe
= Full path to FFPROBE.exethreads
= Number of threads for FFMPEG to use, default "auto"output_directory
= you may specify an alternate output directory. Leave blank to use the same directory that the source file is in. All processing will be done in this location. (Do not use for 'Automatically Add to iTunes' folder, iTunes will add prematurely, usemove_to
)copy_to
= you may specify additional directories for the final product to be replicated to. This will be the last step performed so the file copied will be fully processed. Directories may be separated with a|
charactermove_to
= you may specify one final directory to move the completed file. (Use this option for the 'Automatically Add to iTunes' folder)output_extension
= mp4/m4v (must be one of these 2)output_format
= mp4/mov (must be one of these 2, mov provides better compatibility with iTunes/Apple, mp4 works better with other mobile devices)delete_original
= True/Falserelocate_moov
= True/False - relocates the MOOV atom to the beginning of the file for better streamingios-audio
= creates a 2nd copy of an audio stream that will be iOS compatible (AAC Stereo) if the normal output will not be. If a stereo source stream is detected with this option enabled, an AAC stereo stream will be the only one produced (essentially overriding the codec option) to avoid multiple stereo audio stream copies in different codecs. Instead of 'true' you may also set this option to a specific codec to override the default.ios-first-track-only
= Applies theios-audio
option only to the first audio track encountered in the source video file. This prevents making dual audio streams for additional alternative language codecs or commentary tracks that may be present in the source file.ios-audio-filter
= Applies FFMPEG audio filter option to ONLY the iOS audio channels created by the script. iOS audio counterpart to theaudio-filter
option below.max-audio-channels
= Sets a maximum number of audio channels. This may provide an alternative to the iOS audio option, where instead users can simply select the desired output codec and the max number of audio channels without the creation of an additional audio track.video-codec
= set your desired video codecs. May specify multiple comma separated values (ex: h264, x264). The first value specified will be the default conversion choice when an undesired codec is encountered; any codecs specified here will be remuxed/copied rather than converted.video-bitrate
= allows you to set a maximum video bitrate in Kbps. If the source file exceeds the video-bitrate it will be transcoded to the specified video-bitrate, even if they source file is already in the correct video codec. If the source file is in the correct video codec and does not exceed the video-bitrate setting, then it will be copied without transcoding. Leave blank to disable this setting.video-max-width
= set a max video width to downsize higher resolution video files. Aspect ratio will be preserved.h264-max-level
= set your max h264 level. Use the decimal format. Levels lower than the specified value, if otherwise appropriate, will be copied without transcoding. Example -4.0
.pix_fmt
= set the video pix_fmt. If you don't know what this is just leave it blank.audio-codec
= set your desired audio codecs. May specify multiple comma separated values (ex: ac3, aac). The first value specified will be the default conversion choice when an undesired codec is encountered; any codecs specified here will be remuxed/copied rather than converted.audio-channel-bitrate
= set the bitrate for each audio channel. Default is 256. Setting this value to 0 will attempt to mirror the bitrate of the audio source, but this can be unreliable as bitrates vary between different codecs.audio-language
= 3 letter language code for audio streams you wish to copy. Leave blank to copy all. Separate multiple audio streams with commas (ex: eng,spa)audio-default-language
= If an audio stream with an unidentified/untagged language is detected, you can default that language tag to whatever this value is (ex: eng). This is useful for many single-audio releases which don't bother to tag the audio stream as anythingaudio-filter
= Applies FFMPEG audio filter. Make sure you specify all parameters are you would using the-af
option with FFMPEG command linesubtitle-codec
= set your desired subtitle codec. If you're embedding subs,mov_text
is the only option supported. If you're creating external subtitle files,srt
orwebvtt
are accepted.subtitle-language
= same as audio-language but for subtitles. Set tonil
to disable copying of subtitles.subtitle-language-default
= same as audio-language-default but for subtitlesconvert-mp4
= forces the script to reprocess and convert mp4 files as though they were mkvs. Good if you have old mp4's that you want to match your current codec configuration.fullpathguess
= True/False - When manually processing a file, enable to guess metadata using the full path versus just the file name. (Files shows placed in a 'Movies' folder will be recognized as movies, not as TV shows for example.)tagfile
= True/False - Enable or disable tagging file with appropriate metadata after encoding.tag-language
= en - Set your tag language for TMDB/TVDB entries metadata retrieval. Use either 2 or 3 character language codes.download-artwork
= Poster/Thumbnail/False - Enabled downloading and embeddeding of Season or Movie posters and embeddeding of that image into the mp4 as the cover image. For TV shows you may choose between the season artwork or the episode thumbnail by selecting the corresponding option.embed-subs
= True/False - Enabled by default. Embeds subtitles in the resulting MP4 file that are found embedded in the source file as well as external SRT/VTT files. Disabling embed-subs will cause the script to extract any subtitles that meet your language criteria into external SRT/VTT files. The script will also attempt to download SRT files if possible and this feature is enabled.download-subs
= True/False - When enabled the script will attempt to download subtitles of your specified languages automatically using subliminal and merge them into the final mp4 file. YOU MUST INSTALL SUBLIMINAL AND ITS DEPENDENCIES FOR THIS TO WORK. You must runpip install subliminal
in order for this feature to be enabled.sub-providers
= Comma separated values for potential subtitle providers. Must specify at least 1 provider to enabledownload-subs
. Providers includepodnapisi
thesubdb
opensubtitles
tvsubtitles
addic7ed
- Open Sickbeard's config.ini in Sick Beard installation folder
- Set "extra_scripts" value in the general section to the full path to "python postConversion.py" using double backslashes
- Example:
C:\\Python27\\python C:\\Scripts\\postConversion.py
- Make sure this is done while Sick Beard is not running or it will be reverted
- Example:
- Set "extra_scripts" value in the general section to the full path to "python postConversion.py" using double backslashes
- Set the SickBeard variables in autoProcess.ini under the [Sickbeard] section:
host
- defaultlocalhost
- Sick Beard host addressport
- default8081
- Sick Beard portssl
-0
/1
api_key
- Set this to your Sickbeard API key (options -> general, enable API in Sick Beard to get this key)web_root
- Set your Sickbeard webrootuser
- Usernamepassword
- Password
- Open the configuration page in Sickrage and scroll down to the option labelled "Extra Scripts". Here enter the path to python followed by the full script path. Examples:
C:\\Python27\\python.exe C:\\sickbeard_mp4_automator\\postConversion.py
/usr/bin/python /home/user/sickbeard_mp4_automator/postConversion.py
- Set the Sickrage variables in autoProcess.ini under the [Sickrage] section:
host
- defaultlocalhost
- Sickrage host address (localhost)port
- default8081
Sickrage portssl
-1
if enabled,0
if notapi_key
- Set this to your Sickrage API keyweb_root
- Set your Sickrage webrootuser
- Usernamepassword
- Password
- Set your Sonarr settings in the autoProcess.ini file
host
= Sonarr host address (localhost) #Settings/General/Start-Upport
= Sonarr port (8989) #Settings/General/Start-Upssl
= 1 if enabled, 0 if not #Settings/General/Securityapikey
= Sonarr API Key (required) #Settings/General/Securityweb_root
= URL base empty or e.g. /tv #Settings/General/Start-Up
- Browse to the Settings>Download Client tab and enable advanced settings [Show].
- Set the Drone Factory Interval' to 0 to disable it, and disable 'Completed Download Handling' in Sonarr settings. The script will trigger a specific path re-scan, allowing the mp4 conversion to be completed before Sonarr starts moving stuff around. This step is optional if you do not desire any processing between the downloading by whichever downloader you choose (NZB or Torrent), but is required if you wish to convert the file to an MP4 before it is handed back to Sonarr.
- Setup the postSonarr.py script via Settings > Connect > Connections > + (Add)
name
- postSonarrOn Grab
- NoOn Download
- YesOn Upgrade
- YesOn Rename
- No- Filter Series Tags - optional
- Windows Users
Path
- Full path to your python executableArguments
- Full path topostSonarr.py
- Nonwindows Users
Path
- Full path topostSonarr.py
Arguments
- Leave blank
- Set your Couch Potato settings to the autoProcess.ini file
host
- defaultlocalhost
- Couch Potato host addressport
- default5050
- Couch Potato port (5050)ssl
-1
if enabled,0
if notapi_key
- Couch Potato API Keyusername
- your Couch Potato usernamepassword
- your Couch Potato password
- Edit
main.py
in thesetup\PostProcess
folder- Set the path variable to the script location
- By default it points to
C:\\Scripts\\
- Use double backslahses
- Copy the PostProcess directory from the setup folder included with this script to the Couch Potato
custom_plugins
directory- Navigate to the About page in Couch Potato, where the installation directory is displayed.
- Go to this folder and copy the PostProcess folder (the whole folder, not just the contents) to the Couch Potato
custom_plugins
directory - Delete any
.pyc
files you find. - Restart Couch Potato
- Verify in Couch Potato logs that PostProcess was loaded.
- If you're using one of the post download scripts ([SAB|NZBGet|uTorrent|deluge]PostProcess.py), disable automatic checking of the renamer folder, the script will automatically notify Couch Potato when it is complete to check for new videos to be renamed and relocated. Leaving this on may cause conflicts and CouchPotato may try to relocate/rename the file before processing is completed.
- Set
Run Every
to0
- Set
Force Every
to0
- If you aren't using one of these scripts and are using an unsupported downloader, you will need to have CouchPotato periodically check the folder for files, otherwise the post downloader scripts will manually trigger a renamer scan. Using manual triggers is helpful because it prevents a coincidental renamer scan during other processing events.
- Set
- Configure Downloaders
- In
Settings > Downloaders
configure your labels or categories to match what you have configured in your respective downloader.
- In
- Copy the script NZBGetPostProcess.py to NZBGet's script folder.
- Default location is ~/downloads/scripts/
- Start/Restart NZBGet
- Configure NZBGETPOSTPROCESS
- Access NZBGet's WebUI
- Default
localhost:6789
- Default
- Go to
Settings
- Select
NZBGETPOSTPROCESS
option at the bottom of the left hand navigation panel and configure the optionsMP4_FOLDER
- default~/sickbeard_mp4_automator/
- Location of the script. Use full path with trailing backslash.SHOULDCONVERT
-True
/False
- Convert file before passing to destinationCP_CAT
- defaultcouchpotato
- category of downloads that will be passed to CouchPotatoSONARR_CAT
- defaultsonarr
- category of downloads that will be passed to SonarrSICKBEARD_CAT
- defaultsickbeard
- category of downloads that will be passed to SickbeardSICKRAGE_CAT
- defaultsickrage
- category of downloads that will be passed to SickrageBYPASS_CAT
- defaultbypass
- category of downloads that may be converted but won't be passed on further
- Save changes
- Reload NZBGet
- Access NZBGet's WebUI
- Verify that whatever media manager you are using is assigning the category to match the label settings specified here so that file will be passed back to the appropriate location
- Configure
SABNZBD
section ofautoProcess.ini
convert
-True
/False
- Allows for conversion of files before passing back to the respective download manager.sickbeard-category
- defaultsickbeard
- category that will be sent to Sickbeard for additional processing when download is completesickrage-category
- defaultsickrage
- category that will be sent to Sickrage for additional processing when download is completecouchpotato-category
- defaultcouchpotato
- category that will be sent to Couch Potato for additional processing when download is completesonarr-category
- defaultsonarr
- category that will be sent to Sonarr for additional processing when download is completebyapss-category
- defaultbypass
- category that should be assigned to torrents that will not be sent anywhere when download is complete. Useful if you wish to convert files without additional processing
- Point SABNZBD's script directory to the root directory where you have extract the script.
- Configure categories. Categories will determine where the download is sent when it is finished
Settings > Categories
- Configure
name
to match the settings from theSABNZBD
section ofautoProcess.ini
- Default
sickbeard
- Default
sickrage
- Default
couchpotato
- Default
sonarr
- Default
bypass
- Default
- Select the SABPostProcess.py script
- Save EACH category
- Verify that whatever media manager you are using is assigning the label to match the label settings specified here so that file will be passed back to the appropriate location
- Verify that you have installed the Requests library
pip install requests
- Launch uTorrent
- Set
Run Program
option- Go to
Options > Preferences > Advanced > Run Program
- Point to
uTorrentPostProcess.py
with command line parameters:%L %T %D %K %F %I %N
in that exact order.
- Go to
- Set your uTorrent settings in autoProcess.ini
convert
-True
/False
. Allows for conversion of files before passing back to the respective download manager.sickbeard-label
- defaultsickbeard
- uTorrent label that should be assigned to torrents that will be sent to Sickbeard for additional processing when download is complete.sickrage-label - default
sickrage` - uTorrent label that should be assigned to torrents that will be sent to Sickrage for additional processing when download is complete.couchpotato-label
- defaultcouchpotato
- uTorrent label that should be assigned to torrents that will be sent to Couch Potato for additional processing when download is complete.sonarr-label
- defaultsonarr
- uTorrent label that should be assigned to torrents that will be sent to Sonarr for additional processing when download is complete.bypass-label
- defaultbypass
- label that should be assigned to torrents that will not be sent anywhere when download is complete. Useful if you wish to convert files without additional processing.webui
-True
/False
. IfTrue
the script can change the state of the torrent.action_before
- stop/pause or any other action from http://help.utorrent.com/customer/portal/articles/1573952-actions---webapiaction_after
- start/stop/pause/unpause/remove/removedata or any other action from http://help.utorrent.com/customer/portal/articles/1573952-actions---webapihostname
- your uTorrent Web UI URL, eghttp://localhost:8080/
including the trailing slash.username
- your uTorrent Web UI username.password
- your uTorrent Web UI password.
- Verify that whatever media manager you are using is assigning the label to match the label settings specified here so that file will be passed back to the appropriate location
- Verify that you have installed the Gevent library
pip install gevent
- Windows users will need to also install the Microsoft Visual C++ Compiler for Python 2.7 for gevent to work. http://www.microsoft.com/en-us/download/details.aspx?id=44266
- Create username and password for deluge daemon
- Navigate to your deluge configuration folder
%appdata%\Roaming\Deluge
in Windows/var/lib/deluge/.config/deluge/
in Linux
- Open the
auth
file - Add a username and password in the format
<username>:<password>:<level>
. Replace and with your choice and level with your desired authentication level. Default level is10
. Save auth.- Ex:
sampleuser:samplepass:10
- Ex:
- Navigate to your deluge configuration folder
- Start/Restart deluged
- deluged not deluge
- Access the WebUI
- Default port is
8112
- Default password is
deluge
- Default port is
- Enabled the
Execute
plugin- Add event for
Torrent Complete
- Set path to the full path to
delugePostProcess.py
ordelugePostProcess.bat
for Windows users.
- Add event for
- Configure the deluge options in
autoProcess.ini
sickbeard-label
- Deluge label that should be assigned to torrents that will be sent to Sickbeard for additional processing when download is complete.- `sickrage-label - Deluge label that should be assigned to torrents that will be sent to Sickrage for additional processing when download is complete.
couchpotato-label
- Deluge label that should be assigned to torrents that will be sent to Couch Potato for additional processing when download is complete.sonarr-label
- Deluge label that should be assigned to torrents that will be sent to Sonarr for additional processing when download is complete.bypass-label
- label that should be assigned to torrents that will not be sent anywhere when download is complete. Useful if you wish to convert files without additional processing.convert
-True
/False
. Allows for conversion of files before passing back to the respective download manager.host
- your Deluge hostname. Default islocalhost
port
- Deluge daemon port. Default is58846
. Do not confuse this with your WebUI port, which is different.username
- your Deluge username that you previously added to theauth
file.password
- your Deluge password that you previously added to theauth
file.
- Verify that whatever downloader you are using is assigning the label to match the label settings specified here so that file will be passed back to the appropriate location
Send a Plex notification as the final step when all processing is completed. This feature prevents a file from being flagged as "in use" by Plex before processing has completed.
- Disable automatic refreshing on your Plex server
Settings > Server > Library
and disableUpdate my library automatically
andUpdate my library periodically
.
- Configure autoProcess.ini
refresh
-True
/False
- Enable or disable the featurehost
- Plex hostname. Defaultlocalhost
port
- Plex port. Default32400
token
- Plex Home Token
The script suite supports the ability to write your own post processing scripts that will be executed when all the final processing has been completed. All scripts in the ./post_process
directory will be executed if the post-process
option is set to True
in autoProcess.ini
. Scripts within the ./post_process/resources
directory are protected from execution if additional script resources are required.
The following environmental variables are available for usage:
MH_FILES
- JSON Array of all files created by the post processing script. The first file in the array is the primary file, and any additional files are copies created by the copy-to optionMH_TVDBID
- TVDB ID if file processed was a TV show and this information is availableMH_SEASON
- Season number if file processed was a TV showMH_EPISODE
- Episode number if files processed was a TV showMH_IMDBID
- IMDB ID if file processed was a movie A sample script as well as an OS X 'Add to iTunes' script (iTunes.py
) have been provided. Special thanks to jzucker2 for providing much of the initial code for this feature
To run the script manually, simply run the manual.py file and follow the prompts it presents. If you wish to run it via the command line (good for batch operations) follow this format:
Help output
manual.py -h
usage: manual.py [-h] [-i INPUT] [-a] [-tv TVDBID] [-s SEASON] [-e EPISODE]
[-imdb IMDBID] [-tmdb TMDBID] [-nm] [-nc] [-nd]
Manual conversion and tagging script for sickbeard_mp4_automator
optional arguments:
-h, --help show this help message and exit
-i INPUT, --input INPUT
The source that will be converted. May be a file or a
directory
-a, --auto Enable auto mode, the script will not prompt you for
any further input, good for batch files. It will guess
the metadata using guessit
-tv TVDBID, --tvdbid TVDBID
Set the TVDB ID for a tv show
-s SEASON, --season SEASON
Specifiy the season number
-e EPISODE, --episode EPISODE
Specify the episode number
-imdb IMDBID, --imdbid IMDBID
Specify the IMDB ID for a movie
-tmdb TMDBID, --tmdbid TMDBID
Specify theMovieDB ID for a movie
-nm, --nomove Overrides and disables the custom moving of file
options that come from output_dir and move-to
-m, --moveto Override move-to value setting in autoProcess.ini
changing the final destination of the file
-nc, --nocopy Overrides and disables the custom copying of file
options that come from output_dir and move-to
-nt, --notag Overrides and disables tagging when using the
automated option
-nd, --nodelete Overrides and disables deleting of original files
-pr, --preserveRelative
Preserves relative directories when processing
multiple files using the copy-to or move-to
functionality
-cmp4, --convertmp4 Overrides convert-mp4 setting in autoProcess.ini
enabling the reprocessing of mp4 files
Examples
Movies (using IMDB ID):
manual.py -i mp4path -m imdbid
Example: manual.py -i 'C:\The Matrix.mkv' -imdb tt0133093
Movies (using TMDB ID)
manual.py -i mp4path -tmdb tmdbid
Example: manual.py -i 'C:\The Matrix.mkv' -tmdb 603
TV
manual.py -i mp4path -tv tvdbid -s season -e episode
Example: manual.py -i 'C:\Futurama S03E10.mkv' -tv 73871‎ -s 3 -e 10
Auto Single File (will gather movie ID or TV show ID / season / spisode from the file name if possible)
manual.py -i mp4path -silent
Example: manual.py -i 'C:\Futurama S03E10.mkv' -a
Directory (you will be prompted at each file for the type of file and ID)
manual.py -i directory_path
Example: manual.py -i C:\Movies
Automated Directory (The script will attempt to figure out appropriate tagging based on file name)
manual.py -i directory_path -a
Example: manual.py -i C:\Movies -a
Process a directory but manually specific TVDB ID (Good for shows that don't correctly match using the guess)
manual.py -i directory -a -tv tvdbid
Example: manual.py -i C:\TV\Futurama\ -a -tv 73871
You may also simply run manual.py -i 'C:\The Matrix.mkv'
and the script will prompt you for the missing information or attempt to guess based on the file name.
You may run the script with a --auto
or -a
switch, which will let the script guess the tagging information based on the file name, avoiding any need for user input. This is the most ideal option for large batch file operations.
The script may also be pointed to a directory, where it will process all files in the directory. If you run the script without the -silent
switch, you will be prompted for each file with options on how to tag, to convert without tagging, or skip.
To use your own cover art instead of what the script pulls from TMDB or TVDB, simply place an image file named cover.jpg or cover.png in the same directory as the input video before processing and it will be used.
To import external subtitles, place the .srt file in the same directory as the file to be processed. The srt must have the same name as the input video file, as well as the 3 character language code for which the subtitle is. Subtitle importing obeys the langauge rules set in autoProcess.ini, so languages that aren't whitelisted will be ignored.
Naming example:
input mkv - The.Matrix.1999.mkv
subtitle srt - The.Matrix.1999.eng.srt
ImportError: No module named pkg_resources
- you need to install setuptools for python. See here: https://pypi.python.org/pypi/setuptools#installation-instructions- Problems moving from downloader back to manager - you most likely haven't set up your categories correctly. The category options designated by SB/SR/CP/Sonarr need to match the ones set in your downloader either in the plugin options or in autoProcess.ini, and these categories ALL need to execute either SABPostProcess.py for SAB or NZBGetPostProcess.py for NZBGet. Make sure they match.
This project makes use of the following projects:
- http://www.sickbeard.com/
- http://couchpota.to/
- http://sabnzbd.org/
- http://github.com/senko/python-video-converter
- http://github.com/dbr/tvdb_api
- http://code.google.com/p/mutagen/
- http://imdbpy.sourceforge.net/
- http://github.com/danielgtaylor/qtfaststart
- http://github.com/clinton-hall/nzbToMedia
- http://github.com/wackou/guessit
- http://github.com/Diaoul/subliminal
Enjoy