move torrent scripts and revise torrentcomplete
This commit is contained in:
1 parent
8d9a32879b
commit
fcb901e64d
6 files changed
+3
-103
No files matched your search
+176
@@ -0,0 +1,176 @@
|
||||
#!/bin/bash
|
||||
IFS=$'\n'; set -f
|
||||
STUFF="/torrent/multimedia/Filme/New/"
|
||||
ASSUMEYES=false
|
||||
FILTER_MODE=false
|
||||
FILE_PATH="/torrent/complete/"
|
||||
usage() {
|
||||
printf "Usage:
|
||||
-y\ty Mode
|
||||
-m\tmega Mode
|
||||
-v\tCopy to ~/Videos
|
||||
-help\tDisplay this\n"
|
||||
}
|
||||
get_config() {
|
||||
while [[ ${1:0:1} == - ]]; do
|
||||
echo "Param: $1"
|
||||
[[ $1 == -help ]] && {
|
||||
echo "Help"
|
||||
usage;
|
||||
exit;
|
||||
};
|
||||
[[ $1 == -f ]] && {
|
||||
echo "Dest: /torrent/Films"
|
||||
STUFF="/torrent/Films/"
|
||||
shift 1
|
||||
continue
|
||||
};
|
||||
[[ $1 == -v ]] && {
|
||||
echo "Dest: Videos"
|
||||
STUFF="/data/Videos/"
|
||||
shift 1
|
||||
continue
|
||||
};
|
||||
[[ $1 == -y ]] && {
|
||||
echo "y Mode"
|
||||
ASSUMEYES=true
|
||||
shift 1
|
||||
continue
|
||||
};
|
||||
[[ $1 == -m ]] && {
|
||||
echo "mega Mode"
|
||||
FILE_PATH="/torrent/mega/"
|
||||
shift 1
|
||||
continue
|
||||
};
|
||||
[[ $1 == -l ]] && {
|
||||
echo "List Mode"
|
||||
LIST_MODE=true
|
||||
shift 1
|
||||
continue
|
||||
};
|
||||
[[ $1 == -f ]] && {
|
||||
echo "Filter Mode"
|
||||
FILTER_MODE=true
|
||||
shift 1
|
||||
continue
|
||||
};
|
||||
echo "Parameter $1 discarded"
|
||||
usage
|
||||
exit
|
||||
done
|
||||
}
|
||||
get_config "$@"
|
||||
|
||||
LIST=($(sudo /home/lucas/scripts/serverhost/deluge_user_cmd.sh ls ${FILE_PATH}))
|
||||
if [ ${#LIST[@]} -eq 0 ]; then
|
||||
echo "Nothing to Copy/Delete"
|
||||
exit
|
||||
fi
|
||||
if [ "${LIST_MODE}" == "true" ]; then
|
||||
for i in "${!LIST[@]}"; do
|
||||
files=${LIST[$i]}
|
||||
echo "Copy? ${files} (y/*)"
|
||||
read -n 10 ans
|
||||
if [ "$ans" != "y" ]; then
|
||||
echo "Dont copy $files"
|
||||
unset 'LIST[i]'
|
||||
fi
|
||||
done
|
||||
echo "NEW LIST:"
|
||||
echo "${LIST[*]}"
|
||||
fi
|
||||
if [ ${#LIST[@]} -eq 0 ]; then
|
||||
echo "Nothing to Copy/Delete"
|
||||
exit
|
||||
fi
|
||||
if [ "${ASSUMEYES}" == "false" ]; then
|
||||
echo "Copy? (y/*)"
|
||||
echo "${LIST[*]}"
|
||||
read -n 10 ans
|
||||
else
|
||||
echo "Copy to Films:"
|
||||
echo "${LIST[*]}"
|
||||
ans="y"
|
||||
fi
|
||||
if [ "$ans" == "y" ]; then
|
||||
for files in ${LIST[@]}; do
|
||||
#sudo /home/lucas/scripts/serverhost/deluge_user_cmd.sh cp -dr ${FILE_PATH}$(printf "%q" "$files") "${STUFF}"
|
||||
sudo /home/lucas/scripts/serverhost/deluge_user_cmd.sh cp -dr --no-preserve=mode ${FILE_PATH}${files} ${STUFF}
|
||||
if [ $? -ne 0 ]; then fail=true; echo "Copy Failure"; exit; fi
|
||||
done
|
||||
printf "Torrents Copied\n"
|
||||
else
|
||||
printf "Nothing Copied\n"
|
||||
fi
|
||||
if [ "${ASSUMEYES}" == "false" ]; then
|
||||
echo "Rename? (y/*)"
|
||||
echo "${LIST[*]}"
|
||||
read -n 10 ans
|
||||
else
|
||||
ans="y"
|
||||
fi
|
||||
printf "Change Ownership\n"
|
||||
sudo /home/lucas/Documents/Dokumente/Projekte/Server/scripts/serverhost/chown_tv.sh
|
||||
|
||||
if [ "$ans" == "y" ]; then
|
||||
for files in ${LIST[@]}; do
|
||||
echo "Rename $files"
|
||||
filepath="${STUFF}${files}"
|
||||
if [ -e "${filepath}" ]; then
|
||||
echo "${filepath} exists"
|
||||
sudo /home/lucas/scripts/serverhost/tvbitch_user_cmd.sh chmod -R 777 "${filepath}"
|
||||
/home/lucas/.venv_general/bin/python3 /home/lucas/scripts/rename_episodes.py -d -rep -p "${filepath}"
|
||||
else
|
||||
echo "${filepath} neither Directory nor regular file"
|
||||
fi
|
||||
done
|
||||
printf "Rename Complete\n"
|
||||
else
|
||||
printf "Nothing Renamed\n"
|
||||
fi
|
||||
|
||||
if [ "${FILTER_MODE}" == "true" ]; then
|
||||
for files in ${LIST[@]}; do
|
||||
echo "Filter $files"
|
||||
filepath="${STUFF}${files}"
|
||||
if [ -e "${filepath}" ]; then
|
||||
echo "Filter Video? (y/*)"
|
||||
echo "${files}"
|
||||
read -n 10 ans
|
||||
if [ "$ans" == "y" ]; then
|
||||
echo "Filter ${files}"
|
||||
sudo /home/lucas/scripts/serverhost/tvbitch_user_cmd.sh chmod -R 777 "${filepath}"
|
||||
if /home/lucas/.venv_general/bin/python3 /home/lucas/scripts/ffmpeg_handling.py filter-audio ${filepath} -o \
|
||||
"${STUFF}_${files}" ; then
|
||||
echo "Filter sucessfull"
|
||||
mv "${STUFF}_${files}" "${STUFF}${files}"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "${filepath} neither Directory nor regular file"
|
||||
fi
|
||||
done
|
||||
printf "Filter Complete\n"
|
||||
fi
|
||||
|
||||
|
||||
if [ "${ASSUMEYES}" == "false" ]; then
|
||||
echo "Delete? (y/*)"
|
||||
echo "${LIST[*]}"
|
||||
read -n 10 ans
|
||||
else
|
||||
ans="y"
|
||||
fi
|
||||
if [ "$ans" == "y" ]; then
|
||||
for files in ${LIST[@]}; do
|
||||
echo "Delete $files"
|
||||
sudo /home/lucas/scripts/serverhost/deluge_user_cmd.sh rm -dr ${FILE_PATH}${files}
|
||||
done
|
||||
printf "Torrents Removed\n"
|
||||
else
|
||||
printf "Nothing Removed\n"
|
||||
fi
|
||||
unset IFS; set +f
|
||||
|
||||
syncNC -m -del
|
||||
Executable
+85
@@ -0,0 +1,85 @@
|
||||
#!/home/lucas/scripts/.venv/bin/python
|
||||
import sys
|
||||
import paho.mqtt.client as mqtt
|
||||
|
||||
import logging
|
||||
|
||||
# Set up logging configuration
|
||||
log_file = '/home/lucas/logfile.log' # Replace with your desired log file location
|
||||
|
||||
logging.basicConfig(
|
||||
filename=log_file, # Log file location
|
||||
level=logging.DEBUG, # Log level: DEBUG, INFO, WARNING, ERROR, CRITICAL
|
||||
format='%(asctime)s - %(levelname)s - %(message)s', # Log format
|
||||
filemode='a' # 'a' to append logs, 'w' to overwrite logs each time
|
||||
)
|
||||
logging.info(f"Start")
|
||||
|
||||
# Define the MQTT broker connection details
|
||||
MQTT_BROKER_HOST = "homeassistant"
|
||||
MQTT_BROKER_PORT = 1883
|
||||
MQTT_USERNAME = "MQTTBrokerUser"
|
||||
MQTT_PASSWORD = "mqtt1510##"
|
||||
MQTT_TOPIC = "serverhost_torrent_sensor/topic" # Set the desired topic
|
||||
|
||||
|
||||
# Define the on_connect callback
|
||||
def on_connect(client, userdata, flags, rc):
|
||||
print(f"Connected with result code {rc}")
|
||||
# Define callback functions
|
||||
def on_connect(client, userdata, flags, rc):
|
||||
"""Callback when the client connects to the broker."""
|
||||
print(f"Connected with result code {rc}")
|
||||
# Subscribe to a topic if needed
|
||||
client.subscribe(MQTT_TOPIC)
|
||||
|
||||
def on_message(client, userdata, msg):
|
||||
"""Callback when a message is received from the broker."""
|
||||
print(f"Received message: {msg.payload.decode()} on topic: {msg.topic}")
|
||||
|
||||
def on_subscribe(client, userdata, mid, granted_qos):
|
||||
"""Callback when a subscription is successful."""
|
||||
print(f"Subscribed to topic with QoS {granted_qos}")
|
||||
|
||||
|
||||
|
||||
try:
|
||||
# Your code that is causing the error
|
||||
# Create an MQTT client instance
|
||||
mqttc = mqtt.Client()
|
||||
|
||||
# Set username and password for authentication
|
||||
mqttc.username_pw_set(username=MQTT_USERNAME, password=MQTT_PASSWORD)
|
||||
|
||||
# Connect to the MQTT broker
|
||||
mqttc.connect(MQTT_BROKER_HOST, MQTT_BROKER_PORT, 60)
|
||||
|
||||
# Attach the callback functions
|
||||
mqttc.on_connect = on_connect
|
||||
mqttc.on_message = on_message
|
||||
mqttc.on_subscribe = on_subscribe
|
||||
|
||||
|
||||
# Start the MQTT client loop in the background
|
||||
mqttc.loop_start()
|
||||
|
||||
# Prepare the message from command-line arguments
|
||||
message = ' '.join(sys.argv[1:]) # Collect all arguments except the script name
|
||||
|
||||
logging.info(f"Message: {message}")
|
||||
if message:
|
||||
# Publish the message to the specified topic
|
||||
mqttc.publish(MQTT_TOPIC, message)
|
||||
print(f"Message sent: {message}")
|
||||
else:
|
||||
print("No message provided. Please provide some arguments to send.")
|
||||
|
||||
# Disconnect from the broker
|
||||
mqttc.disconnect()
|
||||
|
||||
# Stop the MQTT client loop
|
||||
mqttc.loop_stop()
|
||||
|
||||
pass
|
||||
except AttributeError as e:
|
||||
logging.error(f"Error: {e}")
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "$@" >> /home/lucas/.LOG/log_torrentlog.txt
|
||||
|
||||
/home/lucas/scripts/serverhost/torrent_mqtt.py "$*"
|
||||
|
||||
#sudo mail -s 'Torr Completed' lucas-f@live.at <<< "Finished at : $(date)"
|
||||
|
||||
#sudo /home/lucas/scripts/serverhost/lucas_cmd.sh ping -c 1 quiethost >> /dev/null
|
||||
#if [ $? -eq 0 ]; then
|
||||
# sudo /home/lucas/scripts/serverhost/lucas_cmd.sh ssh lucas@quiethost -p 1504 notify-send 'Torrent Complete'
|
||||
#fi
|
||||
Reference in new issue
Block a user