Migrate Qbittorrent to Stacks

This commit is contained in:
Joey Hafner 2024-10-08 11:53:18 -07:00
parent a8a9705b82
commit e22e800e3d
No known key found for this signature in database
4 changed files with 41 additions and 166 deletions

View File

@ -1,108 +0,0 @@
#!/bin/bash
# Discord webhook details
discord_webhook_url="$(cat /discord_notifier_secrets.env)"
# Get variables from qBitTorrent. Remember to make sure these align with your qBittorrent variables passed in settings.
torrent_name="$1"
size="$2"
files="$3"
tracker="$4"
category="$5"
path="$6"
# Function to convert size from bytes to gigabytes (GB)
calculate_size_in_gb() {
size_in_gb=$(bc <<< "scale=2; $size / (1024 * 1024 * 1024)")
echo "$size_in_gb GB"
}
# Function to convert size from bytes to megabytes (MB)
calculate_size_in_mb() {
size_in_mb=$(bc <<< "scale=2; $size / (1024 * 1024)")
echo "$size_in_mb MB"
}
# Function to convert size from bytes to kilobytes (KB)
calculate_size_in_kb() {
size_in_kb=$(bc <<< "scale=2; $size / 1024")
echo "$size_in_kb KB"
}
# Determine download type based on the category.
# This is optional, only if you want to change the notification message based on the category.
# You can also comment out this entire section and simply use $category in the 'title' field of the payload below.
case "$category" in
"emp")
download_type="Empornium"
;;
"ggn")
download_type="GGN"
;;
"mam")
download_type="MAM"
;;
"pub")
download_type="Public Torrent"
;;
*)
download_type="Uncategorised"
;;
esac
# Calculate the size message based on the size in megabytes, kilobytes, or gigabytes
if (( size < 1024 * 1024 )); then
size_message=$(calculate_size_in_kb)
elif (( size < 1024 * 1024 * 1024 )); then
size_message=$(calculate_size_in_mb)
else
size_message=$(calculate_size_in_gb)
fi
# Construct the JSON payload for Discord
# You can change the color of the left hand stripe of the notification using the "color" field.
payload='{
"embeds": [
{
"author": {
"name": "qBittorrent",
"icon_url": "https://i.imgur.com/6LTKLgZ.jpg"
},
"title": "'$download_type' download completed",
"color": 7506394,
"fields": [
{
"name": "Torrent",
"value": "'$torrent_name'"
},
{
"name": "Size",
"value": "'$size_message'",
"inline": true
},
{
"name": "Files",
"value": "'$files'",
"inline": true
},
{
"name": "Tracker",
"value": "'$tracker'"
},
{
"name": "Save Path",
"value": "'$path'"
}
]
}
]
}'
# Function to send a notification to Discord
send_discord_notification() {
curl -H "Content-Type: application/json" -X POST -d "$payload" "$discord_webhook_url" >/dev/null 2>&1
}
# Send a notification to Discord
send_discord_notification
# Print an info message in the console
echo "[$torrent_name] ${download_type} completed. Discord notification sent."

View File

@ -26,45 +26,45 @@ For a given `$category`, run `qbt torrent list --category $category --format csv
Columns included are:
- Hash
- Name
- MagnetUri
- Size
- Progress
- DownloadSpeed
- UploadSpeed
- Priority
- ConnectedSeeds
- TotalSeeds
- ConnectedLeechers
- TotalLeechers
- Ratio
- EstimatedTime
- State
- SequentialDownload
- FirstLastPiecePrioritized
- Category
- SuperSeeding
- ForceStart
- SavePath
- AddedOn
- CompletionOn
- CurrentTracker
- DownloadLimit
- UploadLimit
- Downloaded
- Uploaded
- DownloadedInSession
- UploadedInSession
- IncompletedSize
- CompletedSize
- RatioLimit
- LastSeenComplete
- LastActivityTime
- ActiveTime
- AutomaticTorrentManagement
- TotalSize
- SeedingTime
- Hash
- Name
- MagnetUri
- Size
- Progress
- DownloadSpeed
- UploadSpeed
- Priority
- ConnectedSeeds
- TotalSeeds
- ConnectedLeechers
- TotalLeechers
- Ratio
- EstimatedTime
- State
- SequentialDownload
- FirstLastPiecePrioritized
- Category
- SuperSeeding
- ForceStart
- SavePath
- AddedOn
- CompletionOn
- CurrentTracker
- DownloadLimit
- UploadLimit
- Downloaded
- Uploaded
- DownloadedInSession
- UploadedInSession
- IncompletedSize
- CompletedSize
- RatioLimit
- LastSeenComplete
- LastActivityTime
- ActiveTime
- AutomaticTorrentManagement
- TotalSize
- SeedingTime
- ContentPath
## Remove Torrents by Hash
@ -90,4 +90,4 @@ Steps:
1. Get the URL of the Qbittorrent webUI. `docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' qbittorrent_qbittorrent`. We'll assume the default port of `8080` for the webUI here.
2. Get the username and password for the webUI. These should be in a password manager.
3. Run the script `python3 ~/homelab/fighter/scripts/remove_trumped_torrents.py`. When prompted, input the `host` like `172.18.0.28:8080` with the IP found in step 1. Use the credentials from step 2 for username and password.
4. Done.
4. Done.

View File

@ -12,8 +12,6 @@ services:
volumes:
- $DOCKER_DATA:/config
- $TORRENT_DATA:/torrenting
- ./discord_notifier.sh:/discord_notifier.sh
- ./discord_notifier_secrets.env:/discord_notifier_secrets.env
environment:
PUID: 1001
PGID: 1001
@ -30,21 +28,6 @@ services:
- traefik.http.routers.qbt-api.middlewares=lan-only@file
- traefik.http.services.qbt.loadbalancer.server.port=8080
exporter-qbittorrent:
image: esanchezm/prometheus-qbittorrent-exporter:latest
container_name: qbittorrent_exporter
environment:
QBITTORRENT_HOST: http://qbittorrent
QBITTORRENT_PORT: 8080
restart: "no"
networks:
- monitoring
- web
labels:
- traefik.enable=false
networks:
web:
external: true
monitoring:
external: true
external: true