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
|
# Generates App List
|
||||||
ls -la /opt/communityapps/apps/ | sed -e 's/.yml//g' \
|
ls -la /opt/communityapps/apps/ | sed -e 's/.yml//g' |
|
||||||
| awk '{print $9}' | tail -n +4 >> /var/plexguide/app.list
|
awk '{print $9}' | tail -n +4 >>/var/plexguide/app.list
|
||||||
|
|
||||||
ls -la /opt/mycontainers/ | sed -e 's/.yml//g' \
|
ls -la /opt/mycontainers/ | sed -e 's/.yml//g' |
|
||||||
| awk '{print $9}' | tail -n +4 >> /var/plexguide/app.list
|
awk '{print $9}' | tail -n +4 >>/var/plexguide/app.list
|
||||||
# Enter Items Here to Prevent them From Showing Up on AppList
|
# Enter Items Here to Prevent them From Showing Up on AppList
|
||||||
sed -i -e "/traefik/d" /var/plexguide/app.list
|
sed -i -e "/traefik/d" /var/plexguide/app.list
|
||||||
sed -i -e "/image*/d" /var/plexguide/app.list
|
sed -i -e "/image*/d" /var/plexguide/app.list
|
||||||
|
|||||||
@@ -48,8 +48,8 @@
|
|||||||
shell: "echo '{{pgrole}}' > /tmp/program_var"
|
shell: "echo '{{pgrole}}' > /tmp/program_var"
|
||||||
ignore_errors: True
|
ignore_errors: True
|
||||||
|
|
||||||
# APPDATA
|
|
||||||
|
|
||||||
|
# APPDATA
|
||||||
- name: 'Creating appdata folder if it does not exist.'
|
- name: 'Creating appdata folder if it does not exist.'
|
||||||
shell: 'mkdir -p /opt/appdata/{{pgrole}}'
|
shell: 'mkdir -p /opt/appdata/{{pgrole}}'
|
||||||
|
|
||||||
@@ -69,7 +69,6 @@
|
|||||||
shell: 'chmod -R 775 /opt/appdata/{{pgrole}}'
|
shell: 'chmod -R 775 /opt/appdata/{{pgrole}}'
|
||||||
when: '"plex" not in pgrole'
|
when: '"plex" not in pgrole'
|
||||||
|
|
||||||
|
|
||||||
# OVERWRITE IMAGES #############################################################
|
# OVERWRITE IMAGES #############################################################
|
||||||
- name: Check if Image Variable Exists
|
- name: Check if Image Variable Exists
|
||||||
stat:
|
stat:
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
- name: Creating download paths
|
- name: Creating download paths
|
||||||
file: 'path={{item}} state=directory mode=0775 owner=1000 group=1000'
|
file: 'path={{item}} state=directory mode=0775 owner=1000 group=1000'
|
||||||
with_items:
|
with_items:
|
||||||
- '{{path.stdout}}/downloads/{{pgrole}}'
|
- '{{path.stdout}}/downloads/{{pgrole}}'
|
||||||
|
|
||||||
- name: Creating incomplete paths
|
- name: Creating incomplete paths
|
||||||
file: 'path={{item}} state=directory mode=0775 owner=1000 group=1000'
|
file: 'path={{item}} state=directory mode=0775 owner=1000 group=1000'
|
||||||
with_items:
|
with_items:
|
||||||
- '{{path.stdout}}/incomplete/{{pgrole}}'
|
- '{{path.stdout}}/incomplete/{{pgrole}}'
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
pgrole: 'avidemux'
|
pgrole: 'avidemux'
|
||||||
intport: '5800'
|
intport: '5800'
|
||||||
extport: '5806'
|
extport: '5806'
|
||||||
# intport2: '25565'
|
# intport2: '25565'
|
||||||
# extport2: '25565'
|
# extport2: '25565'
|
||||||
image: 'jlesage/avidemux'
|
image: 'jlesage/avidemux'
|
||||||
|
|
||||||
- name: 'Including cron job'
|
- name: 'Including cron job'
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
set_fact:
|
set_fact:
|
||||||
pg_labels:
|
pg_labels:
|
||||||
traefik.enable: 'true'
|
traefik.enable: 'true'
|
||||||
traefik.backend: "{{pgrole}}"
|
traefik.backend: '{{pgrole}}'
|
||||||
traefik.port: '80'
|
traefik.port: '80'
|
||||||
traefik.frontend.rule: 'Host:bit.{{domain.stdout}},{{pgrole}}.{{domain.stdout}},{{tldset}}'
|
traefik.frontend.rule: 'Host:bit.{{domain.stdout}},{{pgrole}}.{{domain.stdout}},{{tldset}}'
|
||||||
|
|
||||||
|
|||||||
@@ -9,23 +9,23 @@
|
|||||||
- hosts: localhost
|
- hosts: localhost
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
tasks:
|
tasks:
|
||||||
# CORE (MANDATORY) DO NOT CHANGE ###########################################
|
# CORE (MANDATORY) DO NOT CHANGE ###########################################
|
||||||
|
|
||||||
- name: 'Set Known Facts'
|
- name: 'Set Known Facts'
|
||||||
set_fact:
|
set_fact:
|
||||||
pgrole: "embystats"
|
pgrole: 'embystats'
|
||||||
intport: "5432"
|
intport: '5432'
|
||||||
extport: "9049"
|
extport: '9049'
|
||||||
image: "uping/embystat:beta-linux"
|
image: 'uping/embystat:beta-linux'
|
||||||
|
|
||||||
- name: 'Including cron job'
|
- name: 'Including cron job'
|
||||||
include_tasks: '/opt/communityapps/apps/_core.yml'
|
include_tasks: '/opt/communityapps/apps/_core.yml'
|
||||||
|
|
||||||
# EXTRA FUNCTIONS REQUIRED BY THE ROLE #####################################
|
# EXTRA FUNCTIONS REQUIRED BY THE ROLE #####################################
|
||||||
|
|
||||||
##### NOTHING REQUIRED
|
##### NOTHING REQUIRED
|
||||||
|
|
||||||
# LABELS #### KEEPS BOTTOM CLEAN ###########################################
|
# LABELS #### KEEPS BOTTOM CLEAN ###########################################
|
||||||
- name: 'Adding Traefik'
|
- name: 'Adding Traefik'
|
||||||
set_fact:
|
set_fact:
|
||||||
pg_labels:
|
pg_labels:
|
||||||
|
|||||||
@@ -75,7 +75,6 @@
|
|||||||
- '{{pgrole}}'
|
- '{{pgrole}}'
|
||||||
state: started
|
state: started
|
||||||
labels: '{{pg_labels}}'
|
labels: '{{pg_labels}}'
|
||||||
|
|
||||||
##PG-Community
|
##PG-Community
|
||||||
|
|
||||||
##PG-Community
|
##PG-Community
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
pgrole: 'firefox'
|
pgrole: 'firefox'
|
||||||
intport: '5800'
|
intport: '5800'
|
||||||
extport: '5810'
|
extport: '5810'
|
||||||
# intport2: '25565'
|
# intport2: '25565'
|
||||||
# extport2: '25565'
|
# extport2: '25565'
|
||||||
image: 'jlesage/firefox'
|
image: 'jlesage/firefox'
|
||||||
|
|
||||||
- name: 'Including cron job'
|
- name: 'Including cron job'
|
||||||
|
|||||||
@@ -9,23 +9,23 @@
|
|||||||
- hosts: localhost
|
- hosts: localhost
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
tasks:
|
tasks:
|
||||||
# CORE (MANDATORY) DO NOT CHANGE ###########################################
|
# CORE (MANDATORY) DO NOT CHANGE ###########################################
|
||||||
|
|
||||||
- name: 'Set Known Facts'
|
- name: 'Set Known Facts'
|
||||||
set_fact:
|
set_fact:
|
||||||
pgrole: "gazee"
|
pgrole: 'gazee'
|
||||||
intport: "4242"
|
intport: '4242'
|
||||||
extport: "4242"
|
extport: '4242'
|
||||||
image: "linuxserver/gazee"
|
image: 'linuxserver/gazee'
|
||||||
|
|
||||||
- name: 'Including cron job'
|
- name: 'Including cron job'
|
||||||
include_tasks: '/opt/communityapps/apps/_core.yml'
|
include_tasks: '/opt/communityapps/apps/_core.yml'
|
||||||
|
|
||||||
# EXTRA FUNCTIONS REQUIRED BY THE ROLE #####################################
|
# EXTRA FUNCTIONS REQUIRED BY THE ROLE #####################################
|
||||||
|
|
||||||
##### NOTHING REQUIRED
|
##### NOTHING REQUIRED
|
||||||
|
|
||||||
# LABELS #### KEEPS BOTTOM CLEAN ###########################################
|
# LABELS #### KEEPS BOTTOM CLEAN ###########################################
|
||||||
- name: 'Adding Traefik'
|
- name: 'Adding Traefik'
|
||||||
set_fact:
|
set_fact:
|
||||||
pg_labels:
|
pg_labels:
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
pgrole: 'git'
|
pgrole: 'git'
|
||||||
intport: '3000'
|
intport: '3000'
|
||||||
extport: '9898'
|
extport: '9898'
|
||||||
intport2: '22' ##for SSH
|
intport2: '22' ##for SSH
|
||||||
extport2: '222'
|
extport2: '222'
|
||||||
|
|
||||||
image: 'gitea/gitea'
|
image: 'gitea/gitea'
|
||||||
@@ -38,22 +38,22 @@
|
|||||||
pg_volumes:
|
pg_volumes:
|
||||||
- '/opt/appdata/{{pgrole}}:/data'
|
- '/opt/appdata/{{pgrole}}:/data'
|
||||||
- '/etc/localtime:/etc/localtime:ro'
|
- '/etc/localtime:/etc/localtime:ro'
|
||||||
### - '/opt/appdata/git/gitea-db:/data'
|
### - '/opt/appdata/git/gitea-db:/data'
|
||||||
|
|
||||||
- name: 'Setting PG ENV'
|
- name: 'Setting PG ENV'
|
||||||
set_fact:
|
set_fact:
|
||||||
pg_env:
|
pg_env:
|
||||||
PUID: '1000'
|
PUID: '1000'
|
||||||
PGID: '1000'
|
PGID: '1000'
|
||||||
#### DB_PASSWORD: gitea
|
|
||||||
|
|
||||||
|
#### DB_PASSWORD: gitea
|
||||||
# MAIN DEPLOYMENT #############################################################
|
# MAIN DEPLOYMENT #############################################################
|
||||||
- name: 'Deploying {{pgrole}}'
|
- name: 'Deploying {{pgrole}}'
|
||||||
docker_container:
|
docker_container:
|
||||||
name: '{{pgrole}}'
|
name: '{{pgrole}}'
|
||||||
image: '{{image}}'
|
image: '{{image}}'
|
||||||
pull: yes
|
pull: yes
|
||||||
# links:
|
# links:
|
||||||
# - "dbgitea:idk?"
|
# - "dbgitea:idk?"
|
||||||
published_ports:
|
published_ports:
|
||||||
- '{{ports.stdout}}{{extport}}:{{intport}}'
|
- '{{ports.stdout}}{{extport}}:{{intport}}'
|
||||||
|
|||||||
@@ -50,13 +50,13 @@
|
|||||||
pg_env:
|
pg_env:
|
||||||
USER_ID: '1000'
|
USER_ID: '1000'
|
||||||
GROUP_ID: '1000'
|
GROUP_ID: '1000'
|
||||||
AUTOMATED_CONVERSION_PRESET: "Very Fast 1080p30"
|
AUTOMATED_CONVERSION_PRESET: 'Very Fast 1080p30'
|
||||||
AUTOMATED_CONVERSION_FORMAT: "mp4"
|
AUTOMATED_CONVERSION_FORMAT: 'mp4'
|
||||||
AUTOMATED_CONVERSION_PRESET_2: "HQ 1080p30 Surround"
|
AUTOMATED_CONVERSION_PRESET_2: 'HQ 1080p30 Surround'
|
||||||
AUTOMATED_CONVERSION_FORMAT_2: "mp4"
|
AUTOMATED_CONVERSION_FORMAT_2: 'mp4'
|
||||||
AUTOMATED_CONVERSION_PRESET_3: "H.264 MKV 1080p30"
|
AUTOMATED_CONVERSION_PRESET_3: 'H.264 MKV 1080p30'
|
||||||
AUTOMATED_CONVERSION_FORMAT_3: "mkv"
|
AUTOMATED_CONVERSION_FORMAT_3: 'mkv'
|
||||||
# SECURE_CONNECTION: 1
|
# SECURE_CONNECTION: 1
|
||||||
|
|
||||||
# MAIN DEPLOYMENT #############################################################
|
# MAIN DEPLOYMENT #############################################################
|
||||||
- name: 'Create watch directory for {{pgrole}}'
|
- name: 'Create watch directory for {{pgrole}}'
|
||||||
|
|||||||
@@ -7,23 +7,23 @@
|
|||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# BAD INPUT
|
# BAD INPUT
|
||||||
badinput () {
|
badinput() {
|
||||||
echo
|
echo
|
||||||
read -p '⛔️ ERROR - BAD INPUT! | PRESS [ENTER] ' typed < /dev/tty
|
read -p '⛔️ ERROR - BAD INPUT! | PRESS [ENTER] ' typed </dev/tty
|
||||||
question1
|
question1
|
||||||
}
|
}
|
||||||
|
|
||||||
# FUNCTION - ONE
|
# FUNCTION - ONE
|
||||||
question1 () {
|
question1() {
|
||||||
|
|
||||||
# Recall Program
|
# Recall Program
|
||||||
image=$(cat /tmp/program_var)
|
image=$(cat /tmp/program_var)
|
||||||
|
|
||||||
# Checks Image List
|
# Checks Image List
|
||||||
file="/opt/communityapps/apps/image/$image"
|
file="/opt/communityapps/apps/image/$image"
|
||||||
if [ ! -e "$file" ]; then exit; fi
|
if [ ! -e "$file" ]; then exit; fi
|
||||||
|
|
||||||
tee <<-EOF
|
tee <<-EOF
|
||||||
|
|
||||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||||
🌵 PG Multi Image Selector - $image
|
🌵 PG Multi Image Selector - $image
|
||||||
@@ -31,19 +31,19 @@ tee <<-EOF
|
|||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
count=1
|
count=1
|
||||||
while read p; do
|
while read p; do
|
||||||
echo "$count - $p"
|
echo "$count - $p"
|
||||||
echo "$p" > /tmp/display$count
|
echo "$p" >/tmp/display$count
|
||||||
count=$[count+1]
|
count=$((count + 1))
|
||||||
done </opt/communityapps/apps/image/$image
|
done </opt/communityapps/apps/image/$image
|
||||||
echo ""
|
echo ""
|
||||||
read -p '🚀 Type Number | PRESS [ENTER]: ' typed < /dev/tty
|
read -p '🚀 Type Number | PRESS [ENTER]: ' typed </dev/tty
|
||||||
|
|
||||||
if [[ "$typed" -ge "1" && "$typed" -lt "$count" ]]; then
|
if [[ "$typed" -ge "1" && "$typed" -lt "$count" ]]; then
|
||||||
mkdir -p /var/plexguide/image
|
mkdir -p /var/plexguide/image
|
||||||
cat "/tmp/display$typed" > "/var/plexguide/image/$image"
|
cat "/tmp/display$typed" >"/var/plexguide/image/$image"
|
||||||
else badinput; fi
|
else badinput; fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# END OF FUNCTIONS ############################################################
|
# END OF FUNCTIONS ############################################################
|
||||||
|
|||||||
@@ -9,19 +9,19 @@
|
|||||||
- hosts: localhost
|
- hosts: localhost
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
tasks:
|
tasks:
|
||||||
# CORE (MANDATORY) DO NOT CHANGE ###########################################
|
# CORE (MANDATORY) DO NOT CHANGE ###########################################
|
||||||
|
|
||||||
- name: 'Set Known Facts'
|
- name: 'Set Known Facts'
|
||||||
set_fact:
|
set_fact:
|
||||||
pgrole: "mariadb"
|
pgrole: 'mariadb'
|
||||||
intport: "3306"
|
intport: '3306'
|
||||||
extport: "6603"
|
extport: '6603'
|
||||||
image: "mariadb:latest"
|
image: 'mariadb:latest'
|
||||||
|
|
||||||
- name: 'Including cron job'
|
- name: 'Including cron job'
|
||||||
include_tasks: '/opt/communityapps/apps/_core.yml'
|
include_tasks: '/opt/communityapps/apps/_core.yml'
|
||||||
|
|
||||||
# LABELS ################################################################
|
# LABELS ################################################################
|
||||||
- name: 'Adding Traefik'
|
- name: 'Adding Traefik'
|
||||||
set_fact:
|
set_fact:
|
||||||
pg_labels:
|
pg_labels:
|
||||||
|
|||||||
@@ -9,23 +9,23 @@
|
|||||||
- hosts: localhost
|
- hosts: localhost
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
tasks:
|
tasks:
|
||||||
# CORE (MANDATORY) DO NOT CHANGE ###########################################
|
# CORE (MANDATORY) DO NOT CHANGE ###########################################
|
||||||
|
|
||||||
- name: 'Set Known Facts'
|
- name: 'Set Known Facts'
|
||||||
set_fact:
|
set_fact:
|
||||||
pgrole: "medusa"
|
pgrole: 'medusa'
|
||||||
intport: "8081"
|
intport: '8081'
|
||||||
extport: "8081"
|
extport: '8081'
|
||||||
image: "linuxserver/medusa"
|
image: 'linuxserver/medusa'
|
||||||
|
|
||||||
- name: 'Including cron job'
|
- name: 'Including cron job'
|
||||||
include_tasks: '/opt/communityapps/apps/_core.yml'
|
include_tasks: '/opt/communityapps/apps/_core.yml'
|
||||||
|
|
||||||
# EXTRA FUNCTIONS REQUIRED BY THE ROLE #####################################
|
# EXTRA FUNCTIONS REQUIRED BY THE ROLE #####################################
|
||||||
|
|
||||||
##### NOTHING REQUIRED
|
##### NOTHING REQUIRED
|
||||||
|
|
||||||
# LABELS #### KEEPS BOTTOM CLEAN ###########################################
|
# LABELS #### KEEPS BOTTOM CLEAN ###########################################
|
||||||
- name: 'Adding Traefik'
|
- name: 'Adding Traefik'
|
||||||
set_fact:
|
set_fact:
|
||||||
pg_labels:
|
pg_labels:
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
path: /opt/appdata/{{pgrole}}/core.conf
|
path: /opt/appdata/{{pgrole}}/core.conf
|
||||||
register: confcheck
|
register: confcheck
|
||||||
|
|
||||||
# LABELS ######################################################################
|
# LABELS ######################################################################
|
||||||
- name: 'Adding Traefik'
|
- name: 'Adding Traefik'
|
||||||
set_fact:
|
set_fact:
|
||||||
pg_labels:
|
pg_labels:
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
pg_env:
|
pg_env:
|
||||||
USER_ID: '1000'
|
USER_ID: '1000'
|
||||||
GROUP_ID: '1000'
|
GROUP_ID: '1000'
|
||||||
# SECURE_CONNECTION: 1
|
# SECURE_CONNECTION: 1
|
||||||
|
|
||||||
# MAIN DEPLOYMENT #############################################################
|
# MAIN DEPLOYMENT #############################################################
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
file: 'path={{item}} state=directory mode=0775 owner=1000 group=1000'
|
file: 'path={{item}} state=directory mode=0775 owner=1000 group=1000'
|
||||||
with_items:
|
with_items:
|
||||||
- '{{path.stdout}}/nzb'
|
- '{{path.stdout}}/nzb'
|
||||||
# force: yes
|
# force: yes
|
||||||
|
|
||||||
- name: 'Including plugins'
|
- name: 'Including plugins'
|
||||||
include_tasks: '/opt/communityapps/apps/_plugins.yml'
|
include_tasks: '/opt/communityapps/apps/_plugins.yml'
|
||||||
|
|||||||
@@ -73,9 +73,6 @@
|
|||||||
DEBUG: 'false'
|
DEBUG: 'false'
|
||||||
WEBUI_PORT: '{{intport}}'
|
WEBUI_PORT: '{{intport}}'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# MAIN DEPLOYMENT #############################################################
|
# MAIN DEPLOYMENT #############################################################
|
||||||
- name: 'Checking for existing app data'
|
- name: 'Checking for existing app data'
|
||||||
stat:
|
stat:
|
||||||
@@ -131,7 +128,6 @@
|
|||||||
value: '{{path.stdout}}/downloads/{{pgrole}}'
|
value: '{{path.stdout}}/downloads/{{pgrole}}'
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
|
|
||||||
- name: Set TempPathEnabled
|
- name: Set TempPathEnabled
|
||||||
ini_file:
|
ini_file:
|
||||||
path: '/opt/appdata/{{pgrole}}/qBittorrent/config/qBittorrent.conf'
|
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
|
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
|
when: not ovpncheck.stat.exists
|
||||||
|
|
||||||
|
|
||||||
# FIRST TIME CONFIGURATION ####################################################
|
# FIRST TIME CONFIGURATION ####################################################
|
||||||
- name: 'Configuring {{pgrole}} for first time use'
|
- name: 'Configuring {{pgrole}} for first time use'
|
||||||
block:
|
block:
|
||||||
|
|||||||
@@ -50,7 +50,6 @@
|
|||||||
- '/etc/localtime:/etc/localtime:ro'
|
- '/etc/localtime:/etc/localtime:ro'
|
||||||
- '/mnt:/mnt'
|
- '/mnt:/mnt'
|
||||||
|
|
||||||
|
|
||||||
- name: 'Setting PG ENV'
|
- name: 'Setting PG ENV'
|
||||||
set_fact:
|
set_fact:
|
||||||
pg_env:
|
pg_env:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"file": 1,
|
"file": 1,
|
||||||
"format": 1
|
"format": 1
|
||||||
}{
|
}{
|
||||||
"interval": 1.0,
|
"interval": 1.0,
|
||||||
"max_seeds": 0,
|
"max_seeds": 0,
|
||||||
"sel_func": "or",
|
"sel_func": "or",
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"file": 1,
|
"file": 1,
|
||||||
"format": 1
|
"format": 1
|
||||||
}{
|
}{
|
||||||
"commands": [
|
"commands": [
|
||||||
[
|
[
|
||||||
"0",
|
"0",
|
||||||
"complete",
|
"complete",
|
||||||
"/config/scripts/extract.sh"
|
"/config/scripts/extract.sh"
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"file": 1,
|
"file": 1,
|
||||||
"format": 1
|
"format": 1
|
||||||
}{
|
}{
|
||||||
"use_name_folder": true,
|
"use_name_folder": true,
|
||||||
"extract_path": "/downloads/deluge/"
|
"extract_path": "/downloads/deluge/"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,7 @@ torrentid=$1
|
|||||||
torrentname=$2
|
torrentname=$2
|
||||||
torrentpath=$3
|
torrentpath=$3
|
||||||
|
|
||||||
log()
|
log() {
|
||||||
{
|
|
||||||
logger -t deluge-extractarchives "$@"
|
logger -t deluge-extractarchives "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,11 +23,11 @@ for format in "${formats[@]}"; do
|
|||||||
cd "$(dirname "$file")"
|
cd "$(dirname "$file")"
|
||||||
file=$(basename "$file")
|
file=$(basename "$file")
|
||||||
# if extraction_subdir is not empty, extract to subdirectory
|
# if extraction_subdir is not empty, extract to subdirectory
|
||||||
if [[ ! -z "$extraction_subdir" ]] ; then
|
if [[ ! -z "$extraction_subdir" ]]; then
|
||||||
mkdir "$extraction_subdir"
|
mkdir "$extraction_subdir"
|
||||||
cd "$extraction_subdir"
|
cd "$extraction_subdir"
|
||||||
file="../$file"
|
file="../$file"
|
||||||
fi
|
fi
|
||||||
${commands[$format]} "$file"
|
${commands[$format]} "$file"
|
||||||
done < <(find "$torrentpath/$torrentname" -iname "*.${format}" )
|
done < <(find "$torrentpath/$torrentname" -iname "*.${format}")
|
||||||
done
|
done
|
||||||
@@ -14,31 +14,31 @@
|
|||||||
### OPTIONS ###
|
### OPTIONS ###
|
||||||
|
|
||||||
# Change to full path to MP4 Automator folder. No quotes and a trailing /
|
# Change to full path to MP4 Automator folder. No quotes and a trailing /
|
||||||
#MP4_FOLDER=~/sickbeard_mp4_automator/
|
# MP4_FOLDER=~/sickbeard_mp4_automator/
|
||||||
|
|
||||||
# Convert file before passing to destination (True, False)
|
# Convert file before passing to destination (True, False)
|
||||||
#SHOULDCONVERT=False
|
# SHOULDCONVERT=False
|
||||||
|
|
||||||
# Category for Couchpotato
|
# Category for Couchpotato
|
||||||
#CP_CAT=Couchpotato
|
# CP_CAT=Couchpotato
|
||||||
|
|
||||||
# Category for Sonarr
|
# Category for Sonarr
|
||||||
#SONARR_CAT=Sonarr
|
# SONARR_CAT=Sonarr
|
||||||
|
|
||||||
# Category for Radarr
|
# Category for Radarr
|
||||||
#RADARR_CAT=Radarr
|
# RADARR_CAT=Radarr
|
||||||
|
|
||||||
# Category for Sickbeard
|
# Category for Sickbeard
|
||||||
#SICKBEARD_CAT=Sickbeard
|
# SICKBEARD_CAT=Sickbeard
|
||||||
|
|
||||||
# Category for Sickrage
|
# Category for Sickrage
|
||||||
#SICKRAGE_CAT=Sickrage
|
# SICKRAGE_CAT=Sickrage
|
||||||
|
|
||||||
# Category list (comma seperated) for bypassing any further processing but still converting
|
# Category list (comma seperated) for bypassing any further processing but still converting
|
||||||
#BYPASS_CAT=tv,movies
|
# BYPASS_CAT=tv,movies
|
||||||
|
|
||||||
# Custom output_directory setting
|
# Custom output_directory setting
|
||||||
#OUTPUT_DIR=
|
# OUTPUT_DIR=
|
||||||
|
|
||||||
### NZBGET POST-PROCESSING SCRIPT ###
|
### NZBGET POST-PROCESSING SCRIPT ###
|
||||||
##############################################################################
|
##############################################################################
|
||||||
@@ -56,7 +56,7 @@ MP4folder = MP4folder.replace("'", "")
|
|||||||
MP4folder = MP4folder.replace("\\", "/")
|
MP4folder = MP4folder.replace("\\", "/")
|
||||||
if not(MP4folder.endswith("/")):
|
if not(MP4folder.endswith("/")):
|
||||||
MP4folder += "/"
|
MP4folder += "/"
|
||||||
#DEBUG#print MP4folder+" the original is "+os.environ['NZBPO_MP4_FOLDER']
|
# DEBUG#print MP4folder+" the original is "+os.environ['NZBPO_MP4_FOLDER']
|
||||||
|
|
||||||
output_dir = None
|
output_dir = None
|
||||||
if 'NZBPO_OUTPUT_DIR' in os.environ:
|
if 'NZBPO_OUTPUT_DIR' in os.environ:
|
||||||
@@ -67,7 +67,7 @@ if 'NZBPO_OUTPUT_DIR' in os.environ:
|
|||||||
output_dir = output_dir.replace("\\", "/")
|
output_dir = output_dir.replace("\\", "/")
|
||||||
if not(output_dir.endswith("/")):
|
if not(output_dir.endswith("/")):
|
||||||
output_dir += "/"
|
output_dir += "/"
|
||||||
#DEBUG#print Overriding output directory
|
# DEBUG#print Overriding output directory
|
||||||
|
|
||||||
sys.path.append(MP4folder)
|
sys.path.append(MP4folder)
|
||||||
try:
|
try:
|
||||||
@@ -77,7 +77,8 @@ try:
|
|||||||
import logging
|
import logging
|
||||||
from logging.config import fileConfig
|
from logging.config import fileConfig
|
||||||
except ImportError:
|
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())
|
print("[ERROR] %s" % traceback.print_exc())
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
@@ -90,28 +91,32 @@ elif not os.path.isdir(logpath):
|
|||||||
os.mkdir(logpath)
|
os.mkdir(logpath)
|
||||||
except:
|
except:
|
||||||
logpath = MP4folder
|
logpath = MP4folder
|
||||||
configPath = os.path.abspath(os.path.join(MP4folder, 'logging.ini')).replace("\\", "\\\\")
|
configPath = os.path.abspath(os.path.join(
|
||||||
logPath = os.path.abspath(os.path.join(logpath, 'index.log')).replace("\\", "\\\\")
|
MP4folder, 'logging.ini')).replace("\\", "\\\\")
|
||||||
|
logPath = os.path.abspath(os.path.join(
|
||||||
|
logpath, 'index.log')).replace("\\", "\\\\")
|
||||||
fileConfig(configPath, defaults={'logfilename': logPath})
|
fileConfig(configPath, defaults={'logfilename': logPath})
|
||||||
log = logging.getLogger("NZBGetPostProcess")
|
log = logging.getLogger("NZBGetPostProcess")
|
||||||
|
|
||||||
# Determine if conversion will take place
|
# 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':
|
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).")
|
log.info("Script triggered from NZBGet (11.0 or later).")
|
||||||
|
|
||||||
path = os.environ['NZBPP_DIRECTORY'] # Path to NZB directory
|
path = os.environ['NZBPP_DIRECTORY'] # Path to NZB directory
|
||||||
nzb = os.environ['NZBPP_NZBFILENAME'] # Original NZB name
|
nzb = os.environ['NZBPP_NZBFILENAME'] # Original NZB name
|
||||||
category = os.environ['NZBPP_CATEGORY'] # NZB Category to determine destination
|
# NZB Category to determine destination
|
||||||
#DEBUG#print "Category is %s." % category
|
category = os.environ['NZBPP_CATEGORY']
|
||||||
|
# DEBUG#print "Category is %s." % category
|
||||||
|
|
||||||
couchcat = os.environ['NZBPO_CP_CAT'].lower()
|
couchcat = os.environ['NZBPO_CP_CAT'].lower()
|
||||||
sonarrcat = os.environ['NZBPO_SONARR_CAT'].lower()
|
sonarrcat = os.environ['NZBPO_SONARR_CAT'].lower()
|
||||||
radarrcat = os.environ['NZBPO_RADARR_CAT'].lower()
|
radarrcat = os.environ['NZBPO_RADARR_CAT'].lower()
|
||||||
sickbeardcat = os.environ['NZBPO_SICKBEARD_CAT'].lower()
|
sickbeardcat = os.environ['NZBPO_SICKBEARD_CAT'].lower()
|
||||||
sickragecat = os.environ['NZBPO_SICKRAGE_CAT'].lower()
|
sickragecat = os.environ['NZBPO_SICKRAGE_CAT'].lower()
|
||||||
bypass = os.environ['NZBPO_BYPASS_CAT'].lower().replace(' ','').split(',')
|
bypass = os.environ['NZBPO_BYPASS_CAT'].lower().replace(' ', '').split(',')
|
||||||
|
|
||||||
categories = [sickbeardcat, couchcat, sonarrcat, radarrcat, sickragecat]
|
categories = [sickbeardcat, couchcat, sonarrcat, radarrcat, sickragecat]
|
||||||
|
|
||||||
@@ -132,7 +137,8 @@ if 'NZBOP_SCRIPTDIR' in os.environ and not os.environ['NZBOP_VERSION'][0:5] < '1
|
|||||||
status = 0
|
status = 0
|
||||||
|
|
||||||
if os.environ['NZBOP_UNPACK'] != 'yes':
|
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)
|
sys.exit(POSTPROCESS_NONE)
|
||||||
|
|
||||||
# Check par status
|
# 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]
|
fileExtension = os.path.splitext(file)[1]
|
||||||
|
|
||||||
if fileExtension in ['.par2']:
|
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
|
status = 1
|
||||||
break
|
break
|
||||||
|
|
||||||
if os.path.isfile(os.path.join(os.environ['NZBPP_DIRECTORY'], "_brokenlog.txt")) and not status == 1:
|
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
|
status = 1
|
||||||
|
|
||||||
if not 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)
|
# Check if destination directory exists (important for reprocessing of history items)
|
||||||
if not os.path.isdir(os.environ['NZBPP_DIRECTORY']):
|
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
|
status = 1
|
||||||
sys.exit(POSTPROCESS_NONE)
|
sys.exit(POSTPROCESS_NONE)
|
||||||
|
|
||||||
# Make sure one of the appropriate categories is set
|
# Make sure one of the appropriate categories is set
|
||||||
if category.lower() not in categories and category.lower() not in bypass:
|
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
|
status = 1
|
||||||
sys.exit(POSTPROCESS_NONE)
|
sys.exit(POSTPROCESS_NONE)
|
||||||
|
|
||||||
@@ -198,8 +209,8 @@ if 'NZBOP_SCRIPTDIR' in os.environ and not os.environ['NZBOP_VERSION'][0:5] < '1
|
|||||||
for r, d, f in os.walk(path):
|
for r, d, f in os.walk(path):
|
||||||
for files in f:
|
for files in f:
|
||||||
inputfile = os.path.join(r, files)
|
inputfile = os.path.join(r, files)
|
||||||
#DEBUG#print inputfile
|
# DEBUG#print inputfile
|
||||||
#Ignores files under 50MB
|
# Ignores files under 50MB
|
||||||
if os.path.getsize(inputfile) > 50000000:
|
if os.path.getsize(inputfile) > 50000000:
|
||||||
if MkvtoMp4(settings, logger=log).validSource(inputfile):
|
if MkvtoMp4(settings, logger=log).validSource(inputfile):
|
||||||
try:
|
try:
|
||||||
@@ -210,33 +221,33 @@ if 'NZBOP_SCRIPTDIR' in os.environ and not os.environ['NZBOP_VERSION'][0:5] < '1
|
|||||||
if converter.output_dir:
|
if converter.output_dir:
|
||||||
path = converter.output_dir
|
path = converter.output_dir
|
||||||
if (category.lower() == categories[0]):
|
if (category.lower() == categories[0]):
|
||||||
#DEBUG#print "Sickbeard Processing Activated"
|
# DEBUG#print "Sickbeard Processing Activated"
|
||||||
autoProcessTV.processEpisode(path, settings, nzb)
|
autoProcessTV.processEpisode(path, settings, nzb)
|
||||||
sys.exit(POSTPROCESS_SUCCESS)
|
sys.exit(POSTPROCESS_SUCCESS)
|
||||||
elif (category.lower() == categories[1]):
|
elif (category.lower() == categories[1]):
|
||||||
#DEBUG#print "CouchPotato Processing Activated"
|
# DEBUG#print "CouchPotato Processing Activated"
|
||||||
autoProcessMovie.process(path, settings, nzb, status)
|
autoProcessMovie.process(path, settings, nzb, status)
|
||||||
sys.exit(POSTPROCESS_SUCCESS)
|
sys.exit(POSTPROCESS_SUCCESS)
|
||||||
elif (category.lower() == categories[2]):
|
elif (category.lower() == categories[2]):
|
||||||
#DEBUG#print "Sonarr Processing Activated"
|
# DEBUG#print "Sonarr Processing Activated"
|
||||||
success = sonarr.processEpisode(path, settings, True)
|
success = sonarr.processEpisode(path, settings, True)
|
||||||
if success:
|
if success:
|
||||||
sys.exit(POSTPROCESS_SUCCESS)
|
sys.exit(POSTPROCESS_SUCCESS)
|
||||||
else:
|
else:
|
||||||
sys.exit(POSTPROCESS_ERROR)
|
sys.exit(POSTPROCESS_ERROR)
|
||||||
elif (category.lower() == categories[3]):
|
elif (category.lower() == categories[3]):
|
||||||
#DEBUG#print "Radarr Processing Activated"
|
# DEBUG#print "Radarr Processing Activated"
|
||||||
success = radarr.processMovie(path, settings, True)
|
success = radarr.processMovie(path, settings, True)
|
||||||
if success:
|
if success:
|
||||||
sys.exit(POSTPROCESS_SUCCESS)
|
sys.exit(POSTPROCESS_SUCCESS)
|
||||||
else:
|
else:
|
||||||
sys.exit(POSTPROCESS_ERROR)
|
sys.exit(POSTPROCESS_ERROR)
|
||||||
elif (category.lower() == categories[4]):
|
elif (category.lower() == categories[4]):
|
||||||
#DEBUG#print "Sickrage Processing Activated"
|
# DEBUG#print "Sickrage Processing Activated"
|
||||||
autoProcessTVSR.processEpisode(path, settings, nzb)
|
autoProcessTVSR.processEpisode(path, settings, nzb)
|
||||||
sys.exit(POSTPROCESS_SUCCESS)
|
sys.exit(POSTPROCESS_SUCCESS)
|
||||||
elif (category.lower() in bypass):
|
elif (category.lower() in bypass):
|
||||||
#DEBUG#print "Bypass Further Processing"
|
# DEBUG#print "Bypass Further Processing"
|
||||||
sys.exit(POSTPROCESS_NONE)
|
sys.exit(POSTPROCESS_NONE)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -141,4 +141,3 @@ host = plex
|
|||||||
port = 32400
|
port = 32400
|
||||||
refresh = False
|
refresh = False
|
||||||
token =
|
token =
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
#!/usr/bin/with-contenv bash
|
#!/usr/bin/with-contenv bash
|
||||||
|
|
||||||
# delete lock file if found
|
# delete lock file if found
|
||||||
[[ -f /downloads/nzbget.lock ]] && \
|
[[ -f /downloads/nzbget.lock ]] &&
|
||||||
rm /downloads/nzbget.lock
|
rm /downloads/nzbget.lock
|
||||||
|
|
||||||
# check if config file exists in /config
|
# check if config file exists in /config
|
||||||
[[ ! -f /config/nzbget.conf ]] && \
|
[[ ! -f /config/nzbget.conf ]] &&
|
||||||
cp /defaults/nzbget.conf /config/nzbget.conf
|
cp /defaults/nzbget.conf /config/nzbget.conf
|
||||||
|
|
||||||
# permissions
|
# permissions
|
||||||
@@ -20,8 +20,8 @@ chmod u+rw \
|
|||||||
chmod 777 -R \
|
chmod 777 -R \
|
||||||
/config
|
/config
|
||||||
chmod 777 -R \
|
chmod 777 -R \
|
||||||
/app/nzbget
|
/app/nzbget
|
||||||
chmod 777 -R \
|
chmod 777 -R \
|
||||||
/downloads
|
/downloads
|
||||||
|
|
||||||
exec /config/installer/installer.sh
|
exec /config/installer/installer.sh
|
||||||
|
|||||||
@@ -15,39 +15,39 @@ ADDITIONAL_CONFIGURE_OPTIONS=""
|
|||||||
# Speed up the process
|
# Speed up the process
|
||||||
# Env Var NUMJOBS overrides automatic detection
|
# Env Var NUMJOBS overrides automatic detection
|
||||||
if [[ -n $NUMJOBS ]]; then
|
if [[ -n $NUMJOBS ]]; then
|
||||||
MJOBS=$NUMJOBS
|
MJOBS=$NUMJOBS
|
||||||
elif [[ -f /proc/cpuinfo ]]; then
|
elif [[ -f /proc/cpuinfo ]]; then
|
||||||
MJOBS=$(grep -c processor /proc/cpuinfo)
|
MJOBS=$(grep -c processor /proc/cpuinfo)
|
||||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
MJOBS=$(sysctl -n machdep.cpu.thread_count)
|
MJOBS=$(sysctl -n machdep.cpu.thread_count)
|
||||||
ADDITIONAL_CONFIGURE_OPTIONS="--enable-videotoolbox"
|
ADDITIONAL_CONFIGURE_OPTIONS="--enable-videotoolbox"
|
||||||
else
|
else
|
||||||
MJOBS=4
|
MJOBS=4
|
||||||
fi
|
fi
|
||||||
|
|
||||||
make_dir () {
|
make_dir() {
|
||||||
if [ ! -d $1 ]; then
|
if [ ! -d $1 ]; then
|
||||||
if ! mkdir $1; then
|
if ! mkdir $1; then
|
||||||
printf "\n Failed to create dir %s" "$1";
|
printf "\n Failed to create dir %s" "$1"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
remove_dir () {
|
remove_dir() {
|
||||||
if [ -d $1 ]; then
|
if [ -d $1 ]; then
|
||||||
rm -r "$1"
|
rm -r "$1"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
download () {
|
download() {
|
||||||
|
|
||||||
DOWNLOAD_PATH=$PACKAGES;
|
DOWNLOAD_PATH=$PACKAGES
|
||||||
|
|
||||||
if [ ! -z "$3" ]; then
|
if [ ! -z "$3" ]; then
|
||||||
mkdir -p $PACKAGES/$3
|
mkdir -p $PACKAGES/$3
|
||||||
DOWNLOAD_PATH=$PACKAGES/$3
|
DOWNLOAD_PATH=$PACKAGES/$3
|
||||||
fi;
|
fi
|
||||||
|
|
||||||
if [ ! -f "$DOWNLOAD_PATH/$2" ]; then
|
if [ ! -f "$DOWNLOAD_PATH/$2" ]; then
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ download () {
|
|||||||
EXITCODE=$?
|
EXITCODE=$?
|
||||||
if [ $EXITCODE -ne 0 ]; then
|
if [ $EXITCODE -ne 0 ]; then
|
||||||
echo ""
|
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
|
sleep 10
|
||||||
curl -L --silent -o "$DOWNLOAD_PATH/$2" "$1"
|
curl -L --silent -o "$DOWNLOAD_PATH/$2" "$1"
|
||||||
fi
|
fi
|
||||||
@@ -65,34 +65,34 @@ download () {
|
|||||||
EXITCODE=$?
|
EXITCODE=$?
|
||||||
if [ $EXITCODE -ne 0 ]; then
|
if [ $EXITCODE -ne 0 ]; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "Failed to download $1. Exitcode $EXITCODE";
|
echo "Failed to download $1. Exitcode $EXITCODE"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "... Done"
|
echo "... Done"
|
||||||
|
|
||||||
if ! tar -xvf "$DOWNLOAD_PATH/$2" -C "$DOWNLOAD_PATH" 2>/dev/null >/dev/null; then
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
execute () {
|
execute() {
|
||||||
echo "$ $*"
|
echo "$ $*"
|
||||||
|
|
||||||
OUTPUT=$($@ 2>&1)
|
OUTPUT=$($@ 2>&1)
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "$OUTPUT"
|
echo "$OUTPUT"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Failed to Execute $*" >&2
|
echo "Failed to Execute $*" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
build () {
|
build() {
|
||||||
echo ""
|
echo ""
|
||||||
echo "building $1"
|
echo "building $1"
|
||||||
echo "======================="
|
echo "======================="
|
||||||
@@ -106,15 +106,14 @@ build () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
command_exists() {
|
command_exists() {
|
||||||
if ! [[ -x $(command -v "$1") ]]; then
|
if ! [[ -x $(command -v "$1") ]]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
build_done() {
|
||||||
build_done () {
|
|
||||||
touch "$PACKAGES/$1.done"
|
touch "$PACKAGES/$1.done"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,18 +128,18 @@ case "$1" in
|
|||||||
echo "Cleanup done."
|
echo "Cleanup done."
|
||||||
echo ""
|
echo ""
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
"--build")
|
"--build") ;;
|
||||||
|
|
||||||
;;
|
\
|
||||||
*)
|
*)
|
||||||
echo "Usage: $0"
|
echo "Usage: $0"
|
||||||
echo " --build: start building process"
|
echo " --build: start building process"
|
||||||
echo " --cleanup: remove all working dirs"
|
echo " --cleanup: remove all working dirs"
|
||||||
echo " --help: show this help"
|
echo " --help: show this help"
|
||||||
echo ""
|
echo ""
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
echo "Using $MJOBS make jobs simultaneously."
|
echo "Using $MJOBS make jobs simultaneously."
|
||||||
@@ -151,18 +150,18 @@ make_dir $WORKSPACE
|
|||||||
export PATH=${WORKSPACE}/bin:$PATH
|
export PATH=${WORKSPACE}/bin:$PATH
|
||||||
|
|
||||||
if ! command_exists "make"; then
|
if ! command_exists "make"; then
|
||||||
echo "make not installed.";
|
echo "make not installed."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! command_exists "g++"; then
|
if ! command_exists "g++"; then
|
||||||
echo "g++ not installed.";
|
echo "g++ not installed."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! command_exists "curl"; then
|
if ! command_exists "curl"; then
|
||||||
echo "curl not installed.";
|
echo "curl not installed."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if build "yasm"; then
|
if build "yasm"; then
|
||||||
@@ -193,14 +192,14 @@ if build "opencore"; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if build "libvpx"; then
|
if build "libvpx"; then
|
||||||
download "https://github.com/webmproject/libvpx/archive/v1.7.0.tar.gz" "libvpx-1.7.0.tar.gz"
|
download "https://github.com/webmproject/libvpx/archive/v1.7.0.tar.gz" "libvpx-1.7.0.tar.gz"
|
||||||
cd $PACKAGES/libvpx-*0 || exit
|
cd $PACKAGES/libvpx-*0 || exit
|
||||||
|
|
||||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
echo "Applying Darwin patch"
|
echo "Applying Darwin patch"
|
||||||
sed "s/,--version-script//g" build/make/Makefile > build/make/Makefile.patched
|
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
|
sed "s/-Wl,--no-undefined -Wl,-soname/-Wl,-undefined,error -Wl,-install_name/g" build/make/Makefile.patched >build/make/Makefile
|
||||||
fi
|
fi
|
||||||
|
|
||||||
execute ./configure --prefix=${WORKSPACE} --disable-unit-tests --disable-shared
|
execute ./configure --prefix=${WORKSPACE} --disable-unit-tests --disable-shared
|
||||||
execute make -j $MJOBS
|
execute make -j $MJOBS
|
||||||
@@ -219,14 +218,14 @@ fi
|
|||||||
|
|
||||||
if build "xvidcore"; then
|
if build "xvidcore"; then
|
||||||
download "http://downloads.xvid.org/downloads/xvidcore-1.3.4.tar.gz" "xvidcore-1.3.4.tar.gz"
|
download "http://downloads.xvid.org/downloads/xvidcore-1.3.4.tar.gz" "xvidcore-1.3.4.tar.gz"
|
||||||
cd $PACKAGES/xvidcore || exit
|
cd $PACKAGES/xvidcore || exit
|
||||||
cd build/generic || exit
|
cd build/generic || exit
|
||||||
execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
|
execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
|
||||||
execute make -j $MJOBS
|
execute make -j $MJOBS
|
||||||
execute make install
|
execute make install
|
||||||
|
|
||||||
if [[ -f ${WORKSPACE}/lib/libxvidcore.4.dylib ]]; then
|
if [[ -f ${WORKSPACE}/lib/libxvidcore.4.dylib ]]; then
|
||||||
execute rm "${WORKSPACE}/lib/libxvidcore.4.dylib"
|
execute rm "${WORKSPACE}/lib/libxvidcore.4.dylib"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
build_done "xvidcore"
|
build_done "xvidcore"
|
||||||
@@ -238,11 +237,11 @@ if build "x264"; then
|
|||||||
|
|
||||||
if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
||||||
execute ./configure --prefix=${WORKSPACE} --enable-static --enable-pic CXXFLAGS="-fPIC"
|
execute ./configure --prefix=${WORKSPACE} --enable-static --enable-pic CXXFLAGS="-fPIC"
|
||||||
else
|
else
|
||||||
execute ./configure --prefix=${WORKSPACE} --enable-static --enable-pic
|
execute ./configure --prefix=${WORKSPACE} --enable-static --enable-pic
|
||||||
fi
|
fi
|
||||||
|
|
||||||
execute make -j $MJOBS
|
execute make -j $MJOBS
|
||||||
execute make install
|
execute make install
|
||||||
execute make install-lib-static
|
execute make install-lib-static
|
||||||
build_done "x264"
|
build_done "x264"
|
||||||
@@ -269,7 +268,7 @@ fi
|
|||||||
if build "libtheora"; then
|
if build "libtheora"; then
|
||||||
download "http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.gz" "libtheora-1.1.1.tar.bz"
|
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
|
cd $PACKAGES/libtheora-1.1.1 || exit
|
||||||
sed "s/-fforce-addr//g" configure > configure.patched
|
sed "s/-fforce-addr//g" configure >configure.patched
|
||||||
chmod +x configure.patched
|
chmod +x configure.patched
|
||||||
mv configure.patched configure
|
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 ./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
|
||||||
@@ -289,7 +288,7 @@ fi
|
|||||||
|
|
||||||
if build "cmake"; then
|
if build "cmake"; then
|
||||||
download "https://cmake.org/files/v3.11/cmake-3.11.3.tar.gz" "cmake-3.11.3.tar.gz"
|
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
|
cd $PACKAGES/cmake-3.11.3 || exit
|
||||||
rm Modules/FindJava.cmake
|
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
|
||||||
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
|
||||||
@@ -315,7 +314,7 @@ if build "x265"; then
|
|||||||
execute cmake -DCMAKE_INSTALL_PREFIX:PATH=${WORKSPACE} -DENABLE_SHARED:bool=off .
|
execute cmake -DCMAKE_INSTALL_PREFIX:PATH=${WORKSPACE} -DENABLE_SHARED:bool=off .
|
||||||
execute make -j $MJOBS
|
execute make -j $MJOBS
|
||||||
execute make install
|
execute make install
|
||||||
sed "s/-lx265/-lx265 -lstdc++/g" "$WORKSPACE/lib/pkgconfig/x265.pc" > "$WORKSPACE/lib/pkgconfig/x265.pc.tmp"
|
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"
|
mv "$WORKSPACE/lib/pkgconfig/x265.pc.tmp" "$WORKSPACE/lib/pkgconfig/x265.pc"
|
||||||
build_done "x265"
|
build_done "x265"
|
||||||
fi
|
fi
|
||||||
@@ -329,17 +328,16 @@ if build "fdk_aac"; then
|
|||||||
build_done "fdk_aac"
|
build_done "fdk_aac"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
build "ffmpeg"
|
build "ffmpeg"
|
||||||
download "http://ffmpeg.org/releases/ffmpeg-4.1.tar.bz2" "ffmpeg-snapshot.tar.bz2"
|
download "http://ffmpeg.org/releases/ffmpeg-4.1.tar.bz2" "ffmpeg-snapshot.tar.bz2"
|
||||||
cd $PACKAGES/ffmpeg-4.1 || exit
|
cd $PACKAGES/ffmpeg-4.1 || exit
|
||||||
./configure $ADDITIONAL_CONFIGURE_OPTIONS \
|
./configure $ADDITIONAL_CONFIGURE_OPTIONS \
|
||||||
--pkgconfigdir="$WORKSPACE/lib/pkgconfig" \
|
--pkgconfigdir="$WORKSPACE/lib/pkgconfig" \
|
||||||
--prefix=${WORKSPACE} \
|
--prefix=${WORKSPACE} \
|
||||||
--pkg-config-flags="--static" \
|
--pkg-config-flags="--static" \
|
||||||
--extra-cflags="-I$WORKSPACE/include" \
|
--extra-cflags="-I$WORKSPACE/include" \
|
||||||
--extra-ldflags="-L$WORKSPACE/lib" \
|
--extra-ldflags="-L$WORKSPACE/lib" \
|
||||||
--extra-libs="-lpthread -lm" \
|
--extra-libs="-lpthread -lm" \
|
||||||
--enable-static \
|
--enable-static \
|
||||||
--disable-debug \
|
--disable-debug \
|
||||||
--disable-shared \
|
--disable-shared \
|
||||||
@@ -368,14 +366,13 @@ execute make install
|
|||||||
|
|
||||||
INSTALL_FOLDER="/usr/bin"
|
INSTALL_FOLDER="/usr/bin"
|
||||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
INSTALL_FOLDER="/usr/local/bin"
|
INSTALL_FOLDER="/usr/local/bin"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Building done. The binary can be found here: $WORKSPACE/bin/ffmpeg"
|
echo "Building done. The binary can be found here: $WORKSPACE/bin/ffmpeg"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
if [[ $AUTOINSTALL == "yes" ]]; then
|
if [[ $AUTOINSTALL == "yes" ]]; then
|
||||||
if command_exists "sudo"; then
|
if command_exists "sudo"; then
|
||||||
sudo cp "$WORKSPACE/bin/ffmpeg" "$INSTALL_FOLDER/ffmpeg"
|
sudo cp "$WORKSPACE/bin/ffmpeg" "$INSTALL_FOLDER/ffmpeg"
|
||||||
@@ -388,11 +385,11 @@ elif [[ ! $SKIPINSTALL == "yes" ]]; then
|
|||||||
read -r -p "Install the binary to your $INSTALL_FOLDER folder? [Y/n] " response
|
read -r -p "Install the binary to your $INSTALL_FOLDER folder? [Y/n] " response
|
||||||
|
|
||||||
case $response in
|
case $response in
|
||||||
[yY][eE][sS]|[yY])
|
[yY][eE][sS] | [yY])
|
||||||
sudo cp "$WORKSPACE/bin/ffmpeg" "$INSTALL_FOLDER/ffmpeg"
|
sudo cp "$WORKSPACE/bin/ffmpeg" "$INSTALL_FOLDER/ffmpeg"
|
||||||
sudo cp "$WORKSPACE/bin/ffprobe" "$INSTALL_FOLDER/ffprobe"
|
sudo cp "$WORKSPACE/bin/ffprobe" "$INSTALL_FOLDER/ffprobe"
|
||||||
echo "Done. ffmpeg is now installed to your system"
|
echo "Done. ffmpeg is now installed to your system"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Helper script to download and run the build-ffmpeg script.
|
# Helper script to download and run the build-ffmpeg script.
|
||||||
|
|
||||||
make_dir () {
|
make_dir() {
|
||||||
if [ ! -d $1 ]; then
|
if [ ! -d $1 ]; then
|
||||||
if ! mkdir $1; then
|
if ! mkdir $1; then
|
||||||
printf "\n Failed to create dir %s" "$1";
|
printf "\n Failed to create dir %s" "$1"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -21,7 +21,7 @@ command_exists() {
|
|||||||
TARGET='ffmpeg-build'
|
TARGET='ffmpeg-build'
|
||||||
|
|
||||||
if ! command_exists "curl"; then
|
if ! command_exists "curl"; then
|
||||||
echo "curl not installed.";
|
echo "curl not installed."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -37,4 +37,3 @@ echo "Now we download and execute the build script"
|
|||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
bash build-ffmpeg --build
|
bash build-ffmpeg --build
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ NZBGET_POSTPROCESS_SUCCESS = 93
|
|||||||
NZBGET_POSTPROCESS_ERROR = 94
|
NZBGET_POSTPROCESS_ERROR = 94
|
||||||
NZBGET_POSTPROCESS_NONE = 95
|
NZBGET_POSTPROCESS_NONE = 95
|
||||||
|
|
||||||
|
|
||||||
def is_sample(filePath, inputName, maxSampleSize, SampleIDs):
|
def is_sample(filePath, inputName, maxSampleSize, SampleIDs):
|
||||||
# 200 MB in bytes
|
# 200 MB in bytes
|
||||||
SIZE_CUTOFF = int(maxSampleSize) * 1024 * 1024
|
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 none of these were met.
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
if not os.environ.has_key('NZBOP_SCRIPTDIR'):
|
if not os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||||
print "This script can only be called from NZBGet (11.0 or later)."
|
print "This script can only be called from NZBGet (11.0 or later)."
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if os.environ['NZBOP_VERSION'][0:5] < '11.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)
|
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
|
status = 0
|
||||||
if os.environ.has_key('NZBPP_TOTALSTATUS'):
|
if os.environ.has_key('NZBPP_TOTALSTATUS'):
|
||||||
if not os.environ['NZBPP_TOTALSTATUS'] == 'SUCCESS':
|
if not os.environ['NZBPP_TOTALSTATUS'] == 'SUCCESS':
|
||||||
@@ -69,7 +73,8 @@ else:
|
|||||||
|
|
||||||
# Check if destination directory exists (important for reprocessing of history items)
|
# Check if destination directory exists (important for reprocessing of history items)
|
||||||
if not os.path.isdir(os.environ['NZBPP_DIRECTORY']):
|
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
|
status = 1
|
||||||
|
|
||||||
# All checks done, now launching the script.
|
# All checks done, now launching the script.
|
||||||
@@ -82,8 +87,9 @@ for dirpath, dirnames, filenames in os.walk(os.environ['NZBPP_DIRECTORY']):
|
|||||||
for file in filenames:
|
for file in filenames:
|
||||||
filePath = os.path.join(dirpath, file)
|
filePath = os.path.join(dirpath, file)
|
||||||
fileName, fileExtension = os.path.splitext(file)
|
fileName, fileExtension = os.path.splitext(file)
|
||||||
if fileExtension in mediaContainer or ".*" in mediaContainer : # If the file is a video 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
|
print "Deleting sample file: ", filePath
|
||||||
try:
|
try:
|
||||||
os.unlink(filePath)
|
os.unlink(filePath)
|
||||||
|
|||||||
@@ -22,14 +22,17 @@ if not os.environ.has_key('NZBOP_SCRIPTDIR'):
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if os.environ['NZBOP_VERSION'][0:5] < '11.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)
|
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
|
status = 0
|
||||||
if os.environ.has_key('NZBPP_TOTALSTATUS'):
|
if os.environ.has_key('NZBPP_TOTALSTATUS'):
|
||||||
if not os.environ['NZBPP_TOTALSTATUS'] == 'SUCCESS':
|
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
|
status = 1
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@@ -64,8 +67,9 @@ if not os.path.isdir(os.environ['NZBPP_DIRECTORY']):
|
|||||||
if status == 1:
|
if status == 1:
|
||||||
sys.exit(NZBGET_POSTPROCESS_NONE)
|
sys.exit(NZBGET_POSTPROCESS_NONE)
|
||||||
|
|
||||||
|
|
||||||
def removeEmptyFolders(path, removeRoot=True):
|
def removeEmptyFolders(path, removeRoot=True):
|
||||||
#Function to remove empty folders
|
# Function to remove empty folders
|
||||||
if not os.path.isdir(path):
|
if not os.path.isdir(path):
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -84,6 +88,7 @@ def removeEmptyFolders(path, removeRoot=True):
|
|||||||
print "[INFO] Removing empty folder:%s" % path
|
print "[INFO] Removing empty folder:%s" % path
|
||||||
os.rmdir(path)
|
os.rmdir(path)
|
||||||
|
|
||||||
|
|
||||||
directory = os.path.normpath(os.environ['NZBPP_DIRECTORY'])
|
directory = os.path.normpath(os.environ['NZBPP_DIRECTORY'])
|
||||||
if os.environ['NZBPO_DESTINATIONDIRECTORY'] and os.path.isdir(os.environ['NZBPO_DESTINATIONDIRECTORY']):
|
if os.environ['NZBPO_DESTINATIONDIRECTORY'] and os.path.isdir(os.environ['NZBPO_DESTINATIONDIRECTORY']):
|
||||||
destination = os.environ['NZBPO_DESTINATIONDIRECTORY']
|
destination = os.environ['NZBPO_DESTINATIONDIRECTORY']
|
||||||
|
|||||||
@@ -25,21 +25,25 @@ NZBGET_POSTPROCESS_NONE = 95
|
|||||||
# EXTENSION STUFF
|
# EXTENSION STUFF
|
||||||
############################################################
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
def do_check():
|
def do_check():
|
||||||
if not os.environ.has_key('NZBOP_SCRIPTDIR'):
|
if not os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||||
print "This script can only be called from NZBGet (11.0 or later)."
|
print "This script can only be called from NZBGet (11.0 or later)."
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if os.environ['NZBOP_VERSION'][0:5] < '11.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)
|
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
|
status = 0
|
||||||
if 'NZBPP_TOTALSTATUS' in os.environ:
|
if 'NZBPP_TOTALSTATUS' in os.environ:
|
||||||
if not os.environ['NZBPP_TOTALSTATUS'] == 'SUCCESS':
|
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
|
status = 1
|
||||||
else:
|
else:
|
||||||
# Check par status
|
# Check par status
|
||||||
@@ -144,7 +148,8 @@ if not found_files:
|
|||||||
print("[INFO] No files were found in \"%s\"" % directory)
|
print("[INFO] No files were found in \"%s\"" % directory)
|
||||||
sys.exit(NZBGET_POSTPROCESS_NONE)
|
sys.exit(NZBGET_POSTPROCESS_NONE)
|
||||||
else:
|
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
|
# loop files checking for file hash
|
||||||
moved_files = 0
|
moved_files = 0
|
||||||
for found_file_path in found_files:
|
for found_file_path in found_files:
|
||||||
@@ -154,14 +159,18 @@ else:
|
|||||||
|
|
||||||
# is this a file hash
|
# is this a file hash
|
||||||
if is_file_hash(file_name):
|
if is_file_hash(file_name):
|
||||||
new_file_path = os.path.join(dir_name, "%s.%s" % (nzb_name, file_ext))
|
new_file_path = os.path.join(
|
||||||
print("[INFO] Moving \"%s\" to \"%s\"" % (found_file_path, new_file_path))
|
dir_name, "%s.%s" % (nzb_name, file_ext))
|
||||||
|
print("[INFO] Moving \"%s\" to \"%s\"" %
|
||||||
|
(found_file_path, new_file_path))
|
||||||
try:
|
try:
|
||||||
shutil.move(found_file_path, new_file_path)
|
shutil.move(found_file_path, new_file_path)
|
||||||
moved_files += 1
|
moved_files += 1
|
||||||
except Exception:
|
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)
|
sys.exit(NZBGET_POSTPROCESS_SUCCESS)
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ For more details, refer to source.
|
|||||||
from __future__ import division, print_function
|
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
|
import sys
|
||||||
@@ -113,13 +113,16 @@ try:
|
|||||||
|
|
||||||
class AES_CBC_Decrypt(object):
|
class AES_CBC_Decrypt(object):
|
||||||
"""Decrypt API"""
|
"""Decrypt API"""
|
||||||
|
|
||||||
def __init__(self, key, iv):
|
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
|
self.decrypt = ciph.decryptor().update
|
||||||
|
|
||||||
def pbkdf2_sha256(password, salt, iters):
|
def pbkdf2_sha256(password, salt, iters):
|
||||||
"""PBKDF2 with HMAC-SHA256"""
|
"""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)
|
return ctx.derive(password)
|
||||||
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@@ -128,6 +131,7 @@ try:
|
|||||||
|
|
||||||
class AES_CBC_Decrypt(object):
|
class AES_CBC_Decrypt(object):
|
||||||
"""Decrypt API"""
|
"""Decrypt API"""
|
||||||
|
|
||||||
def __init__(self, key, iv):
|
def __init__(self, key, iv):
|
||||||
self.decrypt = AES.new(key, AES.MODE_CBC, iv).decrypt
|
self.decrypt = AES.new(key, AES.MODE_CBC, iv).decrypt
|
||||||
|
|
||||||
@@ -173,7 +177,7 @@ __version__ = '3.0'
|
|||||||
__all__ = ['is_rarfile', 'RarInfo', 'RarFile', 'RarExtFile']
|
__all__ = ['is_rarfile', 'RarInfo', 'RarFile', 'RarExtFile']
|
||||||
|
|
||||||
##
|
##
|
||||||
## Module configuration. Can be tuned after importing.
|
# Module configuration. Can be tuned after importing.
|
||||||
##
|
##
|
||||||
|
|
||||||
#: default fallback charset
|
#: default fallback charset
|
||||||
@@ -222,72 +226,72 @@ HACK_SIZE_LIMIT = 20 * 1024 * 1024
|
|||||||
PATH_SEP = '/'
|
PATH_SEP = '/'
|
||||||
|
|
||||||
##
|
##
|
||||||
## rar constants
|
# rar constants
|
||||||
##
|
##
|
||||||
|
|
||||||
# block types
|
# block types
|
||||||
RAR_BLOCK_MARK = 0x72 # r
|
RAR_BLOCK_MARK = 0x72 # r
|
||||||
RAR_BLOCK_MAIN = 0x73 # s
|
RAR_BLOCK_MAIN = 0x73 # s
|
||||||
RAR_BLOCK_FILE = 0x74 # t
|
RAR_BLOCK_FILE = 0x74 # t
|
||||||
RAR_BLOCK_OLD_COMMENT = 0x75 # u
|
RAR_BLOCK_OLD_COMMENT = 0x75 # u
|
||||||
RAR_BLOCK_OLD_EXTRA = 0x76 # v
|
RAR_BLOCK_OLD_EXTRA = 0x76 # v
|
||||||
RAR_BLOCK_OLD_SUB = 0x77 # w
|
RAR_BLOCK_OLD_SUB = 0x77 # w
|
||||||
RAR_BLOCK_OLD_RECOVERY = 0x78 # x
|
RAR_BLOCK_OLD_RECOVERY = 0x78 # x
|
||||||
RAR_BLOCK_OLD_AUTH = 0x79 # y
|
RAR_BLOCK_OLD_AUTH = 0x79 # y
|
||||||
RAR_BLOCK_SUB = 0x7a # z
|
RAR_BLOCK_SUB = 0x7a # z
|
||||||
RAR_BLOCK_ENDARC = 0x7b # {
|
RAR_BLOCK_ENDARC = 0x7b # {
|
||||||
|
|
||||||
# flags for RAR_BLOCK_MAIN
|
# flags for RAR_BLOCK_MAIN
|
||||||
RAR_MAIN_VOLUME = 0x0001
|
RAR_MAIN_VOLUME = 0x0001
|
||||||
RAR_MAIN_COMMENT = 0x0002
|
RAR_MAIN_COMMENT = 0x0002
|
||||||
RAR_MAIN_LOCK = 0x0004
|
RAR_MAIN_LOCK = 0x0004
|
||||||
RAR_MAIN_SOLID = 0x0008
|
RAR_MAIN_SOLID = 0x0008
|
||||||
RAR_MAIN_NEWNUMBERING = 0x0010
|
RAR_MAIN_NEWNUMBERING = 0x0010
|
||||||
RAR_MAIN_AUTH = 0x0020
|
RAR_MAIN_AUTH = 0x0020
|
||||||
RAR_MAIN_RECOVERY = 0x0040
|
RAR_MAIN_RECOVERY = 0x0040
|
||||||
RAR_MAIN_PASSWORD = 0x0080
|
RAR_MAIN_PASSWORD = 0x0080
|
||||||
RAR_MAIN_FIRSTVOLUME = 0x0100
|
RAR_MAIN_FIRSTVOLUME = 0x0100
|
||||||
RAR_MAIN_ENCRYPTVER = 0x0200
|
RAR_MAIN_ENCRYPTVER = 0x0200
|
||||||
|
|
||||||
# flags for RAR_BLOCK_FILE
|
# flags for RAR_BLOCK_FILE
|
||||||
RAR_FILE_SPLIT_BEFORE = 0x0001
|
RAR_FILE_SPLIT_BEFORE = 0x0001
|
||||||
RAR_FILE_SPLIT_AFTER = 0x0002
|
RAR_FILE_SPLIT_AFTER = 0x0002
|
||||||
RAR_FILE_PASSWORD = 0x0004
|
RAR_FILE_PASSWORD = 0x0004
|
||||||
RAR_FILE_COMMENT = 0x0008
|
RAR_FILE_COMMENT = 0x0008
|
||||||
RAR_FILE_SOLID = 0x0010
|
RAR_FILE_SOLID = 0x0010
|
||||||
RAR_FILE_DICTMASK = 0x00e0
|
RAR_FILE_DICTMASK = 0x00e0
|
||||||
RAR_FILE_DICT64 = 0x0000
|
RAR_FILE_DICT64 = 0x0000
|
||||||
RAR_FILE_DICT128 = 0x0020
|
RAR_FILE_DICT128 = 0x0020
|
||||||
RAR_FILE_DICT256 = 0x0040
|
RAR_FILE_DICT256 = 0x0040
|
||||||
RAR_FILE_DICT512 = 0x0060
|
RAR_FILE_DICT512 = 0x0060
|
||||||
RAR_FILE_DICT1024 = 0x0080
|
RAR_FILE_DICT1024 = 0x0080
|
||||||
RAR_FILE_DICT2048 = 0x00a0
|
RAR_FILE_DICT2048 = 0x00a0
|
||||||
RAR_FILE_DICT4096 = 0x00c0
|
RAR_FILE_DICT4096 = 0x00c0
|
||||||
RAR_FILE_DIRECTORY = 0x00e0
|
RAR_FILE_DIRECTORY = 0x00e0
|
||||||
RAR_FILE_LARGE = 0x0100
|
RAR_FILE_LARGE = 0x0100
|
||||||
RAR_FILE_UNICODE = 0x0200
|
RAR_FILE_UNICODE = 0x0200
|
||||||
RAR_FILE_SALT = 0x0400
|
RAR_FILE_SALT = 0x0400
|
||||||
RAR_FILE_VERSION = 0x0800
|
RAR_FILE_VERSION = 0x0800
|
||||||
RAR_FILE_EXTTIME = 0x1000
|
RAR_FILE_EXTTIME = 0x1000
|
||||||
RAR_FILE_EXTFLAGS = 0x2000
|
RAR_FILE_EXTFLAGS = 0x2000
|
||||||
|
|
||||||
# flags for RAR_BLOCK_ENDARC
|
# flags for RAR_BLOCK_ENDARC
|
||||||
RAR_ENDARC_NEXT_VOLUME = 0x0001
|
RAR_ENDARC_NEXT_VOLUME = 0x0001
|
||||||
RAR_ENDARC_DATACRC = 0x0002
|
RAR_ENDARC_DATACRC = 0x0002
|
||||||
RAR_ENDARC_REVSPACE = 0x0004
|
RAR_ENDARC_REVSPACE = 0x0004
|
||||||
RAR_ENDARC_VOLNR = 0x0008
|
RAR_ENDARC_VOLNR = 0x0008
|
||||||
|
|
||||||
# flags common to all blocks
|
# flags common to all blocks
|
||||||
RAR_SKIP_IF_UNKNOWN = 0x4000
|
RAR_SKIP_IF_UNKNOWN = 0x4000
|
||||||
RAR_LONG_BLOCK = 0x8000
|
RAR_LONG_BLOCK = 0x8000
|
||||||
|
|
||||||
# Host OS types
|
# Host OS types
|
||||||
RAR_OS_MSDOS = 0
|
RAR_OS_MSDOS = 0
|
||||||
RAR_OS_OS2 = 1
|
RAR_OS_OS2 = 1
|
||||||
RAR_OS_WIN32 = 2
|
RAR_OS_WIN32 = 2
|
||||||
RAR_OS_UNIX = 3
|
RAR_OS_UNIX = 3
|
||||||
RAR_OS_MACOS = 4
|
RAR_OS_MACOS = 4
|
||||||
RAR_OS_BEOS = 5
|
RAR_OS_BEOS = 5
|
||||||
|
|
||||||
# Compression methods - '0'..'5'
|
# Compression methods - '0'..'5'
|
||||||
RAR_M0 = 0x30
|
RAR_M0 = 0x30
|
||||||
@@ -369,7 +373,7 @@ RAR5_OS_WINDOWS = 0
|
|||||||
RAR5_OS_UNIX = 1
|
RAR5_OS_UNIX = 1
|
||||||
|
|
||||||
##
|
##
|
||||||
## internal constants
|
# internal constants
|
||||||
##
|
##
|
||||||
|
|
||||||
RAR_ID = b"Rar!\x1a\x07\x00"
|
RAR_ID = b"Rar!\x1a\x07\x00"
|
||||||
@@ -379,6 +383,7 @@ EMPTY = b''
|
|||||||
UTC = timezone(timedelta(0), 'UTC')
|
UTC = timezone(timedelta(0), 'UTC')
|
||||||
BSIZE = 32 * 1024
|
BSIZE = 32 * 1024
|
||||||
|
|
||||||
|
|
||||||
def _get_rar_version(xfile):
|
def _get_rar_version(xfile):
|
||||||
'''Check quickly whether file is rar archive.
|
'''Check quickly whether file is rar archive.
|
||||||
'''
|
'''
|
||||||
@@ -391,83 +396,108 @@ def _get_rar_version(xfile):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
##
|
##
|
||||||
## Public interface
|
# Public interface
|
||||||
##
|
##
|
||||||
|
|
||||||
|
|
||||||
def is_rarfile(xfile):
|
def is_rarfile(xfile):
|
||||||
'''Check quickly whether file is rar archive.
|
'''Check quickly whether file is rar archive.
|
||||||
'''
|
'''
|
||||||
return _get_rar_version(xfile) > 0
|
return _get_rar_version(xfile) > 0
|
||||||
|
|
||||||
|
|
||||||
class Error(Exception):
|
class Error(Exception):
|
||||||
"""Base class for rarfile errors."""
|
"""Base class for rarfile errors."""
|
||||||
|
|
||||||
|
|
||||||
class BadRarFile(Error):
|
class BadRarFile(Error):
|
||||||
"""Incorrect data in archive."""
|
"""Incorrect data in archive."""
|
||||||
|
|
||||||
|
|
||||||
class NotRarFile(Error):
|
class NotRarFile(Error):
|
||||||
"""The file is not RAR archive."""
|
"""The file is not RAR archive."""
|
||||||
|
|
||||||
|
|
||||||
class BadRarName(Error):
|
class BadRarName(Error):
|
||||||
"""Cannot guess multipart name components."""
|
"""Cannot guess multipart name components."""
|
||||||
|
|
||||||
|
|
||||||
class NoRarEntry(Error):
|
class NoRarEntry(Error):
|
||||||
"""File not found in RAR"""
|
"""File not found in RAR"""
|
||||||
|
|
||||||
|
|
||||||
class PasswordRequired(Error):
|
class PasswordRequired(Error):
|
||||||
"""File requires password"""
|
"""File requires password"""
|
||||||
|
|
||||||
|
|
||||||
class NeedFirstVolume(Error):
|
class NeedFirstVolume(Error):
|
||||||
"""Need to start from first volume."""
|
"""Need to start from first volume."""
|
||||||
|
|
||||||
|
|
||||||
class NoCrypto(Error):
|
class NoCrypto(Error):
|
||||||
"""Cannot parse encrypted headers - no crypto available."""
|
"""Cannot parse encrypted headers - no crypto available."""
|
||||||
|
|
||||||
|
|
||||||
class RarExecError(Error):
|
class RarExecError(Error):
|
||||||
"""Problem reported by unrar/rar."""
|
"""Problem reported by unrar/rar."""
|
||||||
|
|
||||||
|
|
||||||
class RarWarning(RarExecError):
|
class RarWarning(RarExecError):
|
||||||
"""Non-fatal error"""
|
"""Non-fatal error"""
|
||||||
|
|
||||||
|
|
||||||
class RarFatalError(RarExecError):
|
class RarFatalError(RarExecError):
|
||||||
"""Fatal error"""
|
"""Fatal error"""
|
||||||
|
|
||||||
|
|
||||||
class RarCRCError(RarExecError):
|
class RarCRCError(RarExecError):
|
||||||
"""CRC error during unpacking"""
|
"""CRC error during unpacking"""
|
||||||
|
|
||||||
|
|
||||||
class RarLockedArchiveError(RarExecError):
|
class RarLockedArchiveError(RarExecError):
|
||||||
"""Must not modify locked archive"""
|
"""Must not modify locked archive"""
|
||||||
|
|
||||||
|
|
||||||
class RarWriteError(RarExecError):
|
class RarWriteError(RarExecError):
|
||||||
"""Write error"""
|
"""Write error"""
|
||||||
|
|
||||||
|
|
||||||
class RarOpenError(RarExecError):
|
class RarOpenError(RarExecError):
|
||||||
"""Open error"""
|
"""Open error"""
|
||||||
|
|
||||||
|
|
||||||
class RarUserError(RarExecError):
|
class RarUserError(RarExecError):
|
||||||
"""User error"""
|
"""User error"""
|
||||||
|
|
||||||
|
|
||||||
class RarMemoryError(RarExecError):
|
class RarMemoryError(RarExecError):
|
||||||
"""Memory error"""
|
"""Memory error"""
|
||||||
|
|
||||||
|
|
||||||
class RarCreateError(RarExecError):
|
class RarCreateError(RarExecError):
|
||||||
"""Create error"""
|
"""Create error"""
|
||||||
|
|
||||||
|
|
||||||
class RarNoFilesError(RarExecError):
|
class RarNoFilesError(RarExecError):
|
||||||
"""No files that match pattern were found"""
|
"""No files that match pattern were found"""
|
||||||
|
|
||||||
|
|
||||||
class RarUserBreak(RarExecError):
|
class RarUserBreak(RarExecError):
|
||||||
"""User stop"""
|
"""User stop"""
|
||||||
|
|
||||||
|
|
||||||
class RarWrongPassword(RarExecError):
|
class RarWrongPassword(RarExecError):
|
||||||
"""Incorrect password"""
|
"""Incorrect password"""
|
||||||
|
|
||||||
|
|
||||||
class RarUnknownError(RarExecError):
|
class RarUnknownError(RarExecError):
|
||||||
"""Unknown exit code"""
|
"""Unknown exit code"""
|
||||||
|
|
||||||
|
|
||||||
class RarSignalExit(RarExecError):
|
class RarSignalExit(RarExecError):
|
||||||
"""Unrar exited with signal"""
|
"""Unrar exited with signal"""
|
||||||
|
|
||||||
|
|
||||||
class RarCannotExec(RarExecError):
|
class RarCannotExec(RarExecError):
|
||||||
"""Executable not found."""
|
"""Executable not found."""
|
||||||
|
|
||||||
@@ -734,13 +764,15 @@ class RarFile(object):
|
|||||||
# entry lookup
|
# entry lookup
|
||||||
inf = self.getinfo(fname)
|
inf = self.getinfo(fname)
|
||||||
if inf.isdir():
|
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
|
# check password
|
||||||
if inf.needs_password():
|
if inf.needs_password():
|
||||||
psw = psw or self._password
|
psw = psw or self._password
|
||||||
if psw is None:
|
if psw is None:
|
||||||
raise PasswordRequired("File %s requires password" % inf.filename)
|
raise PasswordRequired(
|
||||||
|
"File %s requires password" % inf.filename)
|
||||||
else:
|
else:
|
||||||
psw = None
|
psw = None
|
||||||
|
|
||||||
@@ -831,7 +863,7 @@ class RarFile(object):
|
|||||||
return self._file_parser.strerror()
|
return self._file_parser.strerror()
|
||||||
|
|
||||||
##
|
##
|
||||||
## private methods
|
# private methods
|
||||||
##
|
##
|
||||||
|
|
||||||
def _parse(self):
|
def _parse(self):
|
||||||
@@ -882,6 +914,7 @@ class RarFile(object):
|
|||||||
# File format parsing
|
# File format parsing
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
class CommonParser(object):
|
class CommonParser(object):
|
||||||
"""Shared parser parts."""
|
"""Shared parser parts."""
|
||||||
_main = None
|
_main = None
|
||||||
@@ -1011,7 +1044,8 @@ class CommonParser(object):
|
|||||||
# RAR 2.x does not set FIRSTVOLUME,
|
# RAR 2.x does not set FIRSTVOLUME,
|
||||||
# so check it only if NEWNUMBERING is used
|
# so check it only if NEWNUMBERING is used
|
||||||
if (h.flags & RAR_MAIN_FIRSTVOLUME) == 0:
|
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:
|
if h.flags & RAR_MAIN_PASSWORD:
|
||||||
self._needs_password = True
|
self._needs_password = True
|
||||||
if not self._password:
|
if not self._password:
|
||||||
@@ -1094,7 +1128,8 @@ class CommonParser(object):
|
|||||||
raise BadRarFile('cannot find copied file')
|
raise BadRarFile('cannot find copied file')
|
||||||
|
|
||||||
if inf.flags & RAR_FILE_SPLIT_BEFORE:
|
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?
|
# is temp write usable?
|
||||||
use_hack = 1
|
use_hack = 1
|
||||||
@@ -1181,6 +1216,7 @@ class CommonParser(object):
|
|||||||
# RAR3 format
|
# RAR3 format
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
class Rar3Info(RarInfo):
|
class Rar3Info(RarInfo):
|
||||||
"""RAR3 specific fields."""
|
"""RAR3 specific fields."""
|
||||||
extract_version = 15
|
extract_version = 15
|
||||||
@@ -1378,7 +1414,7 @@ class RAR3Parser(CommonParser):
|
|||||||
if stype == RAR_BLOCK_OLD_COMMENT and pos + S_COMMENT_HDR.size <= pos_next:
|
if stype == RAR_BLOCK_OLD_COMMENT and pos + S_COMMENT_HDR.size <= pos_next:
|
||||||
declen, ver, meth, crc = S_COMMENT_HDR.unpack_from(hdata, pos)
|
declen, ver, meth, crc = S_COMMENT_HDR.unpack_from(hdata, pos)
|
||||||
pos += S_COMMENT_HDR.size
|
pos += S_COMMENT_HDR.size
|
||||||
data = hdata[pos : pos_next]
|
data = hdata[pos: pos_next]
|
||||||
cmt = rar3_decompress(ver, meth, data, declen, sflags,
|
cmt = rar3_decompress(ver, meth, data, declen, sflags,
|
||||||
crc, self._password)
|
crc, self._password)
|
||||||
if not self._crc_check:
|
if not self._crc_check:
|
||||||
@@ -1464,6 +1500,7 @@ class RAR3Parser(CommonParser):
|
|||||||
# RAR5 format
|
# RAR5 format
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
class Rar5Info(RarInfo):
|
class Rar5Info(RarInfo):
|
||||||
"""Shared fields for RAR5 records.
|
"""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)
|
return self._open_hack_core(inf, psw, RAR5_ID + main_hdr, endarc_hdr)
|
||||||
|
|
||||||
##
|
##
|
||||||
## Utility classes
|
# Utility classes
|
||||||
##
|
##
|
||||||
|
|
||||||
|
|
||||||
class UnicodeFilename(object):
|
class UnicodeFilename(object):
|
||||||
"""Handle RAR3 unicode filename decompression.
|
"""Handle RAR3 unicode filename decompression.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, name, encdata):
|
def __init__(self, name, encdata):
|
||||||
self.std_name = bytearray(name)
|
self.std_name = bytearray(name)
|
||||||
self.encdata = bytearray(encdata)
|
self.encdata = bytearray(encdata)
|
||||||
@@ -2193,10 +2232,10 @@ class PipeReader(RarExtFile):
|
|||||||
vbuf = memoryview(buf)
|
vbuf = memoryview(buf)
|
||||||
res = got = 0
|
res = got = 0
|
||||||
while got < cnt:
|
while got < cnt:
|
||||||
res = self._fd.readinto(vbuf[got : cnt])
|
res = self._fd.readinto(vbuf[got: cnt])
|
||||||
if not res:
|
if not res:
|
||||||
break
|
break
|
||||||
self._md_context.update(vbuf[got : got + res])
|
self._md_context.update(vbuf[got: got + res])
|
||||||
self._remain -= res
|
self._remain -= res
|
||||||
got += res
|
got += res
|
||||||
return got
|
return got
|
||||||
@@ -2316,10 +2355,10 @@ class DirectReader(RarExtFile):
|
|||||||
cnt = self._cur_avail
|
cnt = self._cur_avail
|
||||||
|
|
||||||
# read into temp view
|
# read into temp view
|
||||||
res = self._fd.readinto(vbuf[got : got + cnt])
|
res = self._fd.readinto(vbuf[got: got + cnt])
|
||||||
if not res:
|
if not res:
|
||||||
break
|
break
|
||||||
self._md_context.update(vbuf[got : got + res])
|
self._md_context.update(vbuf[got: got + res])
|
||||||
self._cur_avail -= res
|
self._cur_avail -= res
|
||||||
self._remain -= res
|
self._remain -= res
|
||||||
got += res
|
got += res
|
||||||
@@ -2328,6 +2367,7 @@ class DirectReader(RarExtFile):
|
|||||||
|
|
||||||
class HeaderDecrypt(object):
|
class HeaderDecrypt(object):
|
||||||
"""File-like object that decrypts from another file"""
|
"""File-like object that decrypts from another file"""
|
||||||
|
|
||||||
def __init__(self, f, key, iv):
|
def __init__(self, f, key, iv):
|
||||||
self.f = f
|
self.f = f
|
||||||
self.ciph = AES_CBC_Decrypt(key, iv)
|
self.ciph = AES_CBC_Decrypt(key, iv)
|
||||||
@@ -2414,12 +2454,16 @@ class XFile(object):
|
|||||||
|
|
||||||
class NoHashContext(object):
|
class NoHashContext(object):
|
||||||
"""No-op hash function."""
|
"""No-op hash function."""
|
||||||
|
|
||||||
def __init__(self, data=None):
|
def __init__(self, data=None):
|
||||||
"""Initialize"""
|
"""Initialize"""
|
||||||
|
|
||||||
def update(self, data):
|
def update(self, data):
|
||||||
"""Update data"""
|
"""Update data"""
|
||||||
|
|
||||||
def digest(self):
|
def digest(self):
|
||||||
"""Final hash"""
|
"""Final hash"""
|
||||||
|
|
||||||
def hexdigest(self):
|
def hexdigest(self):
|
||||||
"""Hexadecimal digest."""
|
"""Hexadecimal digest."""
|
||||||
|
|
||||||
@@ -2510,9 +2554,10 @@ class Blake2SP(object):
|
|||||||
return tohex(self.digest())
|
return tohex(self.digest())
|
||||||
|
|
||||||
##
|
##
|
||||||
## Utility functions
|
# Utility functions
|
||||||
##
|
##
|
||||||
|
|
||||||
|
|
||||||
S_LONG = Struct('<L')
|
S_LONG = Struct('<L')
|
||||||
S_SHORT = Struct('<H')
|
S_SHORT = Struct('<H')
|
||||||
S_BYTE = Struct('<B')
|
S_BYTE = Struct('<B')
|
||||||
@@ -2521,6 +2566,7 @@ S_BLK_HDR = Struct('<HBHH')
|
|||||||
S_FILE_HDR = Struct('<LLBLLBBHL')
|
S_FILE_HDR = Struct('<LLBLLBBHL')
|
||||||
S_COMMENT_HDR = Struct('<HBBH')
|
S_COMMENT_HDR = Struct('<HBBH')
|
||||||
|
|
||||||
|
|
||||||
def load_vint(buf, pos):
|
def load_vint(buf, pos):
|
||||||
"""Load variable-size int."""
|
"""Load variable-size int."""
|
||||||
limit = min(pos + 11, len(buf))
|
limit = min(pos + 11, len(buf))
|
||||||
@@ -2534,6 +2580,7 @@ def load_vint(buf, pos):
|
|||||||
return res, pos
|
return res, pos
|
||||||
raise BadRarFile('cannot load vint')
|
raise BadRarFile('cannot load vint')
|
||||||
|
|
||||||
|
|
||||||
def load_byte(buf, pos):
|
def load_byte(buf, pos):
|
||||||
"""Load single byte"""
|
"""Load single byte"""
|
||||||
end = pos + 1
|
end = pos + 1
|
||||||
@@ -2541,6 +2588,7 @@ def load_byte(buf, pos):
|
|||||||
raise BadRarFile('cannot load byte')
|
raise BadRarFile('cannot load byte')
|
||||||
return S_BYTE.unpack_from(buf, pos)[0], end
|
return S_BYTE.unpack_from(buf, pos)[0], end
|
||||||
|
|
||||||
|
|
||||||
def load_le32(buf, pos):
|
def load_le32(buf, pos):
|
||||||
"""Load little-endian 32-bit integer"""
|
"""Load little-endian 32-bit integer"""
|
||||||
end = pos + 4
|
end = pos + 4
|
||||||
@@ -2548,30 +2596,35 @@ def load_le32(buf, pos):
|
|||||||
raise BadRarFile('cannot load le32')
|
raise BadRarFile('cannot load le32')
|
||||||
return S_LONG.unpack_from(buf, pos)[0], pos + 4
|
return S_LONG.unpack_from(buf, pos)[0], pos + 4
|
||||||
|
|
||||||
|
|
||||||
def load_bytes(buf, num, pos):
|
def load_bytes(buf, num, pos):
|
||||||
"""Load sequence of bytes"""
|
"""Load sequence of bytes"""
|
||||||
end = pos + num
|
end = pos + num
|
||||||
if end > len(buf):
|
if end > len(buf):
|
||||||
raise BadRarFile('cannot load bytes')
|
raise BadRarFile('cannot load bytes')
|
||||||
return buf[pos : end], end
|
return buf[pos: end], end
|
||||||
|
|
||||||
|
|
||||||
def load_vstr(buf, pos):
|
def load_vstr(buf, pos):
|
||||||
"""Load bytes prefixed by vint length"""
|
"""Load bytes prefixed by vint length"""
|
||||||
slen, pos = load_vint(buf, pos)
|
slen, pos = load_vint(buf, pos)
|
||||||
return load_bytes(buf, slen, pos)
|
return load_bytes(buf, slen, pos)
|
||||||
|
|
||||||
|
|
||||||
def load_dostime(buf, pos):
|
def load_dostime(buf, pos):
|
||||||
"""Load LE32 dos timestamp"""
|
"""Load LE32 dos timestamp"""
|
||||||
stamp, pos = load_le32(buf, pos)
|
stamp, pos = load_le32(buf, pos)
|
||||||
tup = parse_dos_time(stamp)
|
tup = parse_dos_time(stamp)
|
||||||
return to_datetime(tup), pos
|
return to_datetime(tup), pos
|
||||||
|
|
||||||
|
|
||||||
def load_unixtime(buf, pos):
|
def load_unixtime(buf, pos):
|
||||||
"""Load LE32 unix timestamp"""
|
"""Load LE32 unix timestamp"""
|
||||||
secs, pos = load_le32(buf, pos)
|
secs, pos = load_le32(buf, pos)
|
||||||
dt = datetime.fromtimestamp(secs, UTC)
|
dt = datetime.fromtimestamp(secs, UTC)
|
||||||
return dt, pos
|
return dt, pos
|
||||||
|
|
||||||
|
|
||||||
def load_windowstime(buf, pos):
|
def load_windowstime(buf, pos):
|
||||||
"""Load LE64 windows timestamp"""
|
"""Load LE64 windows timestamp"""
|
||||||
# unix epoch (1970) in seconds from windows epoch (1601)
|
# unix epoch (1970) in seconds from windows epoch (1601)
|
||||||
@@ -2584,6 +2637,8 @@ def load_windowstime(buf, pos):
|
|||||||
return dt, pos
|
return dt, pos
|
||||||
|
|
||||||
# new-style next volume
|
# new-style next volume
|
||||||
|
|
||||||
|
|
||||||
def _next_newvol(volfile):
|
def _next_newvol(volfile):
|
||||||
i = len(volfile) - 1
|
i = len(volfile) - 1
|
||||||
while i >= 0:
|
while i >= 0:
|
||||||
@@ -2593,6 +2648,8 @@ def _next_newvol(volfile):
|
|||||||
raise BadRarName("Cannot construct volume name: " + volfile)
|
raise BadRarName("Cannot construct volume name: " + volfile)
|
||||||
|
|
||||||
# old-style next volume
|
# old-style next volume
|
||||||
|
|
||||||
|
|
||||||
def _next_oldvol(volfile):
|
def _next_oldvol(volfile):
|
||||||
# rar -> r00
|
# rar -> r00
|
||||||
if volfile[-4:].lower() == '.rar':
|
if volfile[-4:].lower() == '.rar':
|
||||||
@@ -2600,6 +2657,8 @@ def _next_oldvol(volfile):
|
|||||||
return _inc_volname(volfile, len(volfile) - 1)
|
return _inc_volname(volfile, len(volfile) - 1)
|
||||||
|
|
||||||
# increase digits with carry, otherwise just increment char
|
# increase digits with carry, otherwise just increment char
|
||||||
|
|
||||||
|
|
||||||
def _inc_volname(volfile, i):
|
def _inc_volname(volfile, i):
|
||||||
fn = list(volfile)
|
fn = list(volfile)
|
||||||
while i >= 0:
|
while i >= 0:
|
||||||
@@ -2611,6 +2670,8 @@ def _inc_volname(volfile, i):
|
|||||||
return ''.join(fn)
|
return ''.join(fn)
|
||||||
|
|
||||||
# rar3 extended time fields
|
# rar3 extended time fields
|
||||||
|
|
||||||
|
|
||||||
def _parse_ext_time(h, data, pos):
|
def _parse_ext_time(h, data, pos):
|
||||||
# flags and rest of data can be missing
|
# flags and rest of data can be missing
|
||||||
flags = 0
|
flags = 0
|
||||||
@@ -2628,6 +2689,8 @@ def _parse_ext_time(h, data, pos):
|
|||||||
return pos
|
return pos
|
||||||
|
|
||||||
# rar3 one extended time field
|
# rar3 one extended time field
|
||||||
|
|
||||||
|
|
||||||
def _parse_xtime(flag, data, pos, basetime=None):
|
def _parse_xtime(flag, data, pos, basetime=None):
|
||||||
res = None
|
res = None
|
||||||
if flag & 8:
|
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
|
# dostime has room for 30 seconds only, correct if needed
|
||||||
if flag & 4 and basetime.second < 59:
|
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:
|
else:
|
||||||
res = basetime.replace(microsecond=usec)
|
res = basetime.replace(microsecond=usec)
|
||||||
return res, pos
|
return res, pos
|
||||||
|
|
||||||
|
|
||||||
def is_filelike(obj):
|
def is_filelike(obj):
|
||||||
"""Filename or file object?
|
"""Filename or file object?
|
||||||
"""
|
"""
|
||||||
@@ -2665,6 +2730,7 @@ def is_filelike(obj):
|
|||||||
raise ValueError("Invalid object passed as file")
|
raise ValueError("Invalid object passed as file")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def rar3_s2k(psw, salt):
|
def rar3_s2k(psw, salt):
|
||||||
"""String-to-key hash for RAR3.
|
"""String-to-key hash for RAR3.
|
||||||
"""
|
"""
|
||||||
@@ -2683,6 +2749,7 @@ def rar3_s2k(psw, salt):
|
|||||||
key_le = pack("<LLLL", *unpack(">LLLL", key_be))
|
key_le = pack("<LLLL", *unpack(">LLLL", key_be))
|
||||||
return key_le, iv
|
return key_le, iv
|
||||||
|
|
||||||
|
|
||||||
def rar3_decompress(vers, meth, data, declen=0, flags=0, crc=0, psw=None, salt=None):
|
def rar3_decompress(vers, meth, data, declen=0, flags=0, crc=0, psw=None, salt=None):
|
||||||
"""Decompress blob of compressed data.
|
"""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()
|
tmpf.close()
|
||||||
os.unlink(tmpname)
|
os.unlink(tmpname)
|
||||||
|
|
||||||
|
|
||||||
def to_datetime(t):
|
def to_datetime(t):
|
||||||
"""Convert 6-part time tuple into datetime object.
|
"""Convert 6-part time tuple into datetime object.
|
||||||
"""
|
"""
|
||||||
@@ -2772,6 +2840,7 @@ def to_datetime(t):
|
|||||||
day = 28
|
day = 28
|
||||||
return datetime(year, mon, day, h, m, s)
|
return datetime(year, mon, day, h, m, s)
|
||||||
|
|
||||||
|
|
||||||
def parse_dos_time(stamp):
|
def parse_dos_time(stamp):
|
||||||
"""Parse standard 32-bit DOS timestamp.
|
"""Parse standard 32-bit DOS timestamp.
|
||||||
"""
|
"""
|
||||||
@@ -2783,6 +2852,7 @@ def parse_dos_time(stamp):
|
|||||||
yr = (stamp & 0x7F) + 1980
|
yr = (stamp & 0x7F) + 1980
|
||||||
return (yr, mon, day, hr, mn, sec * 2)
|
return (yr, mon, day, hr, mn, sec * 2)
|
||||||
|
|
||||||
|
|
||||||
def custom_popen(cmd):
|
def custom_popen(cmd):
|
||||||
"""Disconnect cmd from parent fds, read only from stdout.
|
"""Disconnect cmd from parent fds, read only from stdout.
|
||||||
"""
|
"""
|
||||||
@@ -2797,10 +2867,12 @@ def custom_popen(cmd):
|
|||||||
creationflags=creationflags)
|
creationflags=creationflags)
|
||||||
except OSError as ex:
|
except OSError as ex:
|
||||||
if ex.errno == errno.ENOENT:
|
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
|
raise
|
||||||
return p
|
return p
|
||||||
|
|
||||||
|
|
||||||
def custom_check(cmd, ignore_retcode=False):
|
def custom_check(cmd, ignore_retcode=False):
|
||||||
"""Run command, collect output, raise error if needed.
|
"""Run command, collect output, raise error if needed.
|
||||||
"""
|
"""
|
||||||
@@ -2810,6 +2882,7 @@ def custom_check(cmd, ignore_retcode=False):
|
|||||||
raise RarExecError("Check-run failed")
|
raise RarExecError("Check-run failed")
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
def add_password_arg(cmd, psw, ___required=False):
|
def add_password_arg(cmd, psw, ___required=False):
|
||||||
"""Append password switch to commandline.
|
"""Append password switch to commandline.
|
||||||
"""
|
"""
|
||||||
@@ -2820,6 +2893,7 @@ def add_password_arg(cmd, psw, ___required=False):
|
|||||||
else:
|
else:
|
||||||
cmd.append('-p-')
|
cmd.append('-p-')
|
||||||
|
|
||||||
|
|
||||||
def check_returncode(p, out):
|
def check_returncode(p, out):
|
||||||
"""Raise exception according to unrar exit code.
|
"""Raise exception according to unrar exit code.
|
||||||
"""
|
"""
|
||||||
@@ -2851,10 +2925,12 @@ def check_returncode(p, out):
|
|||||||
|
|
||||||
raise exc(msg)
|
raise exc(msg)
|
||||||
|
|
||||||
|
|
||||||
def hmac_sha256(key, data):
|
def hmac_sha256(key, data):
|
||||||
"""HMAC-SHA256"""
|
"""HMAC-SHA256"""
|
||||||
return HMAC(key, data, sha256).digest()
|
return HMAC(key, data, sha256).digest()
|
||||||
|
|
||||||
|
|
||||||
def membuf_tempfile(memfile):
|
def membuf_tempfile(memfile):
|
||||||
memfile.seek(0, 0)
|
memfile.seek(0, 0)
|
||||||
|
|
||||||
@@ -2874,6 +2950,7 @@ def membuf_tempfile(memfile):
|
|||||||
raise
|
raise
|
||||||
return tmpname
|
return tmpname
|
||||||
|
|
||||||
|
|
||||||
class XTempFile(object):
|
class XTempFile(object):
|
||||||
__slots__ = ('_tmpfile', '_filename')
|
__slots__ = ('_tmpfile', '_filename')
|
||||||
|
|
||||||
@@ -2900,11 +2977,13 @@ class XTempFile(object):
|
|||||||
# Check if unrar works
|
# Check if unrar works
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
ORIG_UNRAR_TOOL = UNRAR_TOOL
|
ORIG_UNRAR_TOOL = UNRAR_TOOL
|
||||||
ORIG_OPEN_ARGS = OPEN_ARGS
|
ORIG_OPEN_ARGS = OPEN_ARGS
|
||||||
ORIG_EXTRACT_ARGS = EXTRACT_ARGS
|
ORIG_EXTRACT_ARGS = EXTRACT_ARGS
|
||||||
ORIG_TEST_ARGS = TEST_ARGS
|
ORIG_TEST_ARGS = TEST_ARGS
|
||||||
|
|
||||||
|
|
||||||
def _check_unrar_tool():
|
def _check_unrar_tool():
|
||||||
global UNRAR_TOOL, OPEN_ARGS, EXTRACT_ARGS, TEST_ARGS
|
global UNRAR_TOOL, OPEN_ARGS, EXTRACT_ARGS, TEST_ARGS
|
||||||
try:
|
try:
|
||||||
@@ -2928,5 +3007,5 @@ def _check_unrar_tool():
|
|||||||
# no usable tool, only uncompressed archives work
|
# no usable tool, only uncompressed archives work
|
||||||
pass
|
pass
|
||||||
|
|
||||||
_check_unrar_tool()
|
|
||||||
|
|
||||||
|
_check_unrar_tool()
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ reverse_list = [r"\.\d{2}e\d{2}s\.", r"\.p0612\.", r"\.[pi]0801\.", r"\.p027\.",
|
|||||||
reverse_pattern = re.compile('|'.join(reverse_list), flags=re.IGNORECASE)
|
reverse_pattern = re.compile('|'.join(reverse_list), flags=re.IGNORECASE)
|
||||||
season_pattern = re.compile(r"(.*\.\d{2}e\d{2}s\.)(.*)", 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]+)")
|
word_pattern = re.compile(r"([^A-Z0-9]*[A-Z0-9]+)")
|
||||||
char_replace = [[r"(\w)1\.(\w)",r"\1i\2"]
|
char_replace = [[r"(\w)1\.(\w)", r"\1i\2"]
|
||||||
]
|
]
|
||||||
garbage_name = re.compile(r"^[a-zA-Z0-9]{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\.",
|
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'\.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\.",
|
||||||
@@ -133,12 +133,14 @@ class ek:
|
|||||||
def ek(func, *args, **kwargs):
|
def ek(func, *args, **kwargs):
|
||||||
if 'nt' == os.name:
|
if 'nt' == os.name:
|
||||||
# convert all str parameter values to unicode
|
# 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 = {k: x if not isinstance(x, str) else ek.win_encode_unicode(x) for k, x in
|
||||||
kwargs.iteritems()}
|
kwargs.iteritems()}
|
||||||
func_result = func(*args, **kwargs)
|
func_result = func(*args, **kwargs)
|
||||||
else:
|
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):
|
if type(func_result) in (list, tuple):
|
||||||
return ek.fix_list_encoding(func_result)
|
return ek.fix_list_encoding(func_result)
|
||||||
@@ -164,6 +166,7 @@ def tryInt(s, s_default=0):
|
|||||||
except:
|
except:
|
||||||
return s_default
|
return s_default
|
||||||
|
|
||||||
|
|
||||||
# NZBGet V11+
|
# NZBGet V11+
|
||||||
# Check if the script is called from nzbget 11.0 or later
|
# Check if the script is called from nzbget 11.0 or later
|
||||||
nzbget_version = evn.get('NZBOP_VERSION', '0.1')
|
nzbget_version = evn.get('NZBOP_VERSION', '0.1')
|
||||||
@@ -174,16 +177,17 @@ if nzbget_version >= 11:
|
|||||||
# NZBGet argv: all passed as environment variables.
|
# NZBGet argv: all passed as environment variables.
|
||||||
clientAgent = "nzbget"
|
clientAgent = "nzbget"
|
||||||
# Exit codes used by NZBGet
|
# Exit codes used by NZBGet
|
||||||
POSTPROCESS_PARCHECK=92
|
POSTPROCESS_PARCHECK = 92
|
||||||
POSTPROCESS_SUCCESS=93
|
POSTPROCESS_SUCCESS = 93
|
||||||
POSTPROCESS_ERROR=94
|
POSTPROCESS_ERROR = 94
|
||||||
POSTPROCESS_NONE=95
|
POSTPROCESS_NONE = 95
|
||||||
|
|
||||||
# Check nzbget.conf options
|
# Check nzbget.conf options
|
||||||
status = 0
|
status = 0
|
||||||
|
|
||||||
if evn['NZBOP_UNPACK'] != 'yes':
|
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)
|
sys.exit(POSTPROCESS_NONE)
|
||||||
|
|
||||||
parstatus = evn['NZBPP_PARSTATUS']
|
parstatus = evn['NZBPP_PARSTATUS']
|
||||||
@@ -216,20 +220,24 @@ if nzbget_version >= 11:
|
|||||||
fileExtension = ek.ek(os.path.splitext, file)[1]
|
fileExtension = ek.ek(os.path.splitext, file)[1]
|
||||||
|
|
||||||
if fileExtension in ['.par2']:
|
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
|
status = 1
|
||||||
break
|
break
|
||||||
|
|
||||||
if ek.ek(os.path.isfile, ek.ek(os.path.join, directory, "_brokenlog.txt")) and not status == 1:
|
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
|
status = 1
|
||||||
|
|
||||||
if not 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)
|
# Check if destination directory exists (important for reprocessing of history items)
|
||||||
if not ek.ek(os.path.isdir, directory):
|
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
|
status = 1
|
||||||
|
|
||||||
# All checks done, now launching the script.
|
# All checks done, now launching the script.
|
||||||
@@ -254,33 +262,39 @@ if nzbget_version >= 11:
|
|||||||
for wp in word_p:
|
for wp in word_p:
|
||||||
if wp[0] == ".":
|
if wp[0] == ".":
|
||||||
new_words += "."
|
new_words += "."
|
||||||
new_words += re.sub(r"\W","",wp)
|
new_words += re.sub(r"\W", "", wp)
|
||||||
for cr in char_replace:
|
for cr in char_replace:
|
||||||
new_words = re.sub(cr[0],cr[1],new_words)
|
new_words = re.sub(cr[0], cr[1], new_words)
|
||||||
new_filename = new_words[::-1] + na_parts.group(1)[::-1]
|
new_filename = new_words[::-1] + na_parts.group(1)[::-1]
|
||||||
else:
|
else:
|
||||||
new_filename = fileName[::-1]
|
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:
|
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
|
rd = True
|
||||||
except Exception,e:
|
except Exception, e:
|
||||||
logger.log(e, logger.ERROR)
|
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
|
pass
|
||||||
elif (fileExtension.lower() in media_extentions) and (garbage_name.search(fileName) is not None) and (media_pattern.search(base_name) is not None):
|
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
|
videos += 1
|
||||||
old_name = filePath
|
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:
|
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:
|
try:
|
||||||
ek.ek(os.rename, old_name, new_name)
|
ek.ek(os.rename, old_name, new_name)
|
||||||
rd = True
|
rd = True
|
||||||
except Exception,e:
|
except Exception, e:
|
||||||
logger.log(e, logger.ERROR)
|
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
|
pass
|
||||||
|
|
||||||
if rd:
|
if rd:
|
||||||
@@ -289,5 +303,6 @@ if nzbget_version >= 11:
|
|||||||
sys.exit(POSTPROCESS_NONE)
|
sys.exit(POSTPROCESS_NONE)
|
||||||
|
|
||||||
else:
|
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)
|
sys.exit(0)
|
||||||
|
|||||||
@@ -12,7 +12,15 @@
|
|||||||
### NZBGET SCAN SCRIPT ###
|
### 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
|
import rarfile.rarfile as rarfile
|
||||||
|
|
||||||
from gzip import FEXTRA, FNAME
|
from gzip import FEXTRA, FNAME
|
||||||
@@ -94,9 +102,11 @@ else:
|
|||||||
dupescore = None
|
dupescore = None
|
||||||
dupemode = 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 = []
|
nzb_list = []
|
||||||
|
|
||||||
|
|
||||||
def read_gzip_info(gzipfile):
|
def read_gzip_info(gzipfile):
|
||||||
gf = gzipfile.fileobj
|
gf = gzipfile.fileobj
|
||||||
pos = gf.tell()
|
pos = gf.tell()
|
||||||
@@ -128,13 +138,14 @@ def read_gzip_info(gzipfile):
|
|||||||
fname = []
|
fname = []
|
||||||
while True:
|
while True:
|
||||||
s = gf.read(1)
|
s = gf.read(1)
|
||||||
if not s or s=='\000':
|
if not s or s == '\000':
|
||||||
break
|
break
|
||||||
fname.append(s)
|
fname.append(s)
|
||||||
|
|
||||||
gf.seek(pos)
|
gf.seek(pos)
|
||||||
return ''.join(fname), size
|
return ''.join(fname), size
|
||||||
|
|
||||||
|
|
||||||
def save_obj(obj, name):
|
def save_obj(obj, name):
|
||||||
tp = os.path.dirname(name)
|
tp = os.path.dirname(name)
|
||||||
if not os.path.exists(tp):
|
if not os.path.exists(tp):
|
||||||
@@ -149,6 +160,7 @@ def save_obj(obj, name):
|
|||||||
except:
|
except:
|
||||||
print "Error saving: " + name
|
print "Error saving: " + name
|
||||||
|
|
||||||
|
|
||||||
def load_obj(name):
|
def load_obj(name):
|
||||||
if os.path.isfile(name):
|
if os.path.isfile(name):
|
||||||
try:
|
try:
|
||||||
@@ -160,6 +172,7 @@ def load_obj(name):
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def save_nzb_list():
|
def save_nzb_list():
|
||||||
if nzb_list:
|
if nzb_list:
|
||||||
save_obj(nzb_list, tmp_zipinfo)
|
save_obj(nzb_list, tmp_zipinfo)
|
||||||
@@ -170,6 +183,7 @@ def save_nzb_list():
|
|||||||
except:
|
except:
|
||||||
print "Error deleting " + tmp_zipinfo
|
print "Error deleting " + tmp_zipinfo
|
||||||
|
|
||||||
|
|
||||||
def load_nzb_list():
|
def load_nzb_list():
|
||||||
global nzb_list
|
global nzb_list
|
||||||
nzb_list = load_obj(tmp_zipinfo)
|
nzb_list = load_obj(tmp_zipinfo)
|
||||||
@@ -180,39 +194,49 @@ def load_nzb_list():
|
|||||||
if nzb_list is not None and o_l != len(nzb_list):
|
if nzb_list is not None and o_l != len(nzb_list):
|
||||||
save_nzb_list()
|
save_nzb_list()
|
||||||
|
|
||||||
|
|
||||||
def get_files(zf):
|
def get_files(zf):
|
||||||
zi = zf.infolist()
|
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
|
return zi
|
||||||
|
|
||||||
|
|
||||||
def get_tar_files(tf):
|
def get_tar_files(tf):
|
||||||
ti = tf.getmembers()
|
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
|
return ti
|
||||||
|
|
||||||
|
|
||||||
def get_rar_files(rf):
|
def get_rar_files(rf):
|
||||||
ri = rf.infolist()
|
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
|
return ri
|
||||||
|
|
||||||
|
|
||||||
def remove_filename():
|
def remove_filename():
|
||||||
try:
|
try:
|
||||||
os.unlink(filename)
|
os.unlink(filename)
|
||||||
except:
|
except:
|
||||||
print "Error deleting " + filename
|
print "Error deleting " + filename
|
||||||
|
|
||||||
|
|
||||||
if ext == '.zip':
|
if ext == '.zip':
|
||||||
load_nzb_list()
|
load_nzb_list()
|
||||||
zipf = zipfile.ZipFile(filename, mode='r')
|
zipf = zipfile.ZipFile(filename, mode='r')
|
||||||
zf = get_files(zipf)
|
zf = get_files(zipf)
|
||||||
if zf:
|
if zf:
|
||||||
zipf.extractall(path = dir, members = zf)
|
zipf.extractall(path=dir, members=zf)
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
for z in zf:
|
for z in zf:
|
||||||
if nzb_list:
|
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:
|
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()
|
save_nzb_list()
|
||||||
zipf.close()
|
zipf.close()
|
||||||
|
|
||||||
@@ -223,13 +247,15 @@ elif ext in ['.tar.gz', '.tar', '.tgz']:
|
|||||||
tarf = tarfile.open(filename, mode='r')
|
tarf = tarfile.open(filename, mode='r')
|
||||||
tf = get_tar_files(tarf)
|
tf = get_tar_files(tarf)
|
||||||
if tf:
|
if tf:
|
||||||
tarf.extractall(path = dir, members = tf)
|
tarf.extractall(path=dir, members=tf)
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
for z in tf:
|
for z in tf:
|
||||||
if nzb_list:
|
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:
|
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()
|
save_nzb_list()
|
||||||
tarf.close()
|
tarf.close()
|
||||||
|
|
||||||
@@ -237,7 +263,7 @@ elif ext in ['.tar.gz', '.tar', '.tgz']:
|
|||||||
|
|
||||||
elif ext == '.gz':
|
elif ext == '.gz':
|
||||||
load_nzb_list()
|
load_nzb_list()
|
||||||
gzf =gzip.open(filename, mode='rb')
|
gzf = gzip.open(filename, mode='rb')
|
||||||
out_filename, size = read_gzip_info(gzf)
|
out_filename, size = read_gzip_info(gzf)
|
||||||
if out_filename and os.path.splitext(out_filename)[1].lower() == '.nzb':
|
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:
|
with open(os.path.join(os.path.dirname(filename), out_filename), 'wb') as outf:
|
||||||
@@ -247,9 +273,11 @@ elif ext == '.gz':
|
|||||||
if gzf and out_filename:
|
if gzf and out_filename:
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
if nzb_list:
|
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:
|
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()
|
save_nzb_list()
|
||||||
gzf.close()
|
gzf.close()
|
||||||
|
|
||||||
@@ -260,13 +288,15 @@ elif ext == '.rar':
|
|||||||
rarf = rarfile.RarFile(filename, mode='r')
|
rarf = rarfile.RarFile(filename, mode='r')
|
||||||
rf = get_files(rarf)
|
rf = get_files(rarf)
|
||||||
if rf:
|
if rf:
|
||||||
rarf.extractall(path = dir, members = rf)
|
rarf.extractall(path=dir, members=rf)
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
for r in rf:
|
for r in rf:
|
||||||
if nzb_list:
|
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:
|
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()
|
save_nzb_list()
|
||||||
rarf.close()
|
rarf.close()
|
||||||
|
|
||||||
|
|||||||
@@ -27,12 +27,12 @@
|
|||||||
|
|
||||||
- name: Checking for existing rss folder
|
- name: Checking for existing rss folder
|
||||||
stat:
|
stat:
|
||||||
path: "/opt/appdata/{{pgrole}}/rss"
|
path: '/opt/appdata/{{pgrole}}/rss'
|
||||||
register: rsscheck
|
register: rsscheck
|
||||||
|
|
||||||
- name: Checking for existing rss config
|
- name: Checking for existing rss config
|
||||||
stat:
|
stat:
|
||||||
path: "/opt/appdata/{{pgrole}}/rss/transmission-rss.conf"
|
path: '/opt/appdata/{{pgrole}}/rss/transmission-rss.conf'
|
||||||
register: cfgcheck
|
register: cfgcheck
|
||||||
|
|
||||||
# LABELS ######################################################################
|
# LABELS ######################################################################
|
||||||
@@ -120,13 +120,13 @@
|
|||||||
- name: 'RSS feed configuration - Folder'
|
- name: 'RSS feed configuration - Folder'
|
||||||
block:
|
block:
|
||||||
- name: 'Creating RSS folder'
|
- name: 'Creating RSS folder'
|
||||||
shell: "mkdir /opt/appdata/{{pgrole}}/rss"
|
shell: 'mkdir /opt/appdata/{{pgrole}}/rss'
|
||||||
when: not rsscheck.stat.exists
|
when: not rsscheck.stat.exists
|
||||||
|
|
||||||
- name: 'RSS feed configuration - Config'
|
- name: 'RSS feed configuration - Config'
|
||||||
block:
|
block:
|
||||||
- name: 'Creating configuration file'
|
- 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
|
when: not cfgcheck.stat.exists
|
||||||
|
|
||||||
- name: 'Deploying {{pgrole2}}'
|
- name: 'Deploying {{pgrole2}}'
|
||||||
|
|||||||
@@ -35,22 +35,22 @@
|
|||||||
- name: 'Adding Traefik'
|
- name: 'Adding Traefik'
|
||||||
set_fact:
|
set_fact:
|
||||||
pg_labels:
|
pg_labels:
|
||||||
traefik.enable: 'true'
|
traefik.enable: 'true'
|
||||||
traefik.tags: 'frontend'
|
traefik.tags: 'frontend'
|
||||||
traefik.frontend.passHostHeader: 'true'
|
traefik.frontend.passHostHeader: 'true'
|
||||||
traefik.backend: '{{pgrole}}'
|
traefik.backend: '{{pgrole}}'
|
||||||
traefik.admin.frontend.rule: 'Host:{{pgrole}}.{{domain.stdout}},{{tldset}}'
|
traefik.admin.frontend.rule: 'Host:{{pgrole}}.{{domain.stdout}},{{tldset}}'
|
||||||
traefik.admin.port: '{{intport5}}'
|
traefik.admin.port: '{{intport5}}'
|
||||||
traefik.admin.protocol: 'https'
|
traefik.admin.protocol: 'https'
|
||||||
traefik.frontend.headers.SSLRedirect: 'true'
|
traefik.frontend.headers.SSLRedirect: 'true'
|
||||||
traefik.frontend.headers.STSSeconds: '315360000'
|
traefik.frontend.headers.STSSeconds: '315360000'
|
||||||
traefik.frontend.headers.browserXSSFilter: 'true'
|
traefik.frontend.headers.browserXSSFilter: 'true'
|
||||||
traefik.frontend.headers.contentTypeNosniff: 'true'
|
traefik.frontend.headers.contentTypeNosniff: 'true'
|
||||||
traefik.frontend.headers.forceSTSHeader: 'true'
|
traefik.frontend.headers.forceSTSHeader: 'true'
|
||||||
traefik.frontend.headers.SSLHost: '{{domain.stdout}}'
|
traefik.frontend.headers.SSLHost: '{{domain.stdout}}'
|
||||||
traefik.frontend.headers.STSIncludeSubdomains: 'true'
|
traefik.frontend.headers.STSIncludeSubdomains: 'true'
|
||||||
traefik.frontend.headers.STSPreload: 'true'
|
traefik.frontend.headers.STSPreload: 'true'
|
||||||
traefik.frontend.headers.frameDeny: 'true'
|
traefik.frontend.headers.frameDeny: 'true'
|
||||||
|
|
||||||
- name: 'Setting PG Volumes'
|
- name: 'Setting PG Volumes'
|
||||||
set_fact:
|
set_fact:
|
||||||
|
|||||||
@@ -9,23 +9,23 @@
|
|||||||
- hosts: localhost
|
- hosts: localhost
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
tasks:
|
tasks:
|
||||||
# CORE (MANDATORY) DO NOT CHANGE ###########################################
|
# CORE (MANDATORY) DO NOT CHANGE ###########################################
|
||||||
|
|
||||||
- name: 'Set Known Facts'
|
- name: 'Set Known Facts'
|
||||||
set_fact:
|
set_fact:
|
||||||
pgrole: "zammad"
|
pgrole: 'zammad'
|
||||||
intport: "80"
|
intport: '80'
|
||||||
extport: "8777"
|
extport: '8777'
|
||||||
image: "zammad/zammad"
|
image: 'zammad/zammad'
|
||||||
|
|
||||||
- name: 'Including cron job'
|
- name: 'Including cron job'
|
||||||
include_tasks: '/opt/communityapps/apps/_core.yml'
|
include_tasks: '/opt/communityapps/apps/_core.yml'
|
||||||
|
|
||||||
# EXTRA FUNCTIONS REQUIRED BY THE ROLE #####################################
|
# EXTRA FUNCTIONS REQUIRED BY THE ROLE #####################################
|
||||||
|
|
||||||
##### NOTHING REQUIRED
|
##### NOTHING REQUIRED
|
||||||
|
|
||||||
# LABELS #### KEEPS BOTTOM CLEAN ###########################################
|
# LABELS #### KEEPS BOTTOM CLEAN ###########################################
|
||||||
- name: 'Adding Traefik'
|
- name: 'Adding Traefik'
|
||||||
set_fact:
|
set_fact:
|
||||||
pg_labels:
|
pg_labels:
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user