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