Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat) xseed.sh: add LOGID_FILE to track downloaded ids #24

Merged
merged 3 commits into from
Aug 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions xseed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# Load environment variables from .env file if it exists
# in the same directory as this bash script
VERSION='2.1.1'
VERSION='2.2.1'
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ENV_PATH="$SCRIPT_DIR/.env"

Expand Down Expand Up @@ -48,6 +48,7 @@ USENET_CLIENT_NAME=${USENET_CLIENT_NAME:-SABnzbd}
XSEED_HOST=${XSEED_HOST:-crossseed}
XSEED_PORT=${XSEED_PORT:-8080}
LOG_FILE=${LOG_FILE:-/config/xseed.log}
LOGID_FILE=${LOG_FILE:-/config/xseed-id.log}
XSEED_APIKEY=${XSEED_APIKEY:-}
log_message "DEBUG" "Using '.env' file for config?: $EVAR"
log_message "INFO" "Using Configuration:"
Expand All @@ -56,6 +57,7 @@ log_message "INFO" "USENET_CLIENT_NAME=$USENET_CLIENT_NAME"
log_message "INFO" "XSEED_HOST=$XSEED_HOST"
log_message "INFO" "XSEED_PORT=$XSEED_PORT"
log_message "INFO" "LOG_FILE=$LOG_FILE"
log_message "INFO" "LOGID_FILE=$LOGID_FILE"

# Function to send a request to Cross Seed API
cross_seed_request() {
Expand Down Expand Up @@ -123,15 +125,16 @@ detect_application() {
# Validate the process
validate_process() {
[ ! -f "$LOG_FILE" ] && touch "$LOG_FILE"
[ ! -f "$LOGID_FILE" ] && touch "$LOGID_FILE"
unique_id="${downloadID}-${clientID}"

if [ -z "$unique_id" ]; then
log_message "ERROR" "Unique ID is missing. Exiting."
exit 1
fi

if grep -qF "$unique_id" "$LOG_FILE"; then
log_message "INFO" "Download ID $unique_id already processed. Exiting."
if grep -qF "$unique_id" "$LOGID_FILE"; then
log_message "INFO" "Download ID [$unique_id] already processed and logged in [$LOGID_FILE]. Exiting."
exit 0
fi

Expand Down Expand Up @@ -199,7 +202,7 @@ handle_operations() {

log_message "INFO" "Cross-seed API response: $xseed_resp"
if [ "$xseed_resp" == "204" ]; then
echo "$unique_id" >>"$LOG_FILE"
echo "$unique_id" >>"$LOGID_FILE"
log_message "INFO" "Process completed successfully."
else
if [ "$xseed_resp" == "000" ]; then
Expand Down