- Fix quote handling in transmission-remote commands - Add robust handling for empty torrent IDs - Improve path handling for empty directories - Update version to 9.1 with shared directory handling - Fix empty array subscript errors On branch main Your branch is up to date with 'origin/main'. Changes to be committed: (use "git restore --staged <file>..." to unstage) modified: README.md modified: etc/torrent/mover.conf modified: install.sh new file: usr/local/bin/smart-processor modified: usr/local/bin/torrent-mover new file: usr/local/bin/torrent-processor modified: usr/local/lib/torrent-mover/common.sh modified: usr/local/lib/torrent-mover/transmission_handler.sh
134 lines
2.9 KiB
Plaintext
Executable File
134 lines
2.9 KiB
Plaintext
Executable File
#\!/bin/bash
|
|
|
|
# Source configuration
|
|
source /etc/torrent/mover.conf
|
|
|
|
# Create destination directories
|
|
mkdir -p /mnt/dsnas1/{Books,Movies,TV,Games,Apps,Music,Other}
|
|
|
|
# Function to display help
|
|
show_help() {
|
|
echo "Torrent Processor - Helper for torrent-mover"
|
|
echo ""
|
|
echo "Usage: $0 [OPTIONS]"
|
|
echo ""
|
|
echo "Options:"
|
|
echo " --reset Clear processed log to re-process all torrents"
|
|
echo " --books Process only book torrents"
|
|
echo " --movies Process only movie torrents"
|
|
echo " --tv Process only TV show torrents"
|
|
echo " --apps Process only application torrents"
|
|
echo " --games Process only game torrents"
|
|
echo " --id NUMBER Process a specific torrent ID"
|
|
echo " --help Show this help message"
|
|
echo ""
|
|
echo "Examples:"
|
|
echo " $0 --reset --books Process all book torrents (even if previously processed)"
|
|
echo " $0 --id 123 Process only torrent with ID 123"
|
|
echo ""
|
|
}
|
|
|
|
# Parse command line options
|
|
RESET=0
|
|
CATEGORY=""
|
|
TORRENT_ID=""
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
key="$1"
|
|
case $key in
|
|
--reset)
|
|
RESET=1
|
|
shift
|
|
;;
|
|
--books)
|
|
CATEGORY="books"
|
|
shift
|
|
;;
|
|
--movies)
|
|
CATEGORY="movies"
|
|
shift
|
|
;;
|
|
--tv)
|
|
CATEGORY="tv"
|
|
shift
|
|
;;
|
|
--apps)
|
|
CATEGORY="apps"
|
|
shift
|
|
;;
|
|
--games)
|
|
CATEGORY="games"
|
|
shift
|
|
;;
|
|
--id)
|
|
TORRENT_ID="$2"
|
|
shift
|
|
shift
|
|
;;
|
|
--help)
|
|
show_help
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo "Unknown option: $key"
|
|
show_help
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# Reset processed log if requested
|
|
if [ $RESET -eq 1 ]; then
|
|
echo "Clearing processed log to re-process all torrents"
|
|
> /var/log/torrent_processed.log
|
|
fi
|
|
|
|
# Remove lock file if it exists
|
|
rm -f /var/lock/torrent-mover.lock
|
|
|
|
# Run torrent-mover based on options
|
|
if [ -n "$TORRENT_ID" ]; then
|
|
echo "Processing torrent ID: $TORRENT_ID"
|
|
|
|
# Get torrent details
|
|
info=$(transmission-remote "${TRANSMISSION_IP}:${TRANSMISSION_PORT}" \
|
|
--auth "${TRANSMISSION_USER}:${TRANSMISSION_PASSWORD}" \
|
|
--torrent $TORRENT_ID --info)
|
|
|
|
name=$(echo "$info" | grep "Name:" | awk -F": " '{print $2}' | xargs)
|
|
echo "Torrent name: $name"
|
|
|
|
# Run torrent-mover
|
|
/usr/local/bin/torrent-mover --debug
|
|
elif [ -n "$CATEGORY" ]; then
|
|
echo "Processing category: $CATEGORY"
|
|
|
|
# Set category-specific filter
|
|
case $CATEGORY in
|
|
books)
|
|
echo "Looking for book torrents..."
|
|
;;
|
|
movies)
|
|
echo "Looking for movie torrents..."
|
|
;;
|
|
tv)
|
|
echo "Looking for TV show torrents..."
|
|
;;
|
|
apps)
|
|
echo "Looking for application torrents..."
|
|
;;
|
|
games)
|
|
echo "Looking for game torrents..."
|
|
;;
|
|
esac
|
|
|
|
# Run torrent-mover
|
|
/usr/local/bin/torrent-mover --debug
|
|
else
|
|
echo "Processing all torrents"
|
|
/usr/local/bin/torrent-mover --debug
|
|
fi
|
|
|
|
echo "Processing complete\!"
|
|
echo "Check /var/log/torrent_mover.log for details"
|