Merge pull request #37 from DaRealestUK/v8.5.6

Adds nzbget-mp4 version of nzbget
This commit is contained in:
Robert Baker
2019-03-14 17:15:46 -07:00
committed by GitHub
16 changed files with 5181 additions and 0 deletions

2
apps/image/nzbget Normal file
View File

@@ -0,0 +1,2 @@
linuxserver/nzbget
linuxserver/nzbget:testing

402
apps/nzbget-mp4.yml Normal file
View File

@@ -0,0 +1,402 @@
#!/bin/bash
#
# NzbGet, with build in sickbeard_mp4_automator and ffmpeg build script
# Built for PGBlitz version 8.5.6
# Should be fine for versions above this too
#
# Title: PGBlitz (Reference Title File)
# Author(s): Admin9705
# URL: https://pgblitz.com - http://github.pgblitz.com
# GNU: General Public License v3.0
#################################################################################
---
- hosts: localhost
gather_facts: false
tasks:
# FACTS #######################################################################
- name: 'Set Known Facts'
set_fact:
pgrole: 'nzbget'
intport: '6789'
extport: '6789'
image: 'linuxserver/nzbget'
# CORE (MANDATORY) ############################################################
- name: 'Including cron job'
include_tasks: '/opt/communityapps/apps/_core.yml'
- name: 'Including folders'
include_tasks: '/opt/communityapps/apps/_downloaders.yml'
- name: Create nzb folder
file: 'path={{item}} state=directory mode=0775 owner=1000 group=1000'
with_items:
- '{{path.stdout}}/nzb'
# force: yes
- name: 'Including plugins'
include_tasks: '/opt/communityapps/apps/_plugins.yml'
- name: 'Checking for existing app data'
stat:
path: /opt/appdata/{{pgrole}}/nzbget.conf
register: confcheck
# EXTRAS FOR MP4 MODS ##########################################################
- name: 'Create {{pgrole}} mp4 directories'
file: 'path={{item}} state=directory mode=0775 owner=1000 group=1000 recurse=yes'
with_items:
- '/opt/appdata/{{pgrole}}'
- '/opt/appdata/{{pgrole}}/cont-init.d'
- '/opt/appdata/{{pgrole}}/installer'
- '/opt/appdata/{{pgrole}}/scripts'
- '/opt/appdata/{{pgrole}}/scripts/MP4_Automator'
- '/opt/appdata/{{pgrole}}/ffmpeg-build'
- '/opt/appdata/{{pgrole}}/services.d'
- name: 'Copy custom init scripts into directory for {{pgrole}}'
copy:
src: /opt/communityapps/apps/templates/nzbget-mp4/cont-init.d/30-config
dest: /opt/appdata/{{pgrole}}/cont-init.d
directory_mode: yes
force: yes
owner: 1000
group: 1000
mode: 0755
- name: 'Copy custom install scripts into directory for {{pgrole}}'
copy:
src: /opt/communityapps/apps/templates/nzbget-mp4/installer/installer.sh
dest: /opt/appdata/{{pgrole}}/installer
directory_mode: yes
force: yes
owner: 1000
group: 1000
mode: 0755
- name: 'Copy custom mp4 config into directory for {{pgrole}}'
copy:
src: /opt/communityapps/apps/templates/nzbget-mp4/MP4_Automator/autoProcess.ini
dest: /opt/appdata/{{pgrole}}/scripts/MP4_Automator
directory_mode: yes
force: yes
owner: 1000
group: 1000
mode: 0755
- name: 'Copy custom NZBGetPostProcess script config into directory for {{pgrole}}'
copy:
src: /opt/communityapps/apps/templates/nzbget-mp4/MP4_Automator/TEMPLATEPPScript
dest: /opt/appdata/{{pgrole}}/
directory_mode: yes
force: yes
owner: 1000
group: 1000
mode: 0755
- name: 'Copy ffmpeg build script into directory for {{pgrole}}'
copy:
src: /opt/communityapps/apps/templates/nzbget-mp4/ffmpeg-build/web-install.sh
dest: /opt/appdata/{{pgrole}}/ffmpeg-build
directory_mode: yes
force: yes
owner: 1000
group: 1000
mode: 0755
- name: 'Copy ffmpeg build script into directory for {{pgrole}}'
copy:
src: /opt/communityapps/apps/templates/nzbget-mp4/ffmpeg-build/build-ffmpeg
dest: /opt/appdata/{{pgrole}}/ffmpeg-build
directory_mode: yes
force: yes
owner: 1000
group: 1000
mode: 0755
- name: 'Copy custom init scripts into directory for {{pgrole}}'
copy:
src: /opt/communityapps/apps/templates/nzbget-mp4/services.d/run
dest: /opt/appdata/{{pgrole}}/services.d
directory_mode: yes
force: yes
owner: 1000
group: 1000
mode: 0755
# LABELS ######################################################################
- name: 'Adding Traefik'
set_fact:
pg_labels:
traefik.enable: 'true'
traefik.port: '{{intport}}'
traefik.frontend.rule: 'Host:{{pgrole}}.{{domain.stdout}},{{tldset}}'
traefik.frontend.auth.forward.address: '{{gauth}}'
- name: 'Setting PG Volumes'
set_fact:
pg_volumes:
- '/etc/localtime:/etc/localtime:ro'
- '/opt/appdata/{{pgrole}}:/config'
- '{{path.stdout}}:{{path.stdout}}'
- '/mnt:/mnt'
- '/tmp:/tmp'
- '/opt/appdata/{{pgrole}}/cont-init.d:/etc/cont-init.d'
- '/opt/appdata/{{pgrole}}/services.d:/etc/services.d/nzbget'
- name: 'Setting PG ENV'
set_fact:
pg_env:
PUID: '1000'
PGID: '1000'
LC_ALL: 'C'
# MAIN DEPLOYMENT #############################################################
- name: 'Deploying {{pgrole}}'
docker_container:
name: '{{pgrole}}'
image: '{{image}}'
pull: yes
published_ports:
- '{{ports.stdout}}{{extport}}:{{intport}}'
volumes: '{{pg_volumes}}'
env: '{{pg_env}}'
restart_policy: unless-stopped
networks:
- name: plexguide
aliases:
- '{{pgrole}}'
state: started
labels: '{{pg_labels}}'
# CONFIGURATION #############################################################
- name: 'Waiting for {{pgrole}} to initialize'
wait_for:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
state: present
delay: 5
- name: 'Stopping {{pgrole}}'
docker_container:
name: '{{pgrole}}'
state: stopped
- name: Set Main Location
lineinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
regexp: '^MainDir\s*=.*'
line: 'MainDir=/config'
state: present
- name: Set download location
lineinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
regexp: '^DestDir\s*=.*'
line: 'DestDir={{path.stdout}}/downloads/{{pgrole}}'
state: present
- name: Set incomplete location
lineinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
regexp: '^InterDir\s*=.*'
line: 'InterDir={{path.stdout}}/incomplete/{{pgrole}}'
state: present
- name: Set TempDir
lineinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
regexp: '^TempDir\s*=.*'
line: 'TempDir=/tmp'
state: present
- name: Set NzbDir Location
lineinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
regexp: '^NzbDir\s*=.*'
line: 'NzbDir={{path.stdout}}/nzb'
state: present
- name: ScriptDir
lineinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
regexp: '^ScriptDir\s*=.*'
line: 'ScriptDir=${MainDir}/scripts'
state: present
# FIRST TIME CONFIGURATION #############################################################
- name: 'Configuring {{pgrole}} for first time use'
block:
- name: Lowercase & Set Movie Category
lineinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
regexp: '^Category1.Name\s*=.*'
line: 'Category1.Name=movies'
state: present
- name: Set Location of Movies
lineinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
regexp: '^Category1.DestDir\s*=.*'
line: 'Category1.DestDir='
state: present
- name: Set postprocess of Movies
lineinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
regexp: '^Category1.Extensions\s*=.*'
line: 'Category1.Extensions=MP4_Automator/NZBGetPostProcess.py'
state: present
- name: Lowercase & Set TV Category
lineinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
regexp: '^Category2.Name\s*=.*'
line: 'Category2.Name=tv'
state: present
- name: Set Location of TV
lineinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
regexp: '^Category2.DestDir\s*=.*'
line: 'Category2.DestDir='
state: present
- name: Set postprocess of TV
lineinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
regexp: '^Category2.Extensions\s*=.*'
line: 'Category2.Extensions=MP4_Automator/NZBGetPostProcess.py'
state: present
- name: Lowercase & Set Music Category
lineinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
regexp: '^Category3.Name\s*=.*'
line: 'Category3.Name=music'
state: present
- name: Set Location of Music
lineinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
regexp: '^Category3.DestDir\s*=.*'
line: 'Category3.DestDir='
state: present
- name: Lowercase & Set EBook Category
lineinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
regexp: '^Category4.Name\s*=.*'
line: 'Category4.Name=ebooks'
state: present
- name: Set Location of EBooks
lineinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
regexp: '^Category4.DestDir\s*=.*'
line: 'Category4.DestDir='
state: present
- name: Lowercase & Set abook Category
lineinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
regexp: 'Category5.Name\s*=.*'
line: 'Category5.Name=abooks'
state: present
- name: Set Location of aBooks
lineinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
regexp: 'Category5.DestDir\s*=.*'
line: 'Category5.DestDir='
state: present
- name: Set Global Extensions
lineinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
regexp: '^Extensions\s*=.*'
line: 'Extensions=unzip.py'
state: present
- name: Set ScriptOrder
lineinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
regexp: '^ScriptOrder\s*=.*'
line: 'ScriptOrder=unzip.py, MP4_Automator/NZBGetPostProcess.py'
state: present
- name: Set mp4 script location
lineinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
regexp: '^MP4_Automator/NZBGetPostProcess.py:MP4_FOLDER\s*=.*'
line: 'MP4_Automator/NZBGetPostProcess.py:MP4_FOLDER=/config/scripts/MP4_Automator/'
state: present
- name: Set mp4 conversion true
lineinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
regexp: '^MP4_Automator/NZBGetPostProcess.py:SHOULDCONVERT\s*=.*'
line: 'MP4_Automator/NZBGetPostProcess.py:SHOULDCONVERT=True'
state: present
- name: Default User
lineinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
regexp: '^ControlUsername\s*=.*'
line: 'ControlUsername='
state: present
- name: Default Password
lineinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
regexp: 'ControlPassword\s*=.*'
line: 'ControlPassword='
state: present
- name: DirectUnpack Set to On
lineinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
regexp: '^DirectUnpack\s*=.*'
line: 'DirectUnpack=yes'
state: present
- name: HealthCheck
lineinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
regexp: '^HealthCheck\s*=.*'
line: 'HealthCheck=Delete'
state: present
- name: Set DiskSpace
lineinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
regexp: '^DiskSpace\s*=.*'
line: 'DiskSpace=25000'
state: present
- name: Remove Generic Task
lineinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
regexp: '{{ item.regexp }}'
state: absent
with_items:
- { regexp: '.Task1\.Time\=' }
- { regexp: '.Task1\.WeekDays\=' }
- { regexp: '.Task1\.Command\=' }
- { regexp: '.Task1\.Param\=' }
- name: Unpause
blockinfile:
path: '/opt/appdata/{{pgrole}}/nzbget.conf'
block: |
Task1.Time=*,*:00,*:30
Task1.WeekDays=1-7
Task1.Command=UnpauseDownload
Task1.Param=
insertafter: '^### SCHEDULER'
when: not confcheck.stat.exists
- name: Restart {{pgrole}}
docker_container:
name: '{{pgrole}}'
state: started

View File

@@ -0,0 +1,27 @@
#!/usr/bin/with-contenv bash
# delete lock file if found
[[ -f /downloads/nzbget.lock ]] && \
rm /downloads/nzbget.lock
# check if config file exists in /config
[[ ! -f /config/nzbget.conf ]] && \
cp /defaults/nzbget.conf /config/nzbget.conf
# permissions
chown 1000:1000 \
/downloads
chown 1000:1000 -R \
/app/nzbget \
/config
chmod u+rw \
/config/nzbget.conf
chmod 777 -R \
/config
chmod 777 -R \
/app/nzbget
chmod 777 -R \
/downloads
exec /config/installer/installer.sh

View File

@@ -0,0 +1,400 @@
#!/bin/bash
# https://github.com/markus-perl/ffmpeg-build-script
VERSION=1.1
CWD=$(pwd)
PACKAGES="$CWD/packages"
WORKSPACE="$CWD/workspace"
CC=clang
LDFLAGS="-L${WORKSPACE}/lib -lm"
CFLAGS="-I${WORKSPACE}/include"
PKG_CONFIG_PATH="${WORKSPACE}/lib/pkgconfig"
ADDITIONAL_CONFIGURE_OPTIONS=""
# Speed up the process
# Env Var NUMJOBS overrides automatic detection
if [[ -n $NUMJOBS ]]; then
MJOBS=$NUMJOBS
elif [[ -f /proc/cpuinfo ]]; then
MJOBS=$(grep -c processor /proc/cpuinfo)
elif [[ "$OSTYPE" == "darwin"* ]]; then
MJOBS=$(sysctl -n machdep.cpu.thread_count)
ADDITIONAL_CONFIGURE_OPTIONS="--enable-videotoolbox"
else
MJOBS=4
fi
make_dir () {
if [ ! -d $1 ]; then
if ! mkdir $1; then
printf "\n Failed to create dir %s" "$1";
exit 1
fi
fi
}
remove_dir () {
if [ -d $1 ]; then
rm -r "$1"
fi
}
download () {
DOWNLOAD_PATH=$PACKAGES;
if [ ! -z "$3" ]; then
mkdir -p $PACKAGES/$3
DOWNLOAD_PATH=$PACKAGES/$3
fi;
if [ ! -f "$DOWNLOAD_PATH/$2" ]; then
echo "Downloading $1"
curl -L --silent -o "$DOWNLOAD_PATH/$2" "$1"
EXITCODE=$?
if [ $EXITCODE -ne 0 ]; then
echo ""
echo "Failed to download $1. Exitcode $EXITCODE. Retrying in 10 seconds";
sleep 10
curl -L --silent -o "$DOWNLOAD_PATH/$2" "$1"
fi
EXITCODE=$?
if [ $EXITCODE -ne 0 ]; then
echo ""
echo "Failed to download $1. Exitcode $EXITCODE";
exit 1
fi
echo "... Done"
if ! tar -xvf "$DOWNLOAD_PATH/$2" -C "$DOWNLOAD_PATH" 2>/dev/null >/dev/null; then
echo "Failed to extract $2";
exit 1
fi
fi
}
execute () {
echo "$ $*"
OUTPUT=$($@ 2>&1)
if [ $? -ne 0 ]; then
echo "$OUTPUT"
echo ""
echo "Failed to Execute $*" >&2
exit 1
fi
}
build () {
echo ""
echo "building $1"
echo "======================="
if [ -f "$PACKAGES/$1.done" ]; then
echo "$1 already built. Remove $PACKAGES/$1.done lockfile to rebuild it."
return 1
fi
return 0
}
command_exists() {
if ! [[ -x $(command -v "$1") ]]; then
return 1
fi
return 0
}
build_done () {
touch "$PACKAGES/$1.done"
}
echo "ffmpeg-build-script v$VERSION"
echo "========================="
echo ""
case "$1" in
"--cleanup")
remove_dir $PACKAGES
remove_dir $WORKSPACE
echo "Cleanup done."
echo ""
exit 0
;;
"--build")
;;
*)
echo "Usage: $0"
echo " --build: start building process"
echo " --cleanup: remove all working dirs"
echo " --help: show this help"
echo ""
exit 0
;;
esac
echo "Using $MJOBS make jobs simultaneously."
make_dir $PACKAGES
make_dir $WORKSPACE
export PATH=${WORKSPACE}/bin:$PATH
if ! command_exists "make"; then
echo "make not installed.";
exit 1
fi
if ! command_exists "g++"; then
echo "g++ not installed.";
exit 1
fi
if ! command_exists "curl"; then
echo "curl not installed.";
exit 1
fi
if build "yasm"; then
download "http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz" "yasm-1.3.0.tar.gz"
cd $PACKAGES/yasm-1.3.0 || exit
execute ./configure --prefix=${WORKSPACE}
execute make -j $MJOBS
execute make install
build_done "yasm"
fi
if build "nasm"; then
download "http://www.nasm.us/pub/nasm/releasebuilds/2.13.03/nasm-2.13.03.tar.gz" "nasm.tar.gz"
cd $PACKAGES/nasm-2.13.03 || exit
execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
execute make -j $MJOBS
execute make install
build_done "nasm"
fi
if build "opencore"; then
download "http://downloads.sourceforge.net/project/opencore-amr/opencore-amr/opencore-amr-0.1.5.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fopencore-amr%2Ffiles%2Fopencore-amr%2F&ts=1442256558&use_mirror=netassist" "opencore-amr-0.1.5.tar.gz"
cd $PACKAGES/opencore-amr-0.1.5 || exit
execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
execute make -j $MJOBS
execute make install
build_done "opencore"
fi
if build "libvpx"; then
download "https://github.com/webmproject/libvpx/archive/v1.7.0.tar.gz" "libvpx-1.7.0.tar.gz"
cd $PACKAGES/libvpx-*0 || exit
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "Applying Darwin patch"
sed "s/,--version-script//g" build/make/Makefile > build/make/Makefile.patched
sed "s/-Wl,--no-undefined -Wl,-soname/-Wl,-undefined,error -Wl,-install_name/g" build/make/Makefile.patched > build/make/Makefile
fi
execute ./configure --prefix=${WORKSPACE} --disable-unit-tests --disable-shared
execute make -j $MJOBS
execute make install
build_done "libvpx"
fi
if build "lame"; then
download "http://kent.dl.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz" "lame-3.100.tar.gz"
cd $PACKAGES/lame-3.100 || exit
execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
execute make -j $MJOBS
execute make install
build_done "lame"
fi
if build "xvidcore"; then
download "http://downloads.xvid.org/downloads/xvidcore-1.3.4.tar.gz" "xvidcore-1.3.4.tar.gz"
cd $PACKAGES/xvidcore || exit
cd build/generic || exit
execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
execute make -j $MJOBS
execute make install
if [[ -f ${WORKSPACE}/lib/libxvidcore.4.dylib ]]; then
execute rm "${WORKSPACE}/lib/libxvidcore.4.dylib"
fi
build_done "xvidcore"
fi
if build "x264"; then
download "http://ftp.videolan.org/pub/x264/snapshots/x264-snapshot-20190204-2245-stable.tar.bz2" "last_x264.tar.bz2"
cd $PACKAGES/x264-snapshot-* || exit
if [[ "$OSTYPE" == "linux-gnu" ]]; then
execute ./configure --prefix=${WORKSPACE} --enable-static --enable-pic CXXFLAGS="-fPIC"
else
execute ./configure --prefix=${WORKSPACE} --enable-static --enable-pic
fi
execute make -j $MJOBS
execute make install
execute make install-lib-static
build_done "x264"
fi
if build "libogg"; then
download "http://downloads.xiph.org/releases/ogg/libogg-1.3.3.tar.gz" "libogg-1.3.3.tar.gz"
cd $PACKAGES/libogg-1.3.3 || exit
execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
execute make -j $MJOBS
execute make install
build_done "libogg"
fi
if build "libvorbis"; then
download "http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.6.tar.gz" "libvorbis-1.3.6.tar.gz"
cd $PACKAGES/libvorbis-1.3.6 || exit
execute ./configure --prefix=${WORKSPACE} --with-ogg-libraries=${WORKSPACE}/lib --with-ogg-includes=${WORKSPACE}/include/ --enable-static --disable-shared --disable-oggtest
execute make -j $MJOBS
execute make install
build_done "libvorbis"
fi
if build "libtheora"; then
download "http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.gz" "libtheora-1.1.1.tar.bz"
cd $PACKAGES/libtheora-1.1.1 || exit
sed "s/-fforce-addr//g" configure > configure.patched
chmod +x configure.patched
mv configure.patched configure
execute ./configure --prefix=${WORKSPACE} --with-ogg-libraries=${WORKSPACE}/lib --with-ogg-includes=${WORKSPACE}/include/ --with-vorbis-libraries=${WORKSPACE}/lib --with-vorbis-includes=${WORKSPACE}/include/ --enable-static --disable-shared --disable-oggtest --disable-vorbistest --disable-examples --disable-asm
execute make -j $MJOBS
execute make install
build_done "libtheora"
fi
if build "pkg-config"; then
download "http://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz" "pkg-config-0.29.2.tar.gz"
cd $PACKAGES/pkg-config-0.29.2 || exit
execute ./configure --silent --prefix=${WORKSPACE} --with-pc-path=${WORKSPACE}/lib/pkgconfig --with-internal-glib
execute make -j $MJOBS
execute make install
build_done "pkg-config"
fi
if build "cmake"; then
download "https://cmake.org/files/v3.11/cmake-3.11.3.tar.gz" "cmake-3.11.3.tar.gz"
cd $PACKAGES/cmake-3.11.3 || exit
rm Modules/FindJava.cmake
perl -p -i -e "s/get_filename_component.JNIPATH/#get_filename_component(JNIPATH/g" Tests/CMakeLists.txt
perl -p -i -e "s/get_filename_component.JNIPATH/#get_filename_component(JNIPATH/g" Tests/CMakeLists.txt
execute ./configure --prefix=${WORKSPACE}
execute make -j $MJOBS
execute make install
build_done "cmake"
fi
if build "vid_stab"; then
download "https://codeload.github.com/georgmartius/vid.stab/legacy.tar.gz/release-0.98b" "vid.stab-0.98b-transcode-1.1-binary-x86_64.tgz"
cd $PACKAGES/georgmartius-vid* || exit
perl -p -i -e "s/vidstab SHARED/vidstab STATIC/" CMakeLists.txt
execute cmake -DCMAKE_INSTALL_PREFIX:PATH=${WORKSPACE} .
execute make install
build_done "vid_stab"
fi
if build "x265"; then
download "https://bitbucket.org/multicoreware/x265/downloads/x265_3.0.tar.gz" "x265-3.0.tar.gz"
cd $PACKAGES/x265_* || exit
cd source || exit
execute cmake -DCMAKE_INSTALL_PREFIX:PATH=${WORKSPACE} -DENABLE_SHARED:bool=off .
execute make -j $MJOBS
execute make install
sed "s/-lx265/-lx265 -lstdc++/g" "$WORKSPACE/lib/pkgconfig/x265.pc" > "$WORKSPACE/lib/pkgconfig/x265.pc.tmp"
mv "$WORKSPACE/lib/pkgconfig/x265.pc.tmp" "$WORKSPACE/lib/pkgconfig/x265.pc"
build_done "x265"
fi
if build "fdk_aac"; then
download "http://downloads.sourceforge.net/project/opencore-amr/fdk-aac/fdk-aac-0.1.6.tar.gz?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fopencore-amr%2Ffiles%2Ffdk-aac%2F&ts=1457561564&use_mirror=kent" "fdk-aac-0.1.6.tar.gz"
cd $PACKAGES/fdk-aac-0.1.6 || exit
execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
execute make -j $MJOBS
execute make install
build_done "fdk_aac"
fi
build "ffmpeg"
download "http://ffmpeg.org/releases/ffmpeg-4.1.tar.bz2" "ffmpeg-snapshot.tar.bz2"
cd $PACKAGES/ffmpeg-4.1 || exit
./configure $ADDITIONAL_CONFIGURE_OPTIONS \
--pkgconfigdir="$WORKSPACE/lib/pkgconfig" \
--prefix=${WORKSPACE} \
--pkg-config-flags="--static" \
--extra-cflags="-I$WORKSPACE/include" \
--extra-ldflags="-L$WORKSPACE/lib" \
--extra-libs="-lpthread -lm" \
--enable-static \
--disable-debug \
--disable-shared \
--disable-ffplay \
--disable-doc \
--enable-gpl \
--enable-version3 \
--enable-nonfree \
--enable-pthreads \
--enable-libvpx \
--enable-libmp3lame \
--enable-libtheora \
--enable-libvorbis \
--enable-libx264 \
--enable-libx265 \
--enable-runtime-cpudetect \
--enable-libfdk-aac \
--enable-avfilter \
--enable-libopencore_amrwb \
--enable-libopencore_amrnb \
--enable-filters \
--enable-libvidstab
execute make -j $MJOBS
execute make install
INSTALL_FOLDER="/usr/bin"
if [[ "$OSTYPE" == "darwin"* ]]; then
INSTALL_FOLDER="/usr/local/bin"
fi
echo ""
echo "Building done. The binary can be found here: $WORKSPACE/bin/ffmpeg"
echo ""
if [[ $AUTOINSTALL == "yes" ]]; then
if command_exists "sudo"; then
sudo cp "$WORKSPACE/bin/ffmpeg" "$INSTALL_FOLDER/ffmpeg"
sudo cp "$WORKSPACE/bin/ffprobe" "$INSTALL_FOLDER/ffprobe"
echo "Done. ffmpeg is now installed to your system"
fi
elif [[ ! $SKIPINSTALL == "yes" ]]; then
if command_exists "sudo"; then
read -r -p "Install the binary to your $INSTALL_FOLDER folder? [Y/n] " response
case $response in
[yY][eE][sS]|[yY])
sudo cp "$WORKSPACE/bin/ffmpeg" "$INSTALL_FOLDER/ffmpeg"
sudo cp "$WORKSPACE/bin/ffprobe" "$INSTALL_FOLDER/ffprobe"
echo "Done. ffmpeg is now installed to your system"
;;
esac
fi
fi
exit 0

View File

@@ -0,0 +1,40 @@
#!/bin/bash
# Helper script to download and run the build-ffmpeg script.
make_dir () {
if [ ! -d $1 ]; then
if ! mkdir $1; then
printf "\n Failed to create dir %s" "$1";
exit 1
fi
fi
}
command_exists() {
if ! [[ -x $(command -v "$1") ]]; then
return 1
fi
return 0
}
TARGET='ffmpeg-build'
if ! command_exists "curl"; then
echo "curl not installed.";
exit 1
fi
echo "ffmpeg-build-script-downloader v0.1"
echo "========================================="
echo ""
echo "First we create the ffmpeg build directory $TARGET"
make_dir $TARGET
cd $TARGET
echo "Now we download and execute the build script"
echo ""
bash build-ffmpeg --build

View File

@@ -0,0 +1,30 @@
#!/bin/bash
apk update
apk upgrade
apk add --no-cache git
apk add build-base gcc wget diffutils perl
apk add curl
git clone https://github.com/mdhiggins/sickbeard_mp4_automator.git /config/scripts/MP4_Automator/tmp
cp -r /config/scripts/MP4_Automator/tmp/* /config/scripts/MP4_Automator
rm -rf /config/scripts/MP4_Automator/tmp
git unstage
apk add --no-cache py-setuptools py-pip python-dev libffi-dev gcc musl-dev openssl-dev
pip install --upgrade PIP
pip install requests
pip install requests[security]
pip install requests-cache
pip install babelfish
pip install "guessit<2"
pip install "subliminal<2"
pip install qtfaststart
# As per https://github.com/mdhiggins/sickbeard_mp4_automator/issues/643
pip uninstall -y stevedore
pip install stevedore==1.19.1
#Remove default NZBGetPostProcess script settings, and replace with our own
rm /config/scripts/MP4_Automator/NZBGetPostProcess.py
cp /config/TEMPLATEPPScript /config/scripts/MP4_Automator/NZBGetPostProcess.py
#Build ffmpeg
cd /config
. /config/ffmpeg-build/web-install.sh
#Set script file permissions
chmod 777 -R /config/scripts

View File

@@ -0,0 +1,244 @@
#!/usr/bin/env python
#
##############################################################################
### NZBGET POST-PROCESSING SCRIPT ###
# Modified to enable multiple bypass categories,
# as per: https://github.com/mdhiggins/sickbeard_mp4_automator/issues/509
#
# Converts files and passes them to Sonarr for further processing.
#
# NOTE: This script requires Python to be installed on your system.
##############################################################################
### OPTIONS ###
# Change to full path to MP4 Automator folder. No quotes and a trailing /
#MP4_FOLDER=~/sickbeard_mp4_automator/
# Convert file before passing to destination (True, False)
#SHOULDCONVERT=False
# Category for Couchpotato
#CP_CAT=Couchpotato
# Category for Sonarr
#SONARR_CAT=Sonarr
# Category for Radarr
#RADARR_CAT=Radarr
# Category for Sickbeard
#SICKBEARD_CAT=Sickbeard
# Category for Sickrage
#SICKRAGE_CAT=Sickrage
# Category list (comma seperated) for bypassing any further processing but still converting
#BYPASS_CAT=tv,movies
# Custom output_directory setting
#OUTPUT_DIR=
### NZBGET POST-PROCESSING SCRIPT ###
##############################################################################
import os
import sys
import re
import json
import traceback
# Sanity checks for path string
MP4folder = os.environ['NZBPO_MP4_FOLDER'].strip()
MP4folder = MP4folder.replace('"', '')
MP4folder = MP4folder.replace("'", "")
MP4folder = MP4folder.replace("\\", "/")
if not(MP4folder.endswith("/")):
MP4folder += "/"
#DEBUG#print MP4folder+" the original is "+os.environ['NZBPO_MP4_FOLDER']
output_dir = None
if 'NZBPO_OUTPUT_DIR' in os.environ:
output_dir = os.environ['NZBPO_OUTPUT_DIR'].strip()
if len(output_dir) > 0:
output_dir = output_dir.replace('"', '')
output_dir = output_dir.replace("'", "")
output_dir = output_dir.replace("\\", "/")
if not(output_dir.endswith("/")):
output_dir += "/"
#DEBUG#print Overriding output directory
sys.path.append(MP4folder)
try:
from readSettings import ReadSettings
from mkvtomp4 import MkvtoMp4
from autoprocess import autoProcessMovie, autoProcessTV, autoProcessTVSR, sonarr, radarr
import logging
from logging.config import fileConfig
except ImportError:
print("[ERROR] Wrong path to sickbeard_mp4_automator: " + os.environ['NZBPO_MP4_FOLDER'])
print("[ERROR] %s" % traceback.print_exc())
sys.exit(0)
# Setup Logging
logpath = '/var/log/sickbeard_mp4_automator'
if os.name == 'nt':
logpath = MP4folder
elif not os.path.isdir(logpath):
try:
os.mkdir(logpath)
except:
logpath = MP4folder
configPath = os.path.abspath(os.path.join(MP4folder, 'logging.ini')).replace("\\", "\\\\")
logPath = os.path.abspath(os.path.join(logpath, 'index.log')).replace("\\", "\\\\")
fileConfig(configPath, defaults={'logfilename': logPath})
log = logging.getLogger("NZBGetPostProcess")
# Determine if conversion will take place
shouldConvert = (os.environ['NZBPO_SHOULDCONVERT'].lower() in ("yes", "true", "t", "1"))
if 'NZBOP_SCRIPTDIR' in os.environ and not os.environ['NZBOP_VERSION'][0:5] < '11.0':
log.info("Script triggered from NZBGet (11.0 or later).")
path = os.environ['NZBPP_DIRECTORY'] # Path to NZB directory
nzb = os.environ['NZBPP_NZBFILENAME'] # Original NZB name
category = os.environ['NZBPP_CATEGORY'] # NZB Category to determine destination
#DEBUG#print "Category is %s." % category
couchcat = os.environ['NZBPO_CP_CAT'].lower()
sonarrcat = os.environ['NZBPO_SONARR_CAT'].lower()
radarrcat = os.environ['NZBPO_RADARR_CAT'].lower()
sickbeardcat = os.environ['NZBPO_SICKBEARD_CAT'].lower()
sickragecat = os.environ['NZBPO_SICKRAGE_CAT'].lower()
bypass = os.environ['NZBPO_BYPASS_CAT'].lower().replace(' ','').split(',')
categories = [sickbeardcat, couchcat, sonarrcat, radarrcat, sickragecat]
log.debug("Path: %s" % path)
log.debug("NZB: %s" % nzb)
log.debug("Category: %s" % category)
log.debug("Categories: %s" % categories)
# NZBGet argv: all passed as environment variables.
clientAgent = "nzbget"
# Exit codes used by NZBGet
POSTPROCESS_PARCHECK = 92
POSTPROCESS_SUCCESS = 93
POSTPROCESS_ERROR = 94
POSTPROCESS_NONE = 95
# Check nzbget.conf options
status = 0
if os.environ['NZBOP_UNPACK'] != 'yes':
log.error("Please enable option \"Unpack\" in nzbget configuration file, exiting.")
sys.exit(POSTPROCESS_NONE)
# Check par status
if os.environ['NZBPP_PARSTATUS'] == '3':
log.error("Par-check successful, but Par-repair disabled, exiting")
sys.exit(POSTPROCESS_NONE)
if os.environ['NZBPP_PARSTATUS'] == '1':
log.error("Par-check failed, setting status \"failed\".")
status = 1
sys.exit(POSTPROCESS_NONE)
# Check unpack status
if os.environ['NZBPP_UNPACKSTATUS'] == '1':
log.error("Unpack failed, setting status \"failed\".")
status = 1
sys.exit(POSTPROCESS_NONE)
if os.environ['NZBPP_UNPACKSTATUS'] == '0' and os.environ['NZBPP_PARSTATUS'] != '2':
# Unpack is disabled or was skipped due to nzb-file properties or due to errors during par-check
for dirpath, dirnames, filenames in os.walk(os.environ['NZBPP_DIRECTORY']):
for file in filenames:
fileExtension = os.path.splitext(file)[1]
if fileExtension in ['.par2']:
log.error("Post-Process: Unpack skipped and par-check skipped (although par2-files exist), setting status \"failed\".")
status = 1
break
if os.path.isfile(os.path.join(os.environ['NZBPP_DIRECTORY'], "_brokenlog.txt")) and not status == 1:
log.error("Post-Process: _brokenlog.txt exists, download is probably damaged, exiting.")
status = 1
if not status == 1:
log.error("Neither par2-files found, _brokenlog.txt doesn't exist, considering download successful.")
# Check if destination directory exists (important for reprocessing of history items)
if not os.path.isdir(os.environ['NZBPP_DIRECTORY']):
log.error("Post-Process: Nothing to post-process: destination directory ", os.environ['NZBPP_DIRECTORY'], "doesn't exist.")
status = 1
sys.exit(POSTPROCESS_NONE)
# Make sure one of the appropriate categories is set
if category.lower() not in categories and category.lower() not in bypass:
log.error("Post-Process: No valid category detected. Category was %s." % (category))
status = 1
sys.exit(POSTPROCESS_NONE)
# Make sure there are no duplicate categories
if len(categories) != len(set(categories)):
log.error("Duplicate category detected. Category names must be unique.")
status = 1
sys.exit(POSTPROCESS_NONE)
# All checks done, now launching the script.
settings = ReadSettings(MP4folder, "autoProcess.ini")
if shouldConvert:
if output_dir:
settings.output_dir = output_dir
converter = MkvtoMp4(settings, logger=log)
for r, d, f in os.walk(path):
for files in f:
inputfile = os.path.join(r, files)
#DEBUG#print inputfile
#Ignores files under 50MB
if os.path.getsize(inputfile) > 50000000:
if MkvtoMp4(settings, logger=log).validSource(inputfile):
try:
output = converter.process(inputfile)
log.info("Successfully processed %s." % inputfile)
except:
log.exception("File processing failed.")
if converter.output_dir:
path = converter.output_dir
if (category.lower() == categories[0]):
#DEBUG#print "Sickbeard Processing Activated"
autoProcessTV.processEpisode(path, settings, nzb)
sys.exit(POSTPROCESS_SUCCESS)
elif (category.lower() == categories[1]):
#DEBUG#print "CouchPotato Processing Activated"
autoProcessMovie.process(path, settings, nzb, status)
sys.exit(POSTPROCESS_SUCCESS)
elif (category.lower() == categories[2]):
#DEBUG#print "Sonarr Processing Activated"
success = sonarr.processEpisode(path, settings, True)
if success:
sys.exit(POSTPROCESS_SUCCESS)
else:
sys.exit(POSTPROCESS_ERROR)
elif (category.lower() == categories[3]):
#DEBUG#print "Radarr Processing Activated"
success = radarr.processMovie(path, settings, True)
if success:
sys.exit(POSTPROCESS_SUCCESS)
else:
sys.exit(POSTPROCESS_ERROR)
elif (category.lower() == categories[4]):
#DEBUG#print "Sickrage Processing Activated"
autoProcessTVSR.processEpisode(path, settings, nzb)
sys.exit(POSTPROCESS_SUCCESS)
elif (category.lower() in bypass):
#DEBUG#print "Bypass Further Processing"
sys.exit(POSTPROCESS_NONE)
else:
log.error("This script can only be called from NZBGet (11.0 or later).")
sys.exit(0)

View File

@@ -0,0 +1,143 @@
[SickBeard]
host = sickbeard
port = 8081
username =
password =
web_root =
ssl = False
api_key =
[Sonarr]
host = sonarr
port = 8989
web_root =
ssl = False
apikey =
[Radarr]
host = radarr
port = 7878
web_root =
ssl = False
apikey =
[MP4]
ffmpeg = /config/ffmpeg-build/workspace/bin/ffmpeg
ffprobe = /config/ffmpeg-build/workspace/bin/ffprobe
threads = 1
output_directory =
copy_to =
move_to =
output_extension = mp4
output_format = mp4
delete_original = True
relocate_moov = True
video-codec = h264,x264
video-bitrate =
video-crf = 18
video-max-width =
h264-max-level = 4.1
use-qsv-decoder-with-encoder = True
ios-audio = libfdk_aac
ios-first-track-only = False
ios-audio-filter = dynaudnorm
max-audio-channels =
audio-codec = ac3,mp3,dts,dca,aac,libfdk_aac
audio-language = eng
audio-default-language = eng
audio-channel-bitrate = 256
audio-filter =
subtitle-codec = srt
subtitle-language = eng
subtitle-default-language =
subtitle-encoding =
fullpathguess = True
convert-mp4 = True
tagfile = True
tag-language = en
download-artwork = Poster
download-subs = True
embed-subs = False
sub-providers = addic7ed,podnapisi,thesubdb,opensubtitles
permissions = 0777
post-process = False
pix-fmt =
aac_adtstoasc = False
postopts = -preset,slower
preopts =
audio-copy-original = False
enable_dxva2_gpu_decode = False
ios-move-last = False
use-hevc-qsv-decoder = False
embed-only-internal-subs = False
audio-first-track-of-language = False
video-profile =
[CouchPotato]
host = couchpotato
port = 5050
username =
password =
web_root =
ssl = False
apikey =
delay = 65
method = renamer
delete_failed = False
[uTorrent]
convert =
couchpotato-label = couchpotato
sickbeard-label = sickbeard
sonarr-label = sonarr
bypass-label = bypass
sickrage-label = sickrage
webui = False
action_before = stop
action_after = removedata
host = http://utorrent:8080/
username =
password =
output_directory =
radarr-label = radarr
[Deluge]
host = deluge
username =
convert = True
password =
sonarr-label = sonarr
radarr-label = radarr
bypass-label = bypass
sickbeard-label = sickbeard
port = 12569
sickrage-label = sickrage
couchpotato-label = couchpotato
output_directory =
remove = true
[SABNZBD]
convert = True
sickrage-category = sickrage
sonarr-category = sonarr
radarr-category = radarr
bypass-category = bypass
couchpotato-category = couchpotato
sickbeard-category = sickbeard
output_directory =
[Sickrage]
host = sickrage
port = 8081
username =
password =
web_root =
ssl = False
api_key =
[Plex]
host = plex
port = 32400
refresh = False
token =

View File

@@ -0,0 +1,93 @@
#!/usr/bin/env python
#
# Title: PGBlitz (Reference Title File)
# Maintainer: Admin9705
# URL: https://pgblitz.com - http://github.pgblitz.com
# GNU: General Public License v3.0
#
# Additions: clinton-hall - https://github.com/Prinz23
################################################################################
import os
import sys
# NZBGet Exit Codes
NZBGET_POSTPROCESS_PARCHECK = 92
NZBGET_POSTPROCESS_SUCCESS = 93
NZBGET_POSTPROCESS_ERROR = 94
NZBGET_POSTPROCESS_NONE = 95
def is_sample(filePath, inputName, maxSampleSize, SampleIDs):
# 200 MB in bytes
SIZE_CUTOFF = int(maxSampleSize) * 1024 * 1024
if os.path.getsize(filePath) < SIZE_CUTOFF:
if 'SizeOnly' in SampleIDs:
return True
# Ignore 'sample' in files unless 'sample' in Torrent Name
for ident in SampleIDs:
if ident.lower() in filePath.lower() and not ident.lower() in inputName.lower():
return True
# Return False if none of these were met.
return False
if not os.environ.has_key('NZBOP_SCRIPTDIR'):
print "This script can only be called from NZBGet (11.0 or later)."
sys.exit(0)
if os.environ['NZBOP_VERSION'][0:5] < '11.0':
print "NZBGet Version %s is not supported. Please update NZBGet." % (str(os.environ['NZBOP_VERSION']))
sys.exit(0)
print "Script triggered from NZBGet Version %s." % (str(os.environ['NZBOP_VERSION']))
status = 0
if os.environ.has_key('NZBPP_TOTALSTATUS'):
if not os.environ['NZBPP_TOTALSTATUS'] == 'SUCCESS':
print "Download failed with status %s." % (os.environ['NZBPP_STATUS'])
status = 1
else:
# Check par status
if os.environ['NZBPP_PARSTATUS'] == '1' or os.environ['NZBPP_PARSTATUS'] == '4':
print "Par-repair failed, setting status \"failed\"."
status = 1
# Check unpack status
if os.environ['NZBPP_UNPACKSTATUS'] == '1':
print "Unpack failed, setting status \"failed\"."
status = 1
if os.environ['NZBPP_UNPACKSTATUS'] == '0' and os.environ['NZBPP_PARSTATUS'] == '0':
# Unpack was skipped due to nzb-file properties or due to errors during par-check
if os.environ['NZBPP_HEALTH'] < 1000:
print "Download health is compromised and Par-check/repair disabled or no .par2 files found. Setting status \"failed\"."
print "Please check your Par-check/repair settings for future downloads."
status = 1
else:
print "Par-check/repair disabled or no .par2 files found, and Unpack not required. Health is ok so handle as though download successful."
print "Please check your Par-check/repair settings for future downloads."
# Check if destination directory exists (important for reprocessing of history items)
if not os.path.isdir(os.environ['NZBPP_DIRECTORY']):
print "Nothing to post-process: destination directory", os.environ['NZBPP_DIRECTORY'], "doesn't exist. Setting status \"failed\"."
status = 1
# All checks done, now launching the script.
if status == 1:
sys.exit(NZBGET_POSTPROCESS_NONE)
mediaContainer = os.environ['NZBPO_MEDIAEXTENSIONS'].split(',')
SampleIDs = os.environ['NZBPO_SAMPLEIDS'].split(',')
for dirpath, dirnames, filenames in os.walk(os.environ['NZBPP_DIRECTORY']):
for file in filenames:
filePath = os.path.join(dirpath, file)
fileName, fileExtension = os.path.splitext(file)
if fileExtension in mediaContainer or ".*" in mediaContainer : # If the file is a video file
if is_sample(filePath, os.environ['NZBPP_NZBNAME'], os.environ['NZBPO_MAXSAMPLESIZE'], SampleIDs): # Ignore samples
print "Deleting sample file: ", filePath
try:
os.unlink(filePath)
except:
print "Error: unable to delete file", filePath
sys.exit(NZBGET_POSTPROCESS_ERROR)
sys.exit(NZBGET_POSTPROCESS_SUCCESS)

View File

@@ -0,0 +1,106 @@
#!/usr/bin/env python
#
# Title: PGBlitz (Reference Title File)
# Maintainer: Admin9705
# URL: https://pgblitz.com - http://github.pgblitz.com
# GNU: General Public License v3.0
#
# Additions: clinton-hall - https://github.com/Prinz23
################################################################################
import os
import sys
import shutil
# NZBGet Exit Codes
NZBGET_POSTPROCESS_PARCHECK = 92
NZBGET_POSTPROCESS_SUCCESS = 93
NZBGET_POSTPROCESS_ERROR = 94
NZBGET_POSTPROCESS_NONE = 95
if not os.environ.has_key('NZBOP_SCRIPTDIR'):
print "This script can only be called from NZBGet (11.0 or later)."
sys.exit(0)
if os.environ['NZBOP_VERSION'][0:5] < '11.0':
print "[ERROR] NZBGet Version %s is not supported. Please update NZBGet." % (str(os.environ['NZBOP_VERSION']))
sys.exit(0)
print "Script triggered from NZBGet Version %s." % (str(os.environ['NZBOP_VERSION']))
status = 0
if os.environ.has_key('NZBPP_TOTALSTATUS'):
if not os.environ['NZBPP_TOTALSTATUS'] == 'SUCCESS':
print "[ERROR] Download failed with status %s." % (os.environ['NZBPP_STATUS'])
status = 1
else:
# Check par status
if os.environ['NZBPP_PARSTATUS'] == '1' or os.environ['NZBPP_PARSTATUS'] == '4':
print "[ERROR] Par-repair failed, setting status \"failed\"."
status = 1
# Check unpack status
if os.environ['NZBPP_UNPACKSTATUS'] == '1':
print "[ERROR] Unpack failed, setting status \"failed\"."
status = 1
if os.environ['NZBPP_UNPACKSTATUS'] == '0' and os.environ['NZBPP_PARSTATUS'] == '0':
# Unpack was skipped due to nzb-file properties or due to errors during par-check
if os.environ['NZBPP_HEALTH'] < 1000:
print "[ERROR] Download health is compromised and Par-check/repair disabled or no .par2 files found. Setting status \"failed\"."
print "[ERROR] Please check your Par-check/repair settings for future downloads."
status = 1
else:
print "[ERROR] Par-check/repair disabled or no .par2 files found, and Unpack not required. Health is ok so handle as though download successful."
print "[WARNING] Please check your Par-check/repair settings for future downloads."
# Check if destination directory exists (important for reprocessing of history items)
if not os.path.isdir(os.environ['NZBPP_DIRECTORY']):
print "[ERROR] Nothing to post-process: destination directory", os.environ['NZBPP_DIRECTORY'], "doesn't exist. Setting status \"failed\"."
status = 1
# All checks done, now launching the script.
if status == 1:
sys.exit(NZBGET_POSTPROCESS_NONE)
def removeEmptyFolders(path, removeRoot=True):
#Function to remove empty folders
if not os.path.isdir(path):
return
# remove empty subfolders
print "[INFO] Checking for empty folders in:%s" % path
files = os.listdir(path)
if len(files):
for f in files:
fullpath = os.path.join(path, f)
if os.path.isdir(fullpath):
removeEmptyFolders(fullpath)
# if folder empty, delete it
files = os.listdir(path)
if len(files) == 0 and removeRoot:
print "[INFO] Removing empty folder:%s" % path
os.rmdir(path)
directory = os.path.normpath(os.environ['NZBPP_DIRECTORY'])
if os.environ['NZBPO_DESTINATIONDIRECTORY'] and os.path.isdir(os.environ['NZBPO_DESTINATIONDIRECTORY']):
destination = os.environ['NZBPO_DESTINATIONDIRECTORY']
if os.environ['NZBPO_APPENDCATEGORIES'] == 'yes':
destination = os.path.join(destination, os.environ['NZBPP_CATEGORY'])
else:
destination = directory
print "Flattening directory: %s" % (directory)
for dirpath, dirnames, filenames in os.walk(directory):
for fileName in filenames:
outputFile = os.path.join(dirpath, fileName)
if dirpath == directory:
continue
target = os.path.join(destination, fileName)
try:
shutil.move(outputFile, target)
except:
print "[ERROR] Could not flatten %s" % outputFile
removeEmptyFolders(directory) # Cleanup empty directories
sys.exit(NZBGET_POSTPROCESS_SUCCESS)

View File

@@ -0,0 +1,167 @@
#!/usr/bin/env python
#
# Title: PGBlitz (Reference Title File)
# Maintainer: Admin9705
# URL: https://pgblitz.com - http://github.pgblitz.com
# GNU: General Public License v3.0
#
# Original Author: clinton-hall
# https://github.com/clinton-hall/GetScripts/blob/master/SafeRename.py
#
# Modified By: desimaniac (No Acknowledgement of Source Above)
################################################################################
import os
import re
import shutil
import sys
# NZBGet Exit Codes
NZBGET_POSTPROCESS_PARCHECK = 92
NZBGET_POSTPROCESS_SUCCESS = 93
NZBGET_POSTPROCESS_ERROR = 94
NZBGET_POSTPROCESS_NONE = 95
############################################################
# EXTENSION STUFF
############################################################
def do_check():
if not os.environ.has_key('NZBOP_SCRIPTDIR'):
print "This script can only be called from NZBGet (11.0 or later)."
sys.exit(0)
if os.environ['NZBOP_VERSION'][0:5] < '11.0':
print "[ERROR] NZBGet Version %s is not supported. Please update NZBGet." % (str(os.environ['NZBOP_VERSION']))
sys.exit(0)
print "Script triggered from NZBGet Version %s." % (str(os.environ['NZBOP_VERSION']))
status = 0
if 'NZBPP_TOTALSTATUS' in os.environ:
if not os.environ['NZBPP_TOTALSTATUS'] == 'SUCCESS':
print "[ERROR] Download failed with status %s." % (os.environ['NZBPP_STATUS'])
status = 1
else:
# Check par status
if os.environ['NZBPP_PARSTATUS'] == '1' or os.environ['NZBPP_PARSTATUS'] == '4':
print "[ERROR] Par-repair failed, setting status \"failed\"."
status = 1
# Check unpack status
if os.environ['NZBPP_UNPACKSTATUS'] == '1':
print "[ERROR] Unpack failed, setting status \"failed\"."
status = 1
if os.environ['NZBPP_UNPACKSTATUS'] == '0' and os.environ['NZBPP_PARSTATUS'] == '0':
# Unpack was skipped due to nzb-file properties or due to errors during par-check
if os.environ['NZBPP_HEALTH'] < 1000:
print "[ERROR] Download health is compromised and Par-check/repair disabled or no .par2 files found. " \
"Setting status \"failed\"."
print "[ERROR] Please check your Par-check/repair settings for future downloads."
status = 1
else:
print "[ERROR] Par-check/repair disabled or no .par2 files found, and Unpack not required. Health is " \
"ok so handle as though download successful."
print "[WARNING] Please check your Par-check/repair settings for future downloads."
# Check if destination directory exists (important for reprocessing of history items)
if not os.path.isdir(os.environ['NZBPP_DIRECTORY']):
print "[ERROR] Nothing to post-process: destination directory", os.environ[
'NZBPP_DIRECTORY'], "doesn't exist. Setting status \"failed\"."
status = 1
# All checks done, now launching the script.
if status == 1:
sys.exit(NZBGET_POSTPROCESS_NONE)
def get_file_name(path):
try:
file_name = os.path.basename(path)
extensions = re.findall(r'\.([^.]+)', file_name)
ext = '.'.join(extensions)
name = file_name.replace(".%s" % ext, '')
return name, ext
except Exception:
pass
return None
def is_file_hash(file_name):
hash_regexp = [
r'^[a-fA-F0-9]{40}$',
r'^[a-fA-F0-9]{32}$',
r'^[a-f0-9]{128}$',
r'^[a-zA-Z0-9]{42}$'
]
for hash in hash_regexp:
if re.match(hash, file_name):
return True
return False
def find_files(folder, extension=None, depth=None):
file_list = []
start_count = folder.count(os.sep)
for path, subdirs, files in os.walk(folder, topdown=True):
for name in files:
if depth and path.count(os.sep) - start_count >= depth:
del subdirs[:]
continue
file = os.path.join(path, name)
if not extension:
file_list.append(file)
else:
if file.lower().endswith(extension.lower()):
file_list.append(file)
return sorted(file_list, key=lambda x: x.count(os.path.sep), reverse=True)
############################################################
# MAIN
############################################################
# do checks
do_check()
# retrieve required variables
directory = os.path.normpath(os.environ['NZBPP_DIRECTORY'])
nzb_name = os.environ['NZBPP_NZBFILENAME']
if nzb_name is None:
print("[ERROR] Unable to retrieve NZBPP_NZBFILENAME")
sys.exit(NZBGET_POSTPROCESS_ERROR)
nzb_name = nzb_name.replace('.nzb', '')
print("[INFO] Using \"%s\" for hashed filenames" % nzb_name)
print("[INFO] Scanning \"%s\" for hashed filenames" % directory)
# scan for files
found_files = find_files(directory)
if not found_files:
print("[INFO] No files were found in \"%s\"" % directory)
sys.exit(NZBGET_POSTPROCESS_NONE)
else:
print("[INFO] Found %d files to check for hashed filenames" % len(found_files))
# loop files checking for file hash
moved_files = 0
for found_file_path in found_files:
# set variable
dir_name = os.path.dirname(found_file_path)
file_name, file_ext = get_file_name(found_file_path)
# is this a file hash
if is_file_hash(file_name):
new_file_path = os.path.join(dir_name, "%s.%s" % (nzb_name, file_ext))
print("[INFO] Moving \"%s\" to \"%s\"" % (found_file_path, new_file_path))
try:
shutil.move(found_file_path, new_file_path)
moved_files += 1
except Exception:
print("[ERROR] Failed moving \"%s\" to \"%s\"" % (found_file_path, new_file_path))
print("[INFO] Finished processing \"%s\", moved %d files" % (directory, moved_files))
sys.exit(NZBGET_POSTPROCESS_SUCCESS)

View File

@@ -0,0 +1 @@

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,293 @@
#!/usr/bin/env python
#
# Title: PGBlitz (Reference Title File)
# Maintainer: Admin9705
# URL: https://pgblitz.com - http://github.pgblitz.com
# GNU: General Public License v3.0
#
# Additions: clinton-hall - https://github.com/Prinz23
################################################################################
import os
import sys
import re
import locale
reverse_list = [r"\.\d{2}e\d{2}s\.", r"\.p0612\.", r"\.[pi]0801\.", r"\.p027\.", r"\.[pi]675\.", r"\.[pi]084\.", r"\.p063\.", r"\b[45]62[xh]\.", r"\.yarulb\.", r"\.vtd[hp]\.",
r'\.(?:ld[.-]?)?bew\.', r"\.pir.?(shv|dov|bew|dvd|db|rb)\.", r"\brdvd\.", r"\.vts\.", r"\.reneercs\.", r"\.dcv\.", r"\b(pir|mac)dh\b", r"\.reporp\.", r"\.kcaper\.",
r"\.lanretni\.", r"\b3ca\b", r"\bcaa\b", r"\b3pm\b", r"\.cstn\.", r"\.5r\.", r"\brcs\b"]
reverse_pattern = re.compile('|'.join(reverse_list), flags=re.IGNORECASE)
season_pattern = re.compile(r"(.*\.\d{2}e\d{2}s\.)(.*)", flags=re.IGNORECASE)
word_pattern = re.compile(r"([^A-Z0-9]*[A-Z0-9]+)")
char_replace = [[r"(\w)1\.(\w)",r"\1i\2"]
]
garbage_name = re.compile(r"^[a-zA-Z0-9]{2,}$")
media_list = [r"\.s\d{2}e\d{2}\.", r"\.2160p\.", r"\.1080[pi]\.", r"\.720p\.", r"\.576[pi]\.", r"\.480[pi]\.", r"\.360p\.", r"\.[xh]26[45]\b", r"\.bluray\.", r"\.[hp]dtv\.",
r'\.web(?:[.-]?dl)?\.', r"\.(vhs|vod|dvd|web|bd|br).?rip\.", r"\.dvdr\b", r"\.stv\.", r"\.screener\.", r"\.vcd\.", r"\bhd(cam|rip)\b", r"\.proper\.", r"\.repack\.",
r"\.internal\.", r"\bac3\b", r"\baac\b", r"\bmp3\b", r"\.ntsc\.", r"\.pal\.", r"\.secam\.", r"\bdivx\b", r"\bxvid\b", r"\.r5\.", r"\.scr\."]
media_pattern = re.compile('|'.join(media_list), flags=re.IGNORECASE)
media_extentions = [".mkv", ".mp4", ".avi", ".wmv", ".divx", ".xvid"]
if 'nt' == os.name:
import ctypes
class WinEnv:
def __init__(self):
pass
@staticmethod
def get_environment_variable(name):
name = unicode(name) # ensures string argument is unicode
n = ctypes.windll.kernel32.GetEnvironmentVariableW(name, None, 0)
env_value = None
if n:
buf = ctypes.create_unicode_buffer(u'\0'*n)
ctypes.windll.kernel32.GetEnvironmentVariableW(name, buf, n)
env_value = buf.value
return env_value
def __getitem__(self, key):
return self.get_environment_variable(key)
def get(self, key, default=None):
r = self.get_environment_variable(key)
return r if r is not None else default
evn = WinEnv()
else:
class LinuxEnv(object):
def __init__(self, environ):
self.environ = environ
def __getitem__(self, key):
v = self.environ.get(key)
try:
return v.decode(SYS_ENCODING) if isinstance(v, str) else v
except (UnicodeDecodeError, UnicodeEncodeError):
return v
def get(self, key, default=None):
v = self[key]
return v if v is not None else default
evn = LinuxEnv(os.environ)
SYS_ENCODING = None
try:
locale.setlocale(locale.LC_ALL, '')
except (locale.Error, IOError):
pass
try:
SYS_ENCODING = locale.getpreferredencoding()
except (locale.Error, IOError):
pass
if not SYS_ENCODING or SYS_ENCODING in ('ANSI_X3.4-1968', 'US-ASCII', 'ASCII'):
SYS_ENCODING = 'UTF-8'
class ek:
def __init__(self):
pass
@staticmethod
def fix_string_encoding(x):
if str == type(x):
try:
return x.decode(SYS_ENCODING)
except UnicodeDecodeError:
return None
elif unicode == type(x):
return x
return None
@staticmethod
def fix_out_encoding(x):
if isinstance(x, basestring):
return ek.fix_string_encoding(x)
return x
@staticmethod
def fix_list_encoding(x):
if type(x) not in (list, tuple):
return x
return filter(lambda i: None is not i, map(ek.fix_out_encoding, x))
@staticmethod
def encode_item(x):
try:
return x.encode(SYS_ENCODING)
except UnicodeEncodeError:
return x.encode(SYS_ENCODING, 'ignore')
@staticmethod
def win_encode_unicode(x):
if isinstance(x, str):
try:
return x.decode('UTF-8')
except UnicodeDecodeError:
return x
return x
@staticmethod
def ek(func, *args, **kwargs):
if 'nt' == os.name:
# convert all str parameter values to unicode
args = tuple([x if not isinstance(x, str) else ek.win_encode_unicode(x) for x in args])
kwargs = {k: x if not isinstance(x, str) else ek.win_encode_unicode(x) for k, x in
kwargs.iteritems()}
func_result = func(*args, **kwargs)
else:
func_result = func(*[ek.encode_item(x) if type(x) == str else x for x in args], **kwargs)
if type(func_result) in (list, tuple):
return ek.fix_list_encoding(func_result)
elif str == type(func_result):
return ek.fix_string_encoding(func_result)
return func_result
class logger:
INFO = 'INFO'
DETAIL = 'DETAIL'
ERROR = 'ERROR'
WARNING = 'WARNING'
@staticmethod
def log(message, msg_type=INFO):
print('[%s] %s' % (msg_type, message))
def tryInt(s, s_default=0):
try:
return int(s)
except:
return s_default
# NZBGet V11+
# Check if the script is called from nzbget 11.0 or later
nzbget_version = evn.get('NZBOP_VERSION', '0.1')
nzbget_version = tryInt(nzbget_version[:nzbget_version.find(".")])
if nzbget_version >= 11:
logger.log("Script triggered from NZBGet (11.0 or later).")
# NZBGet argv: all passed as environment variables.
clientAgent = "nzbget"
# Exit codes used by NZBGet
POSTPROCESS_PARCHECK=92
POSTPROCESS_SUCCESS=93
POSTPROCESS_ERROR=94
POSTPROCESS_NONE=95
# Check nzbget.conf options
status = 0
if evn['NZBOP_UNPACK'] != 'yes':
logger.log("Please enable option \"Unpack\" in nzbget configuration file, exiting")
sys.exit(POSTPROCESS_NONE)
parstatus = evn['NZBPP_PARSTATUS']
# Check par status
if parstatus == '3':
logger.log("Par-check successful, but Par-repair disabled, exiting")
sys.exit(POSTPROCESS_NONE)
if parstatus == '1':
logger.log("Par-check failed, setting status \"failed\"")
status = 1
sys.exit(POSTPROCESS_NONE)
unpackstatus = evn['NZBPP_UNPACKSTATUS']
# Check unpack status
if unpackstatus == '1':
logger.log("Unpack failed, setting status \"failed\"")
status = 1
sys.exit(POSTPROCESS_NONE)
directory = evn['NZBPP_DIRECTORY']
if unpackstatus == '0' and parstatus != '2':
# Unpack is disabled or was skipped due to nzb-file properties or due to errors during par-check
for dirpath, dirnames, filenames in ek.ek(os.walk, directory):
for file in filenames:
fileExtension = ek.ek(os.path.splitext, file)[1]
if fileExtension in ['.par2']:
logger.log("Post-Process: Unpack skipped and par-check skipped (although par2-files exist), setting status \"failed\"g")
status = 1
break
if ek.ek(os.path.isfile, ek.ek(os.path.join, directory, "_brokenlog.txt")) and not status == 1:
logger.log("Post-Process: _brokenlog.txt exists, download is probably damaged, exiting")
status = 1
if not status == 1:
logger.log("Neither par2-files found, _brokenlog.txt doesn't exist, considering download successful")
# Check if destination directory exists (important for reprocessing of history items)
if not ek.ek(os.path.isdir, directory):
logger.log("Post-Process: Nothing to post-process: destination directory %s doesn't exist" % directory)
status = 1
# All checks done, now launching the script.
rd = False
videos = 0
old_name = None
new_name = None
base_name = ek.ek(os.path.basename, directory)
for dirpath, dirnames, filenames in ek.ek(os.walk, directory):
for file in filenames:
filePath = ek.ek(os.path.join, dirpath, file)
fileName, fileExtension = ek.ek(os.path.splitext, file)
dirname = ek.ek(os.path.dirname, filePath)
if reverse_pattern.search(fileName) is not None:
na_parts = season_pattern.search(fileName)
if na_parts is not None:
word_p = word_pattern.findall(na_parts.group(2))
new_words = ""
for wp in word_p:
if wp[0] == ".":
new_words += "."
new_words += re.sub(r"\W","",wp)
for cr in char_replace:
new_words = re.sub(cr[0],cr[1],new_words)
new_filename = new_words[::-1] + na_parts.group(1)[::-1]
else:
new_filename = fileName[::-1]
logger.log("reversing filename from: %s to %s" % (fileName, new_filename))
try:
ek.ek(os.rename, filePath, ek.ek(os.path.join, dirpath, new_filename + fileExtension))
rd = True
except Exception,e:
logger.log(e, logger.ERROR)
logger.log("Error: unable to rename file %s" % file, logger.ERROR)
pass
elif (fileExtension.lower() in media_extentions) and (garbage_name.search(fileName) is not None) and (media_pattern.search(base_name) is not None):
videos += 1
old_name = filePath
new_name = ek.ek(os.path.join, dirname, '%s%s' % (base_name, fileExtension))
if not rd and videos == 1 and old_name is not None and new_name is not None:
logger.log("renaming the File %s to the Dirname %s" % (ek.ek(os.path.basename, old_name), base_name))
try:
ek.ek(os.rename, old_name, new_name)
rd = True
except Exception,e:
logger.log(e, logger.ERROR)
logger.log("Error unable to rename file %s" % old_name, logger.ERROR)
pass
if rd:
sys.exit(POSTPROCESS_SUCCESS)
else:
sys.exit(POSTPROCESS_NONE)
else:
logger.log("This script can only be called from NZBGet (11.0 or later).", logger.ERROR)
sys.exit(0)

View File

@@ -0,0 +1,294 @@
#!/usr/bin/env python
#
##############################################################################
### NZBGET SCAN SCRIPT ###
# Unzips zipped nzbs.
#
# NOTE: This script requires Python to be installed on your system.
##############################################################################
### OPTIONS ###
### NZBGET SCAN SCRIPT ###
##############################################################################
import os, zipfile, tarfile, gzip, pickle, datetime, re, struct, locale
import rarfile.rarfile as rarfile
from gzip import FEXTRA, FNAME
if 'nt' == os.name:
import ctypes
class WinEnv:
def __init__(self):
pass
@staticmethod
def get_environment_variable(name):
name = unicode(name) # ensures string argument is unicode
n = ctypes.windll.kernel32.GetEnvironmentVariableW(name, None, 0)
result = None
if n:
buf = ctypes.create_unicode_buffer(u'\0'*n)
ctypes.windll.kernel32.GetEnvironmentVariableW(name, buf, n)
result = buf.value
return result
def __getitem__(self, key):
return self.get_environment_variable(key)
def get(self, key, default=None):
r = self.get_environment_variable(key)
return r if r is not None else default
env_var = WinEnv()
else:
class LinuxEnv(object):
def __init__(self, environ):
self.environ = environ
def __getitem__(self, key):
v = self.environ.get(key)
try:
return v.decode(SYS_ENCODING) if isinstance(v, str) else v
except (UnicodeDecodeError, UnicodeEncodeError):
return v
def get(self, key, default=None):
v = self[key]
return v if v is not None else default
env_var = LinuxEnv(os.environ)
SYS_ENCODING = None
try:
locale.setlocale(locale.LC_ALL, '')
except (locale.Error, IOError):
pass
try:
SYS_ENCODING = locale.getpreferredencoding()
except (locale.Error, IOError):
pass
if not SYS_ENCODING or SYS_ENCODING in ('ANSI_X3.4-1968', 'US-ASCII', 'ASCII'):
SYS_ENCODING = 'UTF-8'
filename = env_var.get('NZBNP_FILENAME')
if re.search(r"\.tar\.gz$", filename, flags=re.I) is None:
ext = os.path.splitext(filename)[1].lower()
else:
ext = '.tar.gz'
cat = env_var.get('NZBNP_CATEGORY')
dir = env_var.get('NZBNP_DIRECTORY')
prio = env_var.get('NZBNP_PRIORITY')
top = env_var.get('NZBNP_TOP')
pause = env_var.get('NZBNP_PAUSED')
if 'NZBNP_DUPEKEY' in os.environ:
dupekey = env_var.get('NZBNP_DUPEKEY')
dupescore = env_var.get('NZBNP_DUPESCORE')
dupemode = env_var.get('NZBNP_DUPEMODE')
else:
dupekey = None
dupescore = None
dupemode = None
tmp_zipinfo = os.path.join(os.environ.get('NZBOP_TEMPDIR'), r'nzbget\unzip_scan\info')
nzb_list = []
def read_gzip_info(gzipfile):
gf = gzipfile.fileobj
pos = gf.tell()
# Read archive size
gf.seek(-4, 2)
size = struct.unpack('<I', gf.read())[0]
gf.seek(0)
magic = gf.read(2)
if magic != '\037\213':
raise IOError, 'Not a gzipped file'
method, flag, mtime = struct.unpack("<BBIxx", gf.read(8))
if not flag & FNAME:
# Not stored in the header, use the filename sans .gz
gf.seek(pos)
fname = gzipfile.name
if fname.endswith('.gz'):
fname = fname[:-3]
return fname, size
if flag & FEXTRA:
# Read & discard the extra field, if present
gf.read(struct.unpack("<H", gf.read(2)))
# Read a null-terminated string containing the filename
fname = []
while True:
s = gf.read(1)
if not s or s=='\000':
break
fname.append(s)
gf.seek(pos)
return ''.join(fname), size
def save_obj(obj, name):
tp = os.path.dirname(name)
if not os.path.exists(tp):
try:
os.makedirs(tp)
except:
print "Error creating Dir " + tp
return
try:
with open(name, 'wb') as f:
pickle.dump(obj, f, pickle.HIGHEST_PROTOCOL)
except:
print "Error saving: " + name
def load_obj(name):
if os.path.isfile(name):
try:
with open(name, 'rb') as f:
return pickle.load(f)
except:
print "Error loading " + name
return None
else:
return None
def save_nzb_list():
if nzb_list:
save_obj(nzb_list, tmp_zipinfo)
else:
if os.path.isfile(tmp_zipinfo):
try:
os.unlink(tmp_zipinfo)
except:
print "Error deleting " + tmp_zipinfo
def load_nzb_list():
global nzb_list
nzb_list = load_obj(tmp_zipinfo)
if nzb_list:
now = datetime.datetime.now()
o_l = len(nzb_list)
nzb_list[:] = [el for el in nzb_list if (now - el[8]).days < 1]
if nzb_list is not None and o_l != len(nzb_list):
save_nzb_list()
def get_files(zf):
zi = zf.infolist()
zi[:] = [el for el in zi if os.path.splitext(el.filename)[1].lower() == '.nzb']
return zi
def get_tar_files(tf):
ti = tf.getmembers()
ti[:] = [el for el in ti if el.isfile() and os.path.splitext(el.name)[1].lower() == '.nzb']
return ti
def get_rar_files(rf):
ri = rf.infolist()
ri[:] = [el for el in ri if os.path.splitext(el.filename)[1].lower() == '.nzb']
return ri
def remove_filename():
try:
os.unlink(filename)
except:
print "Error deleting " + filename
if ext == '.zip':
load_nzb_list()
zipf = zipfile.ZipFile(filename, mode='r')
zf = get_files(zipf)
if zf:
zipf.extractall(path = dir, members = zf)
now = datetime.datetime.now()
for z in zf:
if nzb_list:
nzb_list.append([z.filename, cat, prio, top, pause, dupekey, dupescore, dupemode, now])
else:
nzb_list = [[z.filename, cat, prio, top, pause, dupekey, dupescore, dupemode, now]]
save_nzb_list()
zipf.close()
remove_filename()
elif ext in ['.tar.gz', '.tar', '.tgz']:
load_nzb_list()
tarf = tarfile.open(filename, mode='r')
tf = get_tar_files(tarf)
if tf:
tarf.extractall(path = dir, members = tf)
now = datetime.datetime.now()
for z in tf:
if nzb_list:
nzb_list.append([z.name, cat, prio, top, pause, dupekey, dupescore, dupemode, now])
else:
nzb_list = [[z.name, cat, prio, top, pause, dupekey, dupescore, dupemode, now]]
save_nzb_list()
tarf.close()
remove_filename()
elif ext == '.gz':
load_nzb_list()
gzf =gzip.open(filename, mode='rb')
out_filename, size = read_gzip_info(gzf)
if out_filename and os.path.splitext(out_filename)[1].lower() == '.nzb':
with open(os.path.join(os.path.dirname(filename), out_filename), 'wb') as outf:
outf.write(gzf.read())
outf.close()
if gzf and out_filename:
now = datetime.datetime.now()
if nzb_list:
nzb_list.append([os.path.basename(out_filename), cat, prio, top, pause, dupekey, dupescore, dupemode, now])
else:
nzb_list = [[os.path.basename(out_filename), cat, prio, top, pause, dupekey, dupescore, dupemode, now]]
save_nzb_list()
gzf.close()
remove_filename()
elif ext == '.rar':
load_nzb_list()
rarf = rarfile.RarFile(filename, mode='r')
rf = get_files(rarf)
if rf:
rarf.extractall(path = dir, members = rf)
now = datetime.datetime.now()
for r in rf:
if nzb_list:
nzb_list.append([r.filename, cat, prio, top, pause, dupekey, dupescore, dupemode, now])
else:
nzb_list = [[r.filename, cat, prio, top, pause, dupekey, dupescore, dupemode, now]]
save_nzb_list()
rarf.close()
remove_filename()
elif ext == '.nzb' and os.path.exists(tmp_zipinfo):
load_nzb_list()
if nzb_list:
ni = None
f_l = os.path.basename(filename).lower()
for i, nf in enumerate(nzb_list):
if os.path.basename(nf[0]).lower() == f_l:
ni = i
break
if ni is not None:
print "[NZB] CATEGORY=" + str(nzb_list[ni][1])
print "[NZB] PRIORITY=" + str(nzb_list[ni][2])
print "[NZB] TOP=" + str(nzb_list[ni][3])
print "[NZB] PAUSED=" + str(nzb_list[ni][4])
if dupekey is not None:
print "[NZB] DUPEKEY=" + str(nzb_list[ni][5])
print "[NZB] DUPESCORE=" + str(nzb_list[ni][6])
print "[NZB] DUPEMODE=" + str(nzb_list[ni][7])
del nzb_list[ni]
save_nzb_list()

View File

@@ -0,0 +1,7 @@
#!/usr/bin/with-contenv bash
umask 000
exec \
s6-envuidgid -nB 1000:1000 /app/nzbget/nzbget -s -c /config/nzbget.conf \
-o OutputMode=log