#!/bin/bash
set -e

# RClone Config file
RCLONE_CONFIG=/opt/rclone/rclone.conf; export RCLONE_CONFIG

if [ -n "$1" ]; then
    KEY=$1
else
    KEY=1
fi

# Local Drive - This must be a local mount point on your server that is used for the source of files
# WARNING: If you make this your rclone Google Drive mount, it will create a move loop
# and DELETE YOUR FILES!
# Make sure to set this to the local path you are moving from!!


# Exit if running
if [[ $(pidof -x "$(basename "$0")" -o %PPID) ]]; then
echo "Already running, exiting..."; exit 1; fi


# Rather than use excludes, I wanted to simplify and just have two move commands to move to Movies and TV Shows
# Adjust a few settings to stay within the Dropbox API limits

# Move to Movies Folder
/usr/bin/rclone move ggl"$KEY":movies dbc_movies:movies --log-file /opt/logs/rclone/tdrive2db.log --delete-empty-src-dirs --fast-list --dropbox-chunk-size 128M --tpslimit 12 --tpslimit-burst 12 --transfers 6 --stats-one-line -v


https://accounts.google.com/AccountChooser?continue=https://takeout.google.com/settings/takeout/download?j%3D66b55c29-2ccd-4c98-8946-443c99a45b5b%26i%3D0&Email=denis@breitenstein.be

# Move to TV Folder
#/usr/bin/rclone move $LOCAL/tv dbc_tv:tv --log-file /opt/logs/rclone/db_upload.log --delete-empty-src-dirs --fast-list --dropbox-chunk-size 128M --tpslimit 12 --tpslimit-burst 12 --transfers 6 --stats-one-line -v --min-age 1d
