Skip to content

Compiling for Windows

Clinton Hall edited this page Jul 3, 2014 · 11 revisions

Compiling for Windows

Currently I am unable to compile these scripts due to changes in the code making this compilation too difficult for me :(

Installing python for Windows is not difficult and I would recommend using the source version of these scripts.

This page is primarily being used as a note to myself so I can more efficiently compile these on major updates without having to re-discover all those little issues ;)

If you want to compile your own windows .exe's from current dev branch, in order to roll out onto other computers, do the following:

Requirements

Python 2.7.3

Pywin 32

pyInstaller

TorrentToMedia.exe

  1. compile using pyinstaller with

     C:\Python27\python.exe C:\pyinstaller-2.0\pyinstaller.py -F -w C:\nzbToMedia\TorrentToMedia.py
    
     -F = single file, -w = suppresses console
    
  2. In order to get full functioning you need to include the following folders/packages in the same directory as TorrentToMedia.exe

     autoProcessMedia.cfg.sample (from this repo)
    
     nzbtomedia\extractor (folder from this repo)
    
     ffmpeg\bin\ffmpeg.exe (required if you want to transcode only)
    

nzbToMedia.exe

  1. compile using pyinstaller with

     C:\Python27\python.exe C:\pyinstaller-2.0\pyinstaller.py -F -w C:\nzbToMedia\nzbToMedia.py
    
     -F = single file, -w = suppresses console
    
  2. In order to get full functioning you need to include the following folders/packages in the same directory as nzbToMedia.exe

     autoProcessMedia.cfg.sample (from this repo)
    
     ffmpeg\bin\ffmpeg.exe (required if you want to transcode only)
    
  3. For NZBGet, you will need a .bat wrapper that will allow you to call this exe, but also allow the parameters to be set in the NZBGet Web UI. (you will note that the first 2 lines actually call the script and return the exit status, while the remainder is just the comments from the start of the nzbToMedia.py script.

     nzbToMedia.exe
     exit /b %errorlevel%
    
     ##############################################################################
     ### NZBGET POST-PROCESSING SCRIPT                                          ###
     
     # Post-Process to CouchPotato, SickBeard, Mylar, Gamez, HeadPhones.
     #
     # This script sends the download to your automated media management servers.
     #
     # NOTE: This script requires Python to be installed on your system.
     
     ##############################################################################
     ### OPTIONS                                                                ###
     
     ## CouchPotato
     
     # CouchPotato script category.
     #
     # category that gets called for post-processing with CouchPotatoServer.
     #cpsCategory=movie
     
     # CouchPotato api key.
     #cpsapikey=
     
     # CouchPotato host.
     #cpshost=localhost
     
     # CouchPotato port.
     #cpsport=5050
     
     # CouchPotato username.
     #cpsusername= 
     
     # CouchPotato password.
     #cpspassword=
     
     # CouchPotato uses ssl (0, 1).
     #
     # Set to 1 if using ssl, else set to 0.
     #cpsssl=0
     
     # CouchPotato URL_Base
     #
     # set this if using a reverse proxy.
     #cpsweb_root=
     
     # CouchPotato Postprocess Delay.
     #
     # must be at least 60 seconds.
     #cpsdelay=65
     
     # CouchPotato Postprocess Method (renamer, manage).
     #
     # use "renamer" for CPS renamer (default) or "manage" to call a manage update.
     #cpsmethod=renamer
     
     # CouchPotato Delete Failed Downloads (0, 1).
     #
     # set to 1 to delete failed, or 0 to leave files in place.
     #cpsdelete_failed=0
     
     # CouchPotatoServer and NZBGet are a different system (0, 1).
     #
     # set to 1 if CouchPotato and NZBGet are on a different system, or 0 if on the same system.
     #remoteCPS = 0
     
     ## SickBeard
     
     # SickBeard script category.
     #
     # category that gets called for post-processing with SickBeard.
     #sbCategory=tv
     
     # SickBeard host.
     #sbhost=localhost
     
     # SickBeard port.
     #sbport=8081
     
     # SickBeard username.
     #sbusername= 
     
     # SickBeard password.
     #sbpassword=
     
     # SickBeard uses ssl (0, 1).
     #
     # Set to 1 if using ssl, else set to 0.
     #sbssl=0
     
     # SickBeard web_root
     #
     # set this if using a reverse proxy.
     #sbweb_root=
     
     # SickBeard watch directory.
     #
     # set this if SickBeard and nzbGet are on different systems.
     #sbwatch_dir=
     
     # SickBeard uses failed fork (0, 1).
     #
     # set to 1 if using the custom "failed fork". Default sickBeard uses 0.
     #sbfailed_fork=0
     
     # SickBeard Delete Failed Downloads (0, 1)
     #
     # set to 1 to delete failed, or 0 to leave files in place.
     #sbdelete_failed=0
     
     ## HeadPhones
     
     # HeadPhones script category.
     #
     # category that gets called for post-processing with HeadHones.
     #hpCategory=music
     
     # HeadPhones api key.
     #hpapikey=
     
     # HeadPhones host.
     #hphost=localhost
     
     # HeadPhones port.
     #hpport=8181
     
     # HeadPhones username.
     #hpusername= 
     
     # HeadPhones password.
     #hppassword=
     
     # HeadPhones uses ssl (0, 1).
     #
     # Set to 1 if using ssl, else set to 0.
     #hpssl=0
     
     # HeadPhones web_root
     #
     # set this if using a reverse proxy.
     #hpweb_root=
     
     # HeadPhones Postprocess Delay.
     #
     # set as required to ensure correct processing.
     #hpdelay=65
     
     ## Mylar
     
     # Mylar script category.
     #
     # category that gets called for post-processing with Mylar.
     #myCategory=comics
     
     # Mylar host.
     #myhost=localhost
     
     # Mylar port.
     #myport=8090
     
     # Mylar username.
     #myusername= 
     
     # Mylar password.
     #mypassword=
     
     # Mylar uses ssl (0, 1).
     #
     # Set to 1 if using ssl, else set to 0.
     #myssl=0
     
     # Mylar web_root
     #
     # set this if using a reverse proxy.
     #myweb_root=
     
     ## Gamez
     
     # Gamez script category.
     #
     # category that gets called for post-processing with Gamez.
     #gzCategory=games
     
     # Gamez api key.
     #gzapikey=
     
     # Gamez host.
     #gzhost=localhost
     
     # Gamez port.
     #gzport=8085
     
     # Gamez username.
     #gzusername=
     
     # Gamez password.
     #gzpassword=
     
     # Gamez uses ssl (0, 1).
     #
     # Set to 1 if using ssl, else set to 0.
     #gzssl=0
     
     # Gamez web_root
     #
     # set this if using a reverse proxy.
     #gzweb_root=
     
     ## Extensions
     
     # Media Extensions
     #
     # This is a list of media extensions that may be transcoded if transcoder is enabled below.
     #mediaExtensions=.mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso
     
     ## Transcoder
     
     # Transcode (0, 1).
     #
     # set to 1 to transcode, otherwise set to 0.
     #transcode=0
     
     # create a duplicate, or replace the original (0, 1).
     #
     # set to 1 to cretae a new file or 0 to replace the original
     #duplicate=1
     
     # ignore extensions
     #
     # list of extensions that won't be transcoded. 
     #ignoreExtensions=.avi,.mkv
     
     # ffmpeg output settings.
     #outputVideoExtension=.mp4
     #outputVideoCodec=libx264
     #outputVideoPreset=medium
     #outputVideoFramerate=24
     #outputVideoBitrate=800k
     #outputAudioCodec=libmp3lame
     #outputAudioBitrate=128k
     #outputSubtitleCodec=
     
     ## WakeOnLan
     
     # use WOL (0, 1).
     #
     # set to 1 to send WOL broadcast to the mac and test the server (e.g. xbmc) on the host and port specified.
     #wolwake=0
     
     # WOL MAC
     #
     # enter the mac address of the system to be woken.
     #wolmac=00:01:2e:2D:64:e1
     
     # Set the Host and Port of a server to verify system has woken.
     #wolhost=192.168.1.37
     #wolport=80
     
     ### NZBGET POST-PROCESSING SCRIPT                                          ###
     ##############################################################################
    

Required 3rd party binaries

The extraction (7zip.exe) and the create hidden process (chp.exe) binaries are included in the "extractor" folder of this repo as they are relatively small.

the following binaries can downloaded from the links below:

ffmpeg.exe

chp.exe is flagged by some virus scans as "potentially harmful" due to the fact that by design it is intended to run processes that are hidden to the user. I believe this is safe, but you can choose to remove this file and the extraction will still work but 7zip will always pop-up a window while it is extracting.

debug work for compiling current dev branch

add files C:\nzbToMedia-dev\libs\guessit\ISO-639-2_utf-8.txt and ISO-3166-1_utf8.txt to libs directory in nzbToMedia

edit C:\nzbToMedia-dev\libs\guessit\fileutils.py and change the last def to

def load_file_in_same_dir(ref_file, filename):
    """Load a given file. Works even when the file is contained inside a zip."""
    path = os.path.join(os.path.dirname(sys.argv[0]), 'libs')
    return u(io.open(os.path.join(path,filename), encoding='utf-8').read())

and add

import sys

at the start of the script, before compiling.

edit C:\nzbToMedia-dev\nzbToMedia.py and C:\nzbToMedia-dev\TorrentToMedia.py and change the last 2 lines to

if __name__ == "__main__":
    sys.exit(main(sys.argv))

edit C:\nzbToMedia-dev\nzbtomedia_init_.py and change line 9 to

PROGRAM_DIR = os.path.dirname(sys.argv[0])

All should now run...

Clone this wiki locally