fix(insta): add temporary local fix for insta on nas
This commit is contained in:
parent
b9af444e74
commit
e602d788b0
1 changed files with 63 additions and 56 deletions
|
@ -1,68 +1,75 @@
|
||||||
function insta() {
|
insta () {
|
||||||
local cwd=$(pwd)
|
local cwd=$(pwd)
|
||||||
|
check_smb_mount () {
|
||||||
|
/sbin/mount | grep -q "$insta_mount_point"
|
||||||
|
}
|
||||||
|
|
||||||
check_smb_mount() {
|
local stories_only=false
|
||||||
/sbin/mount | grep -q "$insta_mount_point"
|
local user_list=()
|
||||||
}
|
while [[ $# -gt 0 ]]
|
||||||
|
do
|
||||||
|
case "$1" in
|
||||||
|
--cron)
|
||||||
|
local random_wait=$((RANDOM % 1800))
|
||||||
|
echo "--------------------------------------------"
|
||||||
|
echo "Waiting for $((random_wait / 60)) minutes..."
|
||||||
|
sleep $random_wait
|
||||||
|
stories_only=true
|
||||||
|
;;
|
||||||
|
--stories)
|
||||||
|
stories_only=true
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
user_list+=("$1")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
local stories_only=false
|
echo "-----$(date)------"
|
||||||
local user_list=()
|
|
||||||
|
|
||||||
# Parse arguments
|
local is_local_nas=false
|
||||||
while [[ $# -gt 0 ]]; do
|
if [[ "$NAS_IP" == "127.0.0.1" || "$NAS_IP" == "localhost" ]]; then
|
||||||
case "$1" in
|
is_local_nas=true
|
||||||
--cron)
|
fi
|
||||||
local random_wait=$((RANDOM % 1800))
|
|
||||||
echo "--------------------------------------------"
|
|
||||||
echo "Waiting for $((random_wait / 60)) minutes..."
|
|
||||||
sleep $random_wait
|
|
||||||
stories_only=true
|
|
||||||
;;
|
|
||||||
--stories)
|
|
||||||
stories_only=true
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
user_list+=("$1")
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
echo "-----$(date)------"
|
|
||||||
if [ ! -d "$insta_mount_point" ]; then
|
|
||||||
echo "Creating mount point directory..."
|
|
||||||
mkdir -p "$insta_mount_point"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! check_smb_mount; then
|
if [ ! -d "$insta_mount_point" ]; then
|
||||||
echo "Mounting SMB share..."
|
echo "Creating mount point directory..."
|
||||||
/sbin/mount_smbfs "smb://janolehuebner:$(pass sudo-lana)@$insta_share_on_nas" "$insta_mount_point"
|
mkdir -p "$insta_mount_point"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! check_smb_mount; then
|
if ! $is_local_nas; then
|
||||||
echo "Failed to mount SMB share. Exiting."
|
if ! check_smb_mount; then
|
||||||
return 1
|
echo "Mounting SMB share..."
|
||||||
fi
|
/sbin/mount_smbfs "smb://janolehuebner:$(pass sudo-lana)@$insta_share_on_nas" "$insta_mount_point"
|
||||||
|
fi
|
||||||
|
if ! check_smb_mount; then
|
||||||
|
echo "Failed to mount SMB share. Exiting."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
cd "$insta_mount_point/$insta_path_on_nas" || return 1
|
cd "$insta_mount_point/$insta_path_on_nas" || return 1
|
||||||
|
|
||||||
# Use default users if no user was specified
|
if [[ ${#user_list[@]} -eq 0 ]]; then
|
||||||
if [[ ${#user_list[@]} -eq 0 ]]; then
|
user_list=("${insta_default_users[@]}")
|
||||||
user_list=("${insta_default_users[@]}")
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# Build the instaloader command
|
local cmd=(uvx --with browser_cookie3 instaloader -b Safari -B "$insta_cookiefile" "${user_list[@]}" --fast-update)
|
||||||
local cmd=(uvx --with browser_cookie3 instaloader -b Safari -B "$insta_cookiefile" "${user_list[@]}" --fast-update)
|
if $stories_only; then
|
||||||
|
cmd+=(--stories --no-profile-pic --no-posts)
|
||||||
|
else
|
||||||
|
cmd+=(--stories --reels)
|
||||||
|
fi
|
||||||
|
|
||||||
if $stories_only; then
|
"${cmd[@]}"
|
||||||
cmd+=(--stories --no-profile-pic --no-posts)
|
|
||||||
else
|
|
||||||
cmd+=(--stories --reels)
|
|
||||||
fi
|
|
||||||
|
|
||||||
"${cmd[@]}"
|
if ! $is_local_nas; then
|
||||||
|
echo "Unmounting SMB share..."
|
||||||
|
sleep 3
|
||||||
|
/sbin/umount -f "$insta_mount_point"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Unmounting SMB share..."
|
cd "$cwd"
|
||||||
sleep 3
|
|
||||||
/sbin/umount -f "$insta_mount_point"
|
|
||||||
cd "$cwd"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue