mirror of
https://github.com/mtan93/Apps-Community.git
synced 2026-03-08 05:31:59 +00:00
formatting
This commit is contained in:
@@ -7,11 +7,11 @@
|
||||
################################################################################
|
||||
|
||||
# Generates App List
|
||||
ls -la /opt/communityapps/apps/ | sed -e 's/.yml//g' \
|
||||
| awk '{print $9}' | tail -n +4 >> /var/plexguide/app.list
|
||||
ls -la /opt/communityapps/apps/ | sed -e 's/.yml//g' |
|
||||
awk '{print $9}' | tail -n +4 >>/var/plexguide/app.list
|
||||
|
||||
ls -la /opt/mycontainers/ | sed -e 's/.yml//g' \
|
||||
| awk '{print $9}' | tail -n +4 >> /var/plexguide/app.list
|
||||
ls -la /opt/mycontainers/ | sed -e 's/.yml//g' |
|
||||
awk '{print $9}' | tail -n +4 >>/var/plexguide/app.list
|
||||
# Enter Items Here to Prevent them From Showing Up on AppList
|
||||
sed -i -e "/traefik/d" /var/plexguide/app.list
|
||||
sed -i -e "/image*/d" /var/plexguide/app.list
|
||||
|
||||
@@ -48,8 +48,8 @@
|
||||
shell: "echo '{{pgrole}}' > /tmp/program_var"
|
||||
ignore_errors: True
|
||||
|
||||
# APPDATA
|
||||
|
||||
# APPDATA
|
||||
- name: 'Creating appdata folder if it does not exist.'
|
||||
shell: 'mkdir -p /opt/appdata/{{pgrole}}'
|
||||
|
||||
@@ -69,7 +69,6 @@
|
||||
shell: 'chmod -R 775 /opt/appdata/{{pgrole}}'
|
||||
when: '"plex" not in pgrole'
|
||||
|
||||
|
||||
# OVERWRITE IMAGES #############################################################
|
||||
- name: Check if Image Variable Exists
|
||||
stat:
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
set_fact:
|
||||
pg_labels:
|
||||
traefik.enable: 'true'
|
||||
traefik.backend: "{{pgrole}}"
|
||||
traefik.backend: '{{pgrole}}'
|
||||
traefik.port: '80'
|
||||
traefik.frontend.rule: 'Host:bit.{{domain.stdout}},{{pgrole}}.{{domain.stdout}},{{tldset}}'
|
||||
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
|
||||
- name: 'Set Known Facts'
|
||||
set_fact:
|
||||
pgrole: "embystats"
|
||||
intport: "5432"
|
||||
extport: "9049"
|
||||
image: "uping/embystat:beta-linux"
|
||||
pgrole: 'embystats'
|
||||
intport: '5432'
|
||||
extport: '9049'
|
||||
image: 'uping/embystat:beta-linux'
|
||||
|
||||
- name: 'Including cron job'
|
||||
include_tasks: '/opt/communityapps/apps/_core.yml'
|
||||
|
||||
@@ -75,7 +75,6 @@
|
||||
- '{{pgrole}}'
|
||||
state: started
|
||||
labels: '{{pg_labels}}'
|
||||
|
||||
##PG-Community
|
||||
|
||||
##PG-Community
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
|
||||
- name: 'Set Known Facts'
|
||||
set_fact:
|
||||
pgrole: "gazee"
|
||||
intport: "4242"
|
||||
extport: "4242"
|
||||
image: "linuxserver/gazee"
|
||||
pgrole: 'gazee'
|
||||
intport: '4242'
|
||||
extport: '4242'
|
||||
image: 'linuxserver/gazee'
|
||||
|
||||
- name: 'Including cron job'
|
||||
include_tasks: '/opt/communityapps/apps/_core.yml'
|
||||
|
||||
@@ -45,8 +45,8 @@
|
||||
pg_env:
|
||||
PUID: '1000'
|
||||
PGID: '1000'
|
||||
#### DB_PASSWORD: gitea
|
||||
|
||||
#### DB_PASSWORD: gitea
|
||||
# MAIN DEPLOYMENT #############################################################
|
||||
- name: 'Deploying {{pgrole}}'
|
||||
docker_container:
|
||||
|
||||
@@ -50,12 +50,12 @@
|
||||
pg_env:
|
||||
USER_ID: '1000'
|
||||
GROUP_ID: '1000'
|
||||
AUTOMATED_CONVERSION_PRESET: "Very Fast 1080p30"
|
||||
AUTOMATED_CONVERSION_FORMAT: "mp4"
|
||||
AUTOMATED_CONVERSION_PRESET_2: "HQ 1080p30 Surround"
|
||||
AUTOMATED_CONVERSION_FORMAT_2: "mp4"
|
||||
AUTOMATED_CONVERSION_PRESET_3: "H.264 MKV 1080p30"
|
||||
AUTOMATED_CONVERSION_FORMAT_3: "mkv"
|
||||
AUTOMATED_CONVERSION_PRESET: 'Very Fast 1080p30'
|
||||
AUTOMATED_CONVERSION_FORMAT: 'mp4'
|
||||
AUTOMATED_CONVERSION_PRESET_2: 'HQ 1080p30 Surround'
|
||||
AUTOMATED_CONVERSION_FORMAT_2: 'mp4'
|
||||
AUTOMATED_CONVERSION_PRESET_3: 'H.264 MKV 1080p30'
|
||||
AUTOMATED_CONVERSION_FORMAT_3: 'mkv'
|
||||
# SECURE_CONNECTION: 1
|
||||
|
||||
# MAIN DEPLOYMENT #############################################################
|
||||
|
||||
@@ -35,7 +35,7 @@ count=1
|
||||
while read p; do
|
||||
echo "$count - $p"
|
||||
echo "$p" >/tmp/display$count
|
||||
count=$[count+1]
|
||||
count=$((count + 1))
|
||||
done </opt/communityapps/apps/image/$image
|
||||
echo ""
|
||||
read -p '🚀 Type Number | PRESS [ENTER]: ' typed </dev/tty
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
|
||||
- name: 'Set Known Facts'
|
||||
set_fact:
|
||||
pgrole: "mariadb"
|
||||
intport: "3306"
|
||||
extport: "6603"
|
||||
image: "mariadb:latest"
|
||||
pgrole: 'mariadb'
|
||||
intport: '3306'
|
||||
extport: '6603'
|
||||
image: 'mariadb:latest'
|
||||
|
||||
- name: 'Including cron job'
|
||||
include_tasks: '/opt/communityapps/apps/_core.yml'
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
|
||||
- name: 'Set Known Facts'
|
||||
set_fact:
|
||||
pgrole: "medusa"
|
||||
intport: "8081"
|
||||
extport: "8081"
|
||||
image: "linuxserver/medusa"
|
||||
pgrole: 'medusa'
|
||||
intport: '8081'
|
||||
extport: '8081'
|
||||
image: 'linuxserver/medusa'
|
||||
|
||||
- name: 'Including cron job'
|
||||
include_tasks: '/opt/communityapps/apps/_core.yml'
|
||||
|
||||
@@ -73,9 +73,6 @@
|
||||
DEBUG: 'false'
|
||||
WEBUI_PORT: '{{intport}}'
|
||||
|
||||
|
||||
|
||||
|
||||
# MAIN DEPLOYMENT #############################################################
|
||||
- name: 'Checking for existing app data'
|
||||
stat:
|
||||
@@ -131,7 +128,6 @@
|
||||
value: '{{path.stdout}}/downloads/{{pgrole}}'
|
||||
state: present
|
||||
|
||||
|
||||
- name: Set TempPathEnabled
|
||||
ini_file:
|
||||
path: '/opt/appdata/{{pgrole}}/qBittorrent/config/qBittorrent.conf'
|
||||
@@ -154,7 +150,6 @@
|
||||
shell: mkdir /opt/appdata/{{pgrole}}/openvpn && touch mkdir /opt/appdata/{{pgrole}}/openvpn/OVPN\ files\ go\ here && chown -R {{puid}}:{{pgid}} /opt/appdata/{{pgrole}}/openvpn
|
||||
when: not ovpncheck.stat.exists
|
||||
|
||||
|
||||
# FIRST TIME CONFIGURATION ####################################################
|
||||
- name: 'Configuring {{pgrole}} for first time use'
|
||||
block:
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
- '/etc/localtime:/etc/localtime:ro'
|
||||
- '/mnt:/mnt'
|
||||
|
||||
|
||||
- name: 'Setting PG ENV'
|
||||
set_fact:
|
||||
pg_env:
|
||||
|
||||
@@ -11,8 +11,7 @@ torrentid=$1
|
||||
torrentname=$2
|
||||
torrentpath=$3
|
||||
|
||||
log()
|
||||
{
|
||||
log() {
|
||||
logger -t deluge-extractarchives "$@"
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,8 @@ try:
|
||||
import logging
|
||||
from logging.config import fileConfig
|
||||
except ImportError:
|
||||
print("[ERROR] Wrong path to sickbeard_mp4_automator: " + os.environ['NZBPO_MP4_FOLDER'])
|
||||
print("[ERROR] Wrong path to sickbeard_mp4_automator: " +
|
||||
os.environ['NZBPO_MP4_FOLDER'])
|
||||
print("[ERROR] %s" % traceback.print_exc())
|
||||
sys.exit(0)
|
||||
|
||||
@@ -90,20 +91,24 @@ elif not os.path.isdir(logpath):
|
||||
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("\\", "\\\\")
|
||||
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"))
|
||||
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
|
||||
# NZB Category to determine destination
|
||||
category = os.environ['NZBPP_CATEGORY']
|
||||
# DEBUG#print "Category is %s." % category
|
||||
|
||||
couchcat = os.environ['NZBPO_CP_CAT'].lower()
|
||||
@@ -132,7 +137,8 @@ if 'NZBOP_SCRIPTDIR' in os.environ and not os.environ['NZBOP_VERSION'][0:5] < '1
|
||||
status = 0
|
||||
|
||||
if os.environ['NZBOP_UNPACK'] != 'yes':
|
||||
log.error("Please enable option \"Unpack\" in nzbget configuration file, exiting.")
|
||||
log.error(
|
||||
"Please enable option \"Unpack\" in nzbget configuration file, exiting.")
|
||||
sys.exit(POSTPROCESS_NONE)
|
||||
|
||||
# Check par status
|
||||
@@ -159,26 +165,31 @@ if 'NZBOP_SCRIPTDIR' in os.environ and not os.environ['NZBOP_VERSION'][0:5] < '1
|
||||
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\".")
|
||||
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.")
|
||||
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.")
|
||||
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.")
|
||||
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))
|
||||
log.error(
|
||||
"Post-Process: No valid category detected. Category was %s." % (category))
|
||||
status = 1
|
||||
sys.exit(POSTPROCESS_NONE)
|
||||
|
||||
|
||||
@@ -141,4 +141,3 @@ host = plex
|
||||
port = 32400
|
||||
refresh = False
|
||||
token =
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
|
||||
# delete lock file if found
|
||||
[[ -f /downloads/nzbget.lock ]] && \
|
||||
[[ -f /downloads/nzbget.lock ]] &&
|
||||
rm /downloads/nzbget.lock
|
||||
|
||||
# check if config file exists in /config
|
||||
[[ ! -f /config/nzbget.conf ]] && \
|
||||
[[ ! -f /config/nzbget.conf ]] &&
|
||||
cp /defaults/nzbget.conf /config/nzbget.conf
|
||||
|
||||
# permissions
|
||||
|
||||
@@ -28,7 +28,7 @@ fi
|
||||
make_dir() {
|
||||
if [ ! -d $1 ]; then
|
||||
if ! mkdir $1; then
|
||||
printf "\n Failed to create dir %s" "$1";
|
||||
printf "\n Failed to create dir %s" "$1"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
@@ -42,12 +42,12 @@ remove_dir () {
|
||||
|
||||
download() {
|
||||
|
||||
DOWNLOAD_PATH=$PACKAGES;
|
||||
DOWNLOAD_PATH=$PACKAGES
|
||||
|
||||
if [ ! -z "$3" ]; then
|
||||
mkdir -p $PACKAGES/$3
|
||||
DOWNLOAD_PATH=$PACKAGES/$3
|
||||
fi;
|
||||
fi
|
||||
|
||||
if [ ! -f "$DOWNLOAD_PATH/$2" ]; then
|
||||
|
||||
@@ -57,7 +57,7 @@ download () {
|
||||
EXITCODE=$?
|
||||
if [ $EXITCODE -ne 0 ]; then
|
||||
echo ""
|
||||
echo "Failed to download $1. Exitcode $EXITCODE. Retrying in 10 seconds";
|
||||
echo "Failed to download $1. Exitcode $EXITCODE. Retrying in 10 seconds"
|
||||
sleep 10
|
||||
curl -L --silent -o "$DOWNLOAD_PATH/$2" "$1"
|
||||
fi
|
||||
@@ -65,14 +65,14 @@ download () {
|
||||
EXITCODE=$?
|
||||
if [ $EXITCODE -ne 0 ]; then
|
||||
echo ""
|
||||
echo "Failed to download $1. Exitcode $EXITCODE";
|
||||
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";
|
||||
echo "Failed to extract $2"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -113,7 +113,6 @@ command_exists() {
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
build_done() {
|
||||
touch "$PACKAGES/$1.done"
|
||||
}
|
||||
@@ -130,9 +129,9 @@ case "$1" in
|
||||
echo ""
|
||||
exit 0
|
||||
;;
|
||||
"--build")
|
||||
"--build") ;;
|
||||
|
||||
;;
|
||||
\
|
||||
*)
|
||||
echo "Usage: $0"
|
||||
echo " --build: start building process"
|
||||
@@ -151,17 +150,17 @@ make_dir $WORKSPACE
|
||||
export PATH=${WORKSPACE}/bin:$PATH
|
||||
|
||||
if ! command_exists "make"; then
|
||||
echo "make not installed.";
|
||||
echo "make not installed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command_exists "g++"; then
|
||||
echo "g++ not installed.";
|
||||
echo "g++ not installed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command_exists "curl"; then
|
||||
echo "curl not installed.";
|
||||
echo "curl not installed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -329,7 +328,6 @@ if build "fdk_aac"; then
|
||||
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
|
||||
@@ -375,7 +373,6 @@ 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"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
make_dir() {
|
||||
if [ ! -d $1 ]; then
|
||||
if ! mkdir $1; then
|
||||
printf "\n Failed to create dir %s" "$1";
|
||||
printf "\n Failed to create dir %s" "$1"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
@@ -21,7 +21,7 @@ command_exists() {
|
||||
TARGET='ffmpeg-build'
|
||||
|
||||
if ! command_exists "curl"; then
|
||||
echo "curl not installed.";
|
||||
echo "curl not installed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -37,4 +37,3 @@ echo "Now we download and execute the build script"
|
||||
echo ""
|
||||
|
||||
bash build-ffmpeg --build
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ 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
|
||||
@@ -29,15 +30,18 @@ def is_sample(filePath, inputName, maxSampleSize, SampleIDs):
|
||||
# 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']))
|
||||
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']))
|
||||
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':
|
||||
@@ -69,7 +73,8 @@ else:
|
||||
|
||||
# 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\"."
|
||||
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.
|
||||
@@ -83,7 +88,8 @@ for dirpath, dirnames, filenames in os.walk(os.environ['NZBPP_DIRECTORY']):
|
||||
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
|
||||
# Ignore samples
|
||||
if is_sample(filePath, os.environ['NZBPP_NZBNAME'], os.environ['NZBPO_MAXSAMPLESIZE'], SampleIDs):
|
||||
print "Deleting sample file: ", filePath
|
||||
try:
|
||||
os.unlink(filePath)
|
||||
|
||||
@@ -22,14 +22,17 @@ if not os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||
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']))
|
||||
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']))
|
||||
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'])
|
||||
print "[ERROR] Download failed with status %s." % (
|
||||
os.environ['NZBPP_STATUS'])
|
||||
status = 1
|
||||
|
||||
else:
|
||||
@@ -64,6 +67,7 @@ if not os.path.isdir(os.environ['NZBPP_DIRECTORY']):
|
||||
if status == 1:
|
||||
sys.exit(NZBGET_POSTPROCESS_NONE)
|
||||
|
||||
|
||||
def removeEmptyFolders(path, removeRoot=True):
|
||||
# Function to remove empty folders
|
||||
if not os.path.isdir(path):
|
||||
@@ -84,6 +88,7 @@ def removeEmptyFolders(path, removeRoot=True):
|
||||
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']
|
||||
|
||||
@@ -25,21 +25,25 @@ 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']))
|
||||
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']))
|
||||
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'])
|
||||
print "[ERROR] Download failed with status %s." % (
|
||||
os.environ['NZBPP_STATUS'])
|
||||
status = 1
|
||||
else:
|
||||
# Check par status
|
||||
@@ -144,7 +148,8 @@ 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))
|
||||
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:
|
||||
@@ -154,14 +159,18 @@ else:
|
||||
|
||||
# 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))
|
||||
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("[ERROR] Failed moving \"%s\" to \"%s\"" %
|
||||
(found_file_path, new_file_path))
|
||||
|
||||
print("[INFO] Finished processing \"%s\", moved %d files" % (directory, moved_files))
|
||||
print("[INFO] Finished processing \"%s\", moved %d files" %
|
||||
(directory, moved_files))
|
||||
|
||||
sys.exit(NZBGET_POSTPROCESS_SUCCESS)
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ For more details, refer to source.
|
||||
from __future__ import division, print_function
|
||||
|
||||
##
|
||||
## Imports and compat - support both Python 2.x and 3.x
|
||||
# Imports and compat - support both Python 2.x and 3.x
|
||||
##
|
||||
|
||||
import sys
|
||||
@@ -113,13 +113,16 @@ try:
|
||||
|
||||
class AES_CBC_Decrypt(object):
|
||||
"""Decrypt API"""
|
||||
|
||||
def __init__(self, key, iv):
|
||||
ciph = Cipher(algorithms.AES(key), modes.CBC(iv), default_backend())
|
||||
ciph = Cipher(algorithms.AES(key),
|
||||
modes.CBC(iv), default_backend())
|
||||
self.decrypt = ciph.decryptor().update
|
||||
|
||||
def pbkdf2_sha256(password, salt, iters):
|
||||
"""PBKDF2 with HMAC-SHA256"""
|
||||
ctx = pbkdf2.PBKDF2HMAC(hashes.SHA256(), 32, salt, iters, default_backend())
|
||||
ctx = pbkdf2.PBKDF2HMAC(
|
||||
hashes.SHA256(), 32, salt, iters, default_backend())
|
||||
return ctx.derive(password)
|
||||
|
||||
except ImportError:
|
||||
@@ -128,6 +131,7 @@ try:
|
||||
|
||||
class AES_CBC_Decrypt(object):
|
||||
"""Decrypt API"""
|
||||
|
||||
def __init__(self, key, iv):
|
||||
self.decrypt = AES.new(key, AES.MODE_CBC, iv).decrypt
|
||||
|
||||
@@ -173,7 +177,7 @@ __version__ = '3.0'
|
||||
__all__ = ['is_rarfile', 'RarInfo', 'RarFile', 'RarExtFile']
|
||||
|
||||
##
|
||||
## Module configuration. Can be tuned after importing.
|
||||
# Module configuration. Can be tuned after importing.
|
||||
##
|
||||
|
||||
#: default fallback charset
|
||||
@@ -222,7 +226,7 @@ HACK_SIZE_LIMIT = 20 * 1024 * 1024
|
||||
PATH_SEP = '/'
|
||||
|
||||
##
|
||||
## rar constants
|
||||
# rar constants
|
||||
##
|
||||
|
||||
# block types
|
||||
@@ -369,7 +373,7 @@ RAR5_OS_WINDOWS = 0
|
||||
RAR5_OS_UNIX = 1
|
||||
|
||||
##
|
||||
## internal constants
|
||||
# internal constants
|
||||
##
|
||||
|
||||
RAR_ID = b"Rar!\x1a\x07\x00"
|
||||
@@ -379,6 +383,7 @@ EMPTY = b''
|
||||
UTC = timezone(timedelta(0), 'UTC')
|
||||
BSIZE = 32 * 1024
|
||||
|
||||
|
||||
def _get_rar_version(xfile):
|
||||
'''Check quickly whether file is rar archive.
|
||||
'''
|
||||
@@ -391,83 +396,108 @@ def _get_rar_version(xfile):
|
||||
return 0
|
||||
|
||||
##
|
||||
## Public interface
|
||||
# Public interface
|
||||
##
|
||||
|
||||
|
||||
def is_rarfile(xfile):
|
||||
'''Check quickly whether file is rar archive.
|
||||
'''
|
||||
return _get_rar_version(xfile) > 0
|
||||
|
||||
|
||||
class Error(Exception):
|
||||
"""Base class for rarfile errors."""
|
||||
|
||||
|
||||
class BadRarFile(Error):
|
||||
"""Incorrect data in archive."""
|
||||
|
||||
|
||||
class NotRarFile(Error):
|
||||
"""The file is not RAR archive."""
|
||||
|
||||
|
||||
class BadRarName(Error):
|
||||
"""Cannot guess multipart name components."""
|
||||
|
||||
|
||||
class NoRarEntry(Error):
|
||||
"""File not found in RAR"""
|
||||
|
||||
|
||||
class PasswordRequired(Error):
|
||||
"""File requires password"""
|
||||
|
||||
|
||||
class NeedFirstVolume(Error):
|
||||
"""Need to start from first volume."""
|
||||
|
||||
|
||||
class NoCrypto(Error):
|
||||
"""Cannot parse encrypted headers - no crypto available."""
|
||||
|
||||
|
||||
class RarExecError(Error):
|
||||
"""Problem reported by unrar/rar."""
|
||||
|
||||
|
||||
class RarWarning(RarExecError):
|
||||
"""Non-fatal error"""
|
||||
|
||||
|
||||
class RarFatalError(RarExecError):
|
||||
"""Fatal error"""
|
||||
|
||||
|
||||
class RarCRCError(RarExecError):
|
||||
"""CRC error during unpacking"""
|
||||
|
||||
|
||||
class RarLockedArchiveError(RarExecError):
|
||||
"""Must not modify locked archive"""
|
||||
|
||||
|
||||
class RarWriteError(RarExecError):
|
||||
"""Write error"""
|
||||
|
||||
|
||||
class RarOpenError(RarExecError):
|
||||
"""Open error"""
|
||||
|
||||
|
||||
class RarUserError(RarExecError):
|
||||
"""User error"""
|
||||
|
||||
|
||||
class RarMemoryError(RarExecError):
|
||||
"""Memory error"""
|
||||
|
||||
|
||||
class RarCreateError(RarExecError):
|
||||
"""Create error"""
|
||||
|
||||
|
||||
class RarNoFilesError(RarExecError):
|
||||
"""No files that match pattern were found"""
|
||||
|
||||
|
||||
class RarUserBreak(RarExecError):
|
||||
"""User stop"""
|
||||
|
||||
|
||||
class RarWrongPassword(RarExecError):
|
||||
"""Incorrect password"""
|
||||
|
||||
|
||||
class RarUnknownError(RarExecError):
|
||||
"""Unknown exit code"""
|
||||
|
||||
|
||||
class RarSignalExit(RarExecError):
|
||||
"""Unrar exited with signal"""
|
||||
|
||||
|
||||
class RarCannotExec(RarExecError):
|
||||
"""Executable not found."""
|
||||
|
||||
@@ -734,13 +764,15 @@ class RarFile(object):
|
||||
# entry lookup
|
||||
inf = self.getinfo(fname)
|
||||
if inf.isdir():
|
||||
raise TypeError("Directory does not have any data: " + inf.filename)
|
||||
raise TypeError(
|
||||
"Directory does not have any data: " + inf.filename)
|
||||
|
||||
# check password
|
||||
if inf.needs_password():
|
||||
psw = psw or self._password
|
||||
if psw is None:
|
||||
raise PasswordRequired("File %s requires password" % inf.filename)
|
||||
raise PasswordRequired(
|
||||
"File %s requires password" % inf.filename)
|
||||
else:
|
||||
psw = None
|
||||
|
||||
@@ -831,7 +863,7 @@ class RarFile(object):
|
||||
return self._file_parser.strerror()
|
||||
|
||||
##
|
||||
## private methods
|
||||
# private methods
|
||||
##
|
||||
|
||||
def _parse(self):
|
||||
@@ -882,6 +914,7 @@ class RarFile(object):
|
||||
# File format parsing
|
||||
#
|
||||
|
||||
|
||||
class CommonParser(object):
|
||||
"""Shared parser parts."""
|
||||
_main = None
|
||||
@@ -1011,7 +1044,8 @@ class CommonParser(object):
|
||||
# RAR 2.x does not set FIRSTVOLUME,
|
||||
# so check it only if NEWNUMBERING is used
|
||||
if (h.flags & RAR_MAIN_FIRSTVOLUME) == 0:
|
||||
raise NeedFirstVolume("Need to start from first volume")
|
||||
raise NeedFirstVolume(
|
||||
"Need to start from first volume")
|
||||
if h.flags & RAR_MAIN_PASSWORD:
|
||||
self._needs_password = True
|
||||
if not self._password:
|
||||
@@ -1094,7 +1128,8 @@ class CommonParser(object):
|
||||
raise BadRarFile('cannot find copied file')
|
||||
|
||||
if inf.flags & RAR_FILE_SPLIT_BEFORE:
|
||||
raise NeedFirstVolume("Partial file, please start from first volume: " + inf.filename)
|
||||
raise NeedFirstVolume(
|
||||
"Partial file, please start from first volume: " + inf.filename)
|
||||
|
||||
# is temp write usable?
|
||||
use_hack = 1
|
||||
@@ -1181,6 +1216,7 @@ class CommonParser(object):
|
||||
# RAR3 format
|
||||
#
|
||||
|
||||
|
||||
class Rar3Info(RarInfo):
|
||||
"""RAR3 specific fields."""
|
||||
extract_version = 15
|
||||
@@ -1464,6 +1500,7 @@ class RAR3Parser(CommonParser):
|
||||
# RAR5 format
|
||||
#
|
||||
|
||||
|
||||
class Rar5Info(RarInfo):
|
||||
"""Shared fields for RAR5 records.
|
||||
"""
|
||||
@@ -1871,12 +1908,14 @@ class RAR5Parser(CommonParser):
|
||||
return self._open_hack_core(inf, psw, RAR5_ID + main_hdr, endarc_hdr)
|
||||
|
||||
##
|
||||
## Utility classes
|
||||
# Utility classes
|
||||
##
|
||||
|
||||
|
||||
class UnicodeFilename(object):
|
||||
"""Handle RAR3 unicode filename decompression.
|
||||
"""
|
||||
|
||||
def __init__(self, name, encdata):
|
||||
self.std_name = bytearray(name)
|
||||
self.encdata = bytearray(encdata)
|
||||
@@ -2328,6 +2367,7 @@ class DirectReader(RarExtFile):
|
||||
|
||||
class HeaderDecrypt(object):
|
||||
"""File-like object that decrypts from another file"""
|
||||
|
||||
def __init__(self, f, key, iv):
|
||||
self.f = f
|
||||
self.ciph = AES_CBC_Decrypt(key, iv)
|
||||
@@ -2414,12 +2454,16 @@ class XFile(object):
|
||||
|
||||
class NoHashContext(object):
|
||||
"""No-op hash function."""
|
||||
|
||||
def __init__(self, data=None):
|
||||
"""Initialize"""
|
||||
|
||||
def update(self, data):
|
||||
"""Update data"""
|
||||
|
||||
def digest(self):
|
||||
"""Final hash"""
|
||||
|
||||
def hexdigest(self):
|
||||
"""Hexadecimal digest."""
|
||||
|
||||
@@ -2510,9 +2554,10 @@ class Blake2SP(object):
|
||||
return tohex(self.digest())
|
||||
|
||||
##
|
||||
## Utility functions
|
||||
# Utility functions
|
||||
##
|
||||
|
||||
|
||||
S_LONG = Struct('<L')
|
||||
S_SHORT = Struct('<H')
|
||||
S_BYTE = Struct('<B')
|
||||
@@ -2521,6 +2566,7 @@ S_BLK_HDR = Struct('<HBHH')
|
||||
S_FILE_HDR = Struct('<LLBLLBBHL')
|
||||
S_COMMENT_HDR = Struct('<HBBH')
|
||||
|
||||
|
||||
def load_vint(buf, pos):
|
||||
"""Load variable-size int."""
|
||||
limit = min(pos + 11, len(buf))
|
||||
@@ -2534,6 +2580,7 @@ def load_vint(buf, pos):
|
||||
return res, pos
|
||||
raise BadRarFile('cannot load vint')
|
||||
|
||||
|
||||
def load_byte(buf, pos):
|
||||
"""Load single byte"""
|
||||
end = pos + 1
|
||||
@@ -2541,6 +2588,7 @@ def load_byte(buf, pos):
|
||||
raise BadRarFile('cannot load byte')
|
||||
return S_BYTE.unpack_from(buf, pos)[0], end
|
||||
|
||||
|
||||
def load_le32(buf, pos):
|
||||
"""Load little-endian 32-bit integer"""
|
||||
end = pos + 4
|
||||
@@ -2548,6 +2596,7 @@ def load_le32(buf, pos):
|
||||
raise BadRarFile('cannot load le32')
|
||||
return S_LONG.unpack_from(buf, pos)[0], pos + 4
|
||||
|
||||
|
||||
def load_bytes(buf, num, pos):
|
||||
"""Load sequence of bytes"""
|
||||
end = pos + num
|
||||
@@ -2555,23 +2604,27 @@ def load_bytes(buf, num, pos):
|
||||
raise BadRarFile('cannot load bytes')
|
||||
return buf[pos: end], end
|
||||
|
||||
|
||||
def load_vstr(buf, pos):
|
||||
"""Load bytes prefixed by vint length"""
|
||||
slen, pos = load_vint(buf, pos)
|
||||
return load_bytes(buf, slen, pos)
|
||||
|
||||
|
||||
def load_dostime(buf, pos):
|
||||
"""Load LE32 dos timestamp"""
|
||||
stamp, pos = load_le32(buf, pos)
|
||||
tup = parse_dos_time(stamp)
|
||||
return to_datetime(tup), pos
|
||||
|
||||
|
||||
def load_unixtime(buf, pos):
|
||||
"""Load LE32 unix timestamp"""
|
||||
secs, pos = load_le32(buf, pos)
|
||||
dt = datetime.fromtimestamp(secs, UTC)
|
||||
return dt, pos
|
||||
|
||||
|
||||
def load_windowstime(buf, pos):
|
||||
"""Load LE64 windows timestamp"""
|
||||
# unix epoch (1970) in seconds from windows epoch (1601)
|
||||
@@ -2584,6 +2637,8 @@ def load_windowstime(buf, pos):
|
||||
return dt, pos
|
||||
|
||||
# new-style next volume
|
||||
|
||||
|
||||
def _next_newvol(volfile):
|
||||
i = len(volfile) - 1
|
||||
while i >= 0:
|
||||
@@ -2593,6 +2648,8 @@ def _next_newvol(volfile):
|
||||
raise BadRarName("Cannot construct volume name: " + volfile)
|
||||
|
||||
# old-style next volume
|
||||
|
||||
|
||||
def _next_oldvol(volfile):
|
||||
# rar -> r00
|
||||
if volfile[-4:].lower() == '.rar':
|
||||
@@ -2600,6 +2657,8 @@ def _next_oldvol(volfile):
|
||||
return _inc_volname(volfile, len(volfile) - 1)
|
||||
|
||||
# increase digits with carry, otherwise just increment char
|
||||
|
||||
|
||||
def _inc_volname(volfile, i):
|
||||
fn = list(volfile)
|
||||
while i >= 0:
|
||||
@@ -2611,6 +2670,8 @@ def _inc_volname(volfile, i):
|
||||
return ''.join(fn)
|
||||
|
||||
# rar3 extended time fields
|
||||
|
||||
|
||||
def _parse_ext_time(h, data, pos):
|
||||
# flags and rest of data can be missing
|
||||
flags = 0
|
||||
@@ -2628,6 +2689,8 @@ def _parse_ext_time(h, data, pos):
|
||||
return pos
|
||||
|
||||
# rar3 one extended time field
|
||||
|
||||
|
||||
def _parse_xtime(flag, data, pos, basetime=None):
|
||||
res = None
|
||||
if flag & 8:
|
||||
@@ -2648,11 +2711,13 @@ def _parse_xtime(flag, data, pos, basetime=None):
|
||||
|
||||
# dostime has room for 30 seconds only, correct if needed
|
||||
if flag & 4 and basetime.second < 59:
|
||||
res = basetime.replace(microsecond=usec, second=basetime.second + 1)
|
||||
res = basetime.replace(
|
||||
microsecond=usec, second=basetime.second + 1)
|
||||
else:
|
||||
res = basetime.replace(microsecond=usec)
|
||||
return res, pos
|
||||
|
||||
|
||||
def is_filelike(obj):
|
||||
"""Filename or file object?
|
||||
"""
|
||||
@@ -2665,6 +2730,7 @@ def is_filelike(obj):
|
||||
raise ValueError("Invalid object passed as file")
|
||||
return True
|
||||
|
||||
|
||||
def rar3_s2k(psw, salt):
|
||||
"""String-to-key hash for RAR3.
|
||||
"""
|
||||
@@ -2683,6 +2749,7 @@ def rar3_s2k(psw, salt):
|
||||
key_le = pack("<LLLL", *unpack(">LLLL", key_be))
|
||||
return key_le, iv
|
||||
|
||||
|
||||
def rar3_decompress(vers, meth, data, declen=0, flags=0, crc=0, psw=None, salt=None):
|
||||
"""Decompress blob of compressed data.
|
||||
|
||||
@@ -2734,6 +2801,7 @@ def rar3_decompress(vers, meth, data, declen=0, flags=0, crc=0, psw=None, salt=N
|
||||
tmpf.close()
|
||||
os.unlink(tmpname)
|
||||
|
||||
|
||||
def to_datetime(t):
|
||||
"""Convert 6-part time tuple into datetime object.
|
||||
"""
|
||||
@@ -2772,6 +2840,7 @@ def to_datetime(t):
|
||||
day = 28
|
||||
return datetime(year, mon, day, h, m, s)
|
||||
|
||||
|
||||
def parse_dos_time(stamp):
|
||||
"""Parse standard 32-bit DOS timestamp.
|
||||
"""
|
||||
@@ -2783,6 +2852,7 @@ def parse_dos_time(stamp):
|
||||
yr = (stamp & 0x7F) + 1980
|
||||
return (yr, mon, day, hr, mn, sec * 2)
|
||||
|
||||
|
||||
def custom_popen(cmd):
|
||||
"""Disconnect cmd from parent fds, read only from stdout.
|
||||
"""
|
||||
@@ -2797,10 +2867,12 @@ def custom_popen(cmd):
|
||||
creationflags=creationflags)
|
||||
except OSError as ex:
|
||||
if ex.errno == errno.ENOENT:
|
||||
raise RarCannotExec("Unrar not installed? (rarfile.UNRAR_TOOL=%r)" % UNRAR_TOOL)
|
||||
raise RarCannotExec(
|
||||
"Unrar not installed? (rarfile.UNRAR_TOOL=%r)" % UNRAR_TOOL)
|
||||
raise
|
||||
return p
|
||||
|
||||
|
||||
def custom_check(cmd, ignore_retcode=False):
|
||||
"""Run command, collect output, raise error if needed.
|
||||
"""
|
||||
@@ -2810,6 +2882,7 @@ def custom_check(cmd, ignore_retcode=False):
|
||||
raise RarExecError("Check-run failed")
|
||||
return out
|
||||
|
||||
|
||||
def add_password_arg(cmd, psw, ___required=False):
|
||||
"""Append password switch to commandline.
|
||||
"""
|
||||
@@ -2820,6 +2893,7 @@ def add_password_arg(cmd, psw, ___required=False):
|
||||
else:
|
||||
cmd.append('-p-')
|
||||
|
||||
|
||||
def check_returncode(p, out):
|
||||
"""Raise exception according to unrar exit code.
|
||||
"""
|
||||
@@ -2851,10 +2925,12 @@ def check_returncode(p, out):
|
||||
|
||||
raise exc(msg)
|
||||
|
||||
|
||||
def hmac_sha256(key, data):
|
||||
"""HMAC-SHA256"""
|
||||
return HMAC(key, data, sha256).digest()
|
||||
|
||||
|
||||
def membuf_tempfile(memfile):
|
||||
memfile.seek(0, 0)
|
||||
|
||||
@@ -2874,6 +2950,7 @@ def membuf_tempfile(memfile):
|
||||
raise
|
||||
return tmpname
|
||||
|
||||
|
||||
class XTempFile(object):
|
||||
__slots__ = ('_tmpfile', '_filename')
|
||||
|
||||
@@ -2900,11 +2977,13 @@ class XTempFile(object):
|
||||
# Check if unrar works
|
||||
#
|
||||
|
||||
|
||||
ORIG_UNRAR_TOOL = UNRAR_TOOL
|
||||
ORIG_OPEN_ARGS = OPEN_ARGS
|
||||
ORIG_EXTRACT_ARGS = EXTRACT_ARGS
|
||||
ORIG_TEST_ARGS = TEST_ARGS
|
||||
|
||||
|
||||
def _check_unrar_tool():
|
||||
global UNRAR_TOOL, OPEN_ARGS, EXTRACT_ARGS, TEST_ARGS
|
||||
try:
|
||||
@@ -2928,5 +3007,5 @@ def _check_unrar_tool():
|
||||
# no usable tool, only uncompressed archives work
|
||||
pass
|
||||
|
||||
_check_unrar_tool()
|
||||
|
||||
_check_unrar_tool()
|
||||
|
||||
@@ -133,12 +133,14 @@ class ek:
|
||||
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])
|
||||
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)
|
||||
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)
|
||||
@@ -164,6 +166,7 @@ def tryInt(s, s_default=0):
|
||||
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')
|
||||
@@ -183,7 +186,8 @@ if nzbget_version >= 11:
|
||||
status = 0
|
||||
|
||||
if evn['NZBOP_UNPACK'] != 'yes':
|
||||
logger.log("Please enable option \"Unpack\" in nzbget configuration file, exiting")
|
||||
logger.log(
|
||||
"Please enable option \"Unpack\" in nzbget configuration file, exiting")
|
||||
sys.exit(POSTPROCESS_NONE)
|
||||
|
||||
parstatus = evn['NZBPP_PARSTATUS']
|
||||
@@ -216,20 +220,24 @@ if nzbget_version >= 11:
|
||||
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")
|
||||
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")
|
||||
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")
|
||||
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)
|
||||
logger.log(
|
||||
"Post-Process: Nothing to post-process: destination directory %s doesn't exist" % directory)
|
||||
status = 1
|
||||
|
||||
# All checks done, now launching the script.
|
||||
@@ -260,27 +268,33 @@ if nzbget_version >= 11:
|
||||
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))
|
||||
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))
|
||||
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)
|
||||
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))
|
||||
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))
|
||||
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)
|
||||
logger.log("Error unable to rename file %s" %
|
||||
old_name, logger.ERROR)
|
||||
pass
|
||||
|
||||
if rd:
|
||||
@@ -289,5 +303,6 @@ if nzbget_version >= 11:
|
||||
sys.exit(POSTPROCESS_NONE)
|
||||
|
||||
else:
|
||||
logger.log("This script can only be called from NZBGet (11.0 or later).", logger.ERROR)
|
||||
logger.log(
|
||||
"This script can only be called from NZBGet (11.0 or later).", logger.ERROR)
|
||||
sys.exit(0)
|
||||
|
||||
@@ -12,7 +12,15 @@
|
||||
### NZBGET SCAN SCRIPT ###
|
||||
##############################################################################
|
||||
|
||||
import os, zipfile, tarfile, gzip, pickle, datetime, re, struct, locale
|
||||
import os
|
||||
import zipfile
|
||||
import tarfile
|
||||
import gzip
|
||||
import pickle
|
||||
import datetime
|
||||
import re
|
||||
import struct
|
||||
import locale
|
||||
import rarfile.rarfile as rarfile
|
||||
|
||||
from gzip import FEXTRA, FNAME
|
||||
@@ -94,9 +102,11 @@ else:
|
||||
dupescore = None
|
||||
dupemode = None
|
||||
|
||||
tmp_zipinfo = os.path.join(os.environ.get('NZBOP_TEMPDIR'), r'nzbget\unzip_scan\info')
|
||||
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()
|
||||
@@ -135,6 +145,7 @@ def read_gzip_info(gzipfile):
|
||||
gf.seek(pos)
|
||||
return ''.join(fname), size
|
||||
|
||||
|
||||
def save_obj(obj, name):
|
||||
tp = os.path.dirname(name)
|
||||
if not os.path.exists(tp):
|
||||
@@ -149,6 +160,7 @@ def save_obj(obj, name):
|
||||
except:
|
||||
print "Error saving: " + name
|
||||
|
||||
|
||||
def load_obj(name):
|
||||
if os.path.isfile(name):
|
||||
try:
|
||||
@@ -160,6 +172,7 @@ def load_obj(name):
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def save_nzb_list():
|
||||
if nzb_list:
|
||||
save_obj(nzb_list, tmp_zipinfo)
|
||||
@@ -170,6 +183,7 @@ def save_nzb_list():
|
||||
except:
|
||||
print "Error deleting " + tmp_zipinfo
|
||||
|
||||
|
||||
def load_nzb_list():
|
||||
global nzb_list
|
||||
nzb_list = load_obj(tmp_zipinfo)
|
||||
@@ -180,27 +194,35 @@ def load_nzb_list():
|
||||
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']
|
||||
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']
|
||||
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']
|
||||
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')
|
||||
@@ -210,9 +232,11 @@ if ext == '.zip':
|
||||
now = datetime.datetime.now()
|
||||
for z in zf:
|
||||
if nzb_list:
|
||||
nzb_list.append([z.filename, cat, prio, top, pause, dupekey, dupescore, dupemode, now])
|
||||
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]]
|
||||
nzb_list = [[z.filename, cat, prio, top,
|
||||
pause, dupekey, dupescore, dupemode, now]]
|
||||
save_nzb_list()
|
||||
zipf.close()
|
||||
|
||||
@@ -227,9 +251,11 @@ elif ext in ['.tar.gz', '.tar', '.tgz']:
|
||||
now = datetime.datetime.now()
|
||||
for z in tf:
|
||||
if nzb_list:
|
||||
nzb_list.append([z.name, cat, prio, top, pause, dupekey, dupescore, dupemode, now])
|
||||
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]]
|
||||
nzb_list = [[z.name, cat, prio, top, pause,
|
||||
dupekey, dupescore, dupemode, now]]
|
||||
save_nzb_list()
|
||||
tarf.close()
|
||||
|
||||
@@ -247,9 +273,11 @@ elif ext == '.gz':
|
||||
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])
|
||||
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]]
|
||||
nzb_list = [[os.path.basename(
|
||||
out_filename), cat, prio, top, pause, dupekey, dupescore, dupemode, now]]
|
||||
save_nzb_list()
|
||||
gzf.close()
|
||||
|
||||
@@ -264,9 +292,11 @@ elif ext == '.rar':
|
||||
now = datetime.datetime.now()
|
||||
for r in rf:
|
||||
if nzb_list:
|
||||
nzb_list.append([r.filename, cat, prio, top, pause, dupekey, dupescore, dupemode, now])
|
||||
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]]
|
||||
nzb_list = [[r.filename, cat, prio, top,
|
||||
pause, dupekey, dupescore, dupemode, now]]
|
||||
save_nzb_list()
|
||||
rarf.close()
|
||||
|
||||
|
||||
@@ -27,12 +27,12 @@
|
||||
|
||||
- name: Checking for existing rss folder
|
||||
stat:
|
||||
path: "/opt/appdata/{{pgrole}}/rss"
|
||||
path: '/opt/appdata/{{pgrole}}/rss'
|
||||
register: rsscheck
|
||||
|
||||
- name: Checking for existing rss config
|
||||
stat:
|
||||
path: "/opt/appdata/{{pgrole}}/rss/transmission-rss.conf"
|
||||
path: '/opt/appdata/{{pgrole}}/rss/transmission-rss.conf'
|
||||
register: cfgcheck
|
||||
|
||||
# LABELS ######################################################################
|
||||
@@ -120,13 +120,13 @@
|
||||
- name: 'RSS feed configuration - Folder'
|
||||
block:
|
||||
- name: 'Creating RSS folder'
|
||||
shell: "mkdir /opt/appdata/{{pgrole}}/rss"
|
||||
shell: 'mkdir /opt/appdata/{{pgrole}}/rss'
|
||||
when: not rsscheck.stat.exists
|
||||
|
||||
- name: 'RSS feed configuration - Config'
|
||||
block:
|
||||
- name: 'Creating configuration file'
|
||||
shell: "touch /opt/appdata/{{pgrole}}/rss/transmission-rss.conf && chown -R 1000:1000 /opt/appdata/{{pgrole}}/rss/ && echo see https://git.io/fhAm2 to configure > /opt/appdata/{{pgrole}}/rss/transmission-rss.conf"
|
||||
shell: 'touch /opt/appdata/{{pgrole}}/rss/transmission-rss.conf && chown -R 1000:1000 /opt/appdata/{{pgrole}}/rss/ && echo see https://git.io/fhAm2 to configure > /opt/appdata/{{pgrole}}/rss/transmission-rss.conf'
|
||||
when: not cfgcheck.stat.exists
|
||||
|
||||
- name: 'Deploying {{pgrole2}}'
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
|
||||
- name: 'Set Known Facts'
|
||||
set_fact:
|
||||
pgrole: "zammad"
|
||||
intport: "80"
|
||||
extport: "8777"
|
||||
image: "zammad/zammad"
|
||||
pgrole: 'zammad'
|
||||
intport: '80'
|
||||
extport: '8777'
|
||||
image: 'zammad/zammad'
|
||||
|
||||
- name: 'Including cron job'
|
||||
include_tasks: '/opt/communityapps/apps/_core.yml'
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
|
||||
Reference in New Issue
Block a user