Added stash script, use .env to override vars
This commit is contained in:
parent
5e7cd4527d
commit
007a298f18
|
@ -0,0 +1,27 @@
|
|||
#!/bin/bash
|
||||
|
||||
STASH_IMPORT_DIR=""
|
||||
STASH_API_KEY=""
|
||||
STASH_HOST=""
|
||||
STASH_PORT=0
|
||||
source .env
|
||||
|
||||
TARGET_DIR=$(readlink -m "$STASH_IMPORT_DIR/$(date +%Y%m)")
|
||||
mkdir -p $TARGET_DIR
|
||||
|
||||
regex='^http(s?):\/\/[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b[-a-zA-Z0-9@:%_\+.~#?&\/\/=]*$'
|
||||
|
||||
if [[ $1 =~ $regex ]]; then
|
||||
yt-dlp $1 -o "$TARGET_DIR\%(title)s [%(id)s].%(ext)s"
|
||||
else
|
||||
if [[ $1 == *.txt ]]; then
|
||||
yt-dlp -o "$TARGET_DIR\%(title)s [%(id)s].%(ext)s" -a $1
|
||||
else
|
||||
echo $1
|
||||
echo $TARGET_DIR
|
||||
rsync "$1" "$TARGET_DIR\\"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Update stash
|
||||
curl -X POST -H "ApiKey: $STASH_API_KEY" -H "Content-Type: application/json" --data '{ "query": "mutation { metadataScan (input:{useFileMetadata: false})}" }' $STASH_HOST:$STASH_PORT/graphql
|
Loading…
Reference in New Issue