From b9af444e746a98c40e28d94b66c1542f5f6be376 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Ole=20H=C3=BCbner?= Date: Sun, 13 Apr 2025 18:23:53 +0200 Subject: [PATCH 01/10] feat(install): add uv install --- .zshrc.d/install_dotfiles.zsh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.zshrc.d/install_dotfiles.zsh b/.zshrc.d/install_dotfiles.zsh index ec5a27f..419dd9b 100644 --- a/.zshrc.d/install_dotfiles.zsh +++ b/.zshrc.d/install_dotfiles.zsh @@ -37,6 +37,11 @@ install_dotfiles () { /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" fi + #----uv + command -v uv >/dev/null 2>&1 || curl -LsSf https://astral.sh/uv/install.sh | sh + # + + if [[ "$OSTYPE" == "darwin"* ]]; then /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" From e602d788b06f2964ec9690baa145c5b9760169c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Ole=20H=C3=BCbner?= Date: Sun, 13 Apr 2025 19:02:27 +0200 Subject: [PATCH 02/10] fix(insta): add temporary local fix for insta on nas --- .zsh_functions/insta.zsh | 119 +++++++++++++++++++++------------------ 1 file changed, 63 insertions(+), 56 deletions(-) diff --git a/.zsh_functions/insta.zsh b/.zsh_functions/insta.zsh index 779cf25..fca9843 100644 --- a/.zsh_functions/insta.zsh +++ b/.zsh_functions/insta.zsh @@ -1,68 +1,75 @@ -function insta() { - local cwd=$(pwd) +insta () { + local cwd=$(pwd) + check_smb_mount () { + /sbin/mount | grep -q "$insta_mount_point" + } - check_smb_mount() { - /sbin/mount | grep -q "$insta_mount_point" - } + local stories_only=false + 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 - local user_list=() + echo "-----$(date)------" - # Parse arguments - 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 - echo "-----$(date)------" - if [ ! -d "$insta_mount_point" ]; then - echo "Creating mount point directory..." - mkdir -p "$insta_mount_point" - fi + local is_local_nas=false + if [[ "$NAS_IP" == "127.0.0.1" || "$NAS_IP" == "localhost" ]]; then + is_local_nas=true + fi - if ! check_smb_mount; then - echo "Mounting SMB share..." - /sbin/mount_smbfs "smb://janolehuebner:$(pass sudo-lana)@$insta_share_on_nas" "$insta_mount_point" - fi + if [ ! -d "$insta_mount_point" ]; then + echo "Creating mount point directory..." + mkdir -p "$insta_mount_point" + fi - if ! check_smb_mount; then - echo "Failed to mount SMB share. Exiting." - return 1 - fi + if ! $is_local_nas; then + if ! check_smb_mount; then + echo "Mounting SMB share..." + /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 - user_list=("${insta_default_users[@]}") - fi + if [[ ${#user_list[@]} -eq 0 ]]; then + user_list=("${insta_default_users[@]}") + 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+=(--stories --no-profile-pic --no-posts) - else - cmd+=(--stories --reels) - fi + "${cmd[@]}" - "${cmd[@]}" + if ! $is_local_nas; then + echo "Unmounting SMB share..." + sleep 3 + /sbin/umount -f "$insta_mount_point" + fi - echo "Unmounting SMB share..." - sleep 3 - /sbin/umount -f "$insta_mount_point" - cd "$cwd" + cd "$cwd" } + From 40153d6e10981b7b66024e4be9f464783708521d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Ole=20H=C3=BCbner?= Date: Sun, 13 Apr 2025 19:25:58 +0200 Subject: [PATCH 03/10] fix(youtube): use uvx --- .zsh_functions/youtube.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.zsh_functions/youtube.zsh b/.zsh_functions/youtube.zsh index 007bf5e..78269bd 100644 --- a/.zsh_functions/youtube.zsh +++ b/.zsh_functions/youtube.zsh @@ -67,7 +67,7 @@ yts() { while read -r youtube_id; do # Add each video ID to the array of data (accumulating in $video_data) video_data=$(echo "$video_data" | jq --arg youtube_id "$youtube_id" '. + [{youtube_id: $youtube_id, status: "pending"}]') - done < <(yt-dlp "https://www.youtube.com/@$1/shorts" --flat-playlist --print "%(id)s") + done < <(uvx yt-dlp "https://www.youtube.com/@$1/shorts" --flat-playlist --print "%(id)s") # Check if video_data is still an empty array (meaning no videos were found) if [[ "$video_data" == "[]" ]]; then From 3559b1c113ff7b4fec99e3799b59c8a8ef0bca0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Ole=20H=C3=BCbner?= Date: Sun, 13 Apr 2025 19:36:21 +0200 Subject: [PATCH 04/10] fix(pass): ignore errors from pass --- .zsh_functions/insta.zsh | 2 +- .zsh_functions/youtube.zsh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.zsh_functions/insta.zsh b/.zsh_functions/insta.zsh index fca9843..efb1e9f 100644 --- a/.zsh_functions/insta.zsh +++ b/.zsh_functions/insta.zsh @@ -41,7 +41,7 @@ insta () { if ! $is_local_nas; then if ! check_smb_mount; then echo "Mounting SMB share..." - /sbin/mount_smbfs "smb://janolehuebner:$(pass sudo-lana)@$insta_share_on_nas" "$insta_mount_point" + /sbin/mount_smbfs "smb://janolehuebner:$(pass sudo-lana 2>/dev/null)@$insta_share_on_nas" "$insta_mount_point" fi if ! check_smb_mount; then echo "Failed to mount SMB share. Exiting." diff --git a/.zsh_functions/youtube.zsh b/.zsh_functions/youtube.zsh index 78269bd..771e49a 100644 --- a/.zsh_functions/youtube.zsh +++ b/.zsh_functions/youtube.zsh @@ -29,7 +29,7 @@ ytr () { return 1 fi - local token="$(pass $TUBE_TOKEN_NAME_IN_STORE)" + local token="$(pass $TUBE_TOKEN_NAME_IN_STORE 2>/dev/null)" local json_data=$(jq -n --arg youtube_id "$youtube_id" '{ data: [ { @@ -58,7 +58,7 @@ yts() { fi # Set the token and URL - local token="$(pass $TUBE_TOKEN_NAME_IN_STORE)" + local token="$(pass $TUBE_TOKEN_NAME_IN_STORE 2>/dev/null)" # Initialize an empty array to store video data local video_data="[]" From 1e73c34288b3bd6dd0cdfa0d695374d97ffe9bae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Ole=20H=C3=BCbner?= Date: Sun, 13 Apr 2025 19:55:04 +0200 Subject: [PATCH 05/10] feat(youtube): make check_shorts users configurable --- .environment.d/{youtube.env => youtube.env.skel} | 1 + .zsh_functions/youtube.zsh | 8 +------- 2 files changed, 2 insertions(+), 7 deletions(-) rename .environment.d/{youtube.env => youtube.env.skel} (55%) diff --git a/.environment.d/youtube.env b/.environment.d/youtube.env.skel similarity index 55% rename from .environment.d/youtube.env rename to .environment.d/youtube.env.skel index cf2c388..4deb20e 100644 --- a/.environment.d/youtube.env +++ b/.environment.d/youtube.env.skel @@ -1 +1,2 @@ TUBE_TOKEN_NAME_IN_STORE="tube.lan" +TUBE_DEFAULT_USERS=("a" "b") diff --git a/.zsh_functions/youtube.zsh b/.zsh_functions/youtube.zsh index 771e49a..100bdd1 100644 --- a/.zsh_functions/youtube.zsh +++ b/.zsh_functions/youtube.zsh @@ -90,13 +90,7 @@ yts() { # check_shorts() { - # List of channels to check (you can hardcode them or pass them as arguments) - channels=( - "DarkBlondii" - "littlesiha" - "lenaindica" - ) - + channels=$TUBE_DEFAULT_USERS # Loop through each channel and call yts for channel in "${channels[@]}"; do echo "Checking shorts for channel: $channel" From 5521f3de6c006d7c5e49b2a976e625b1e72b0083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Ole=20H=C3=BCbner?= Date: Sun, 13 Apr 2025 20:07:53 +0200 Subject: [PATCH 06/10] amend(youtube): fix list handling --- .zsh_functions/youtube.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.zsh_functions/youtube.zsh b/.zsh_functions/youtube.zsh index 100bdd1..4651f39 100644 --- a/.zsh_functions/youtube.zsh +++ b/.zsh_functions/youtube.zsh @@ -90,7 +90,7 @@ yts() { # check_shorts() { - channels=$TUBE_DEFAULT_USERS + channels=("${TUBE_DEFAULT_USERS[@]}") # Loop through each channel and call yts for channel in "${channels[@]}"; do echo "Checking shorts for channel: $channel" From 74c37f0a2a72b0cede51e9842fb60e59bdf3b67f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Ole=20H=C3=BCbner?= Date: Mon, 14 Apr 2025 11:38:22 +0200 Subject: [PATCH 07/10] fix(nas): environment loaded in wrong order / use safari again because of a cookie library bug --- .environment.d/{nas.env => 01_nas.env} | 0 .zsh_functions/insta.zsh | 122 ++++++++++++------------- 2 files changed, 61 insertions(+), 61 deletions(-) rename .environment.d/{nas.env => 01_nas.env} (100%) diff --git a/.environment.d/nas.env b/.environment.d/01_nas.env similarity index 100% rename from .environment.d/nas.env rename to .environment.d/01_nas.env diff --git a/.zsh_functions/insta.zsh b/.zsh_functions/insta.zsh index efb1e9f..a0f2503 100644 --- a/.zsh_functions/insta.zsh +++ b/.zsh_functions/insta.zsh @@ -1,75 +1,75 @@ insta () { - local cwd=$(pwd) - check_smb_mount () { - /sbin/mount | grep -q "$insta_mount_point" - } + local cwd=$(pwd) + check_smb_mount () { + /sbin/mount | grep -q "$insta_mount_point" + } - local stories_only=false - 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 + 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 - echo "-----$(date)------" + echo "-----$(date)------" - local is_local_nas=false - if [[ "$NAS_IP" == "127.0.0.1" || "$NAS_IP" == "localhost" ]]; then - is_local_nas=true - fi + local is_local_nas=false + if [[ "$NAS_IP" == "127.0.0.1" || "$NAS_IP" == "localhost" ]]; then + is_local_nas=true + fi - if [ ! -d "$insta_mount_point" ]; then - echo "Creating mount point directory..." - mkdir -p "$insta_mount_point" - fi + if [ ! -d "$insta_mount_point" ]; then + echo "Creating mount point directory..." + mkdir -p "$insta_mount_point" + fi - if ! $is_local_nas; then - if ! check_smb_mount; then - echo "Mounting SMB share..." - /sbin/mount_smbfs "smb://janolehuebner:$(pass sudo-lana 2>/dev/null)@$insta_share_on_nas" "$insta_mount_point" - fi - if ! check_smb_mount; then - echo "Failed to mount SMB share. Exiting." - return 1 - fi - fi + if ! $is_local_nas; then + if ! check_smb_mount; then + echo "Mounting SMB share..." + /sbin/mount_smbfs "smb://janolehuebner:$(pass sudo-lana 2>/dev/null)@$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 - if [[ ${#user_list[@]} -eq 0 ]]; then - user_list=("${insta_default_users[@]}") - fi + if [[ ${#user_list[@]} -eq 0 ]]; then + user_list=("${insta_default_users[@]}") + fi - 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 + local cmd=(uvx --with browser_cookie3 instaloader -b Safari "${user_list[@]}" --fast-update) + if $stories_only; then + cmd+=(--stories --no-profile-pic --no-posts) + else + cmd+=(--stories --reels) + fi - "${cmd[@]}" + "${cmd[@]}" - if ! $is_local_nas; then - echo "Unmounting SMB share..." - sleep 3 - /sbin/umount -f "$insta_mount_point" - fi + if ! $is_local_nas; then + echo "Unmounting SMB share..." + sleep 3 + /sbin/umount -f "$insta_mount_point" + fi - cd "$cwd" + cd "$cwd" } From 6a462556a26a26b55ba5e8f69b06df655f6c62ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Ole=20H=C3=BCbner?= Date: Sat, 19 Apr 2025 01:04:23 +0200 Subject: [PATCH 08/10] feat(homebrew): add Brewfile --- .Brewfile | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .Brewfile diff --git a/.Brewfile b/.Brewfile new file mode 100644 index 0000000..d9f0c5b --- /dev/null +++ b/.Brewfile @@ -0,0 +1,23 @@ +brew "cmake" +brew "exiv2" +brew "ffmpeg" +brew "git-filter-repo" +brew "go" +brew "jpeg" +brew "leveldb" +brew "neovim" +brew "nmap" +brew "node" +brew "pass" +brew "podman" +brew "python@3.12" +brew "restic" +brew "samba" +brew "subfinder" +brew "yarn" +brew "yt-dlp" +brew "zoxide" +cask "amethyst" +cask "amorphousdiskmark" +cask "android-platform-tools" +cask "iterm2" From 55019903a7135367a4cc739d35ba014c477ca9c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Ole=20H=C3=BCbner?= Date: Tue, 13 May 2025 11:35:06 +0200 Subject: [PATCH 09/10] zoxide and abort on error for insta --- .zsh_functions/insta.zsh | 2 +- .zshrc | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.zsh_functions/insta.zsh b/.zsh_functions/insta.zsh index a0f2503..a899cbd 100644 --- a/.zsh_functions/insta.zsh +++ b/.zsh_functions/insta.zsh @@ -55,7 +55,7 @@ insta () { user_list=("${insta_default_users[@]}") fi - local cmd=(uvx --with browser_cookie3 instaloader -b Safari "${user_list[@]}" --fast-update) + local cmd=(uvx --with browser_cookie3 instaloader -b Safari "${user_list[@]}" --fast-update --abort-on=302,400,401,429) if $stories_only; then cmd+=(--stories --no-profile-pic --no-posts) else diff --git a/.zshrc b/.zshrc index b541348..3c4544a 100755 --- a/.zshrc +++ b/.zshrc @@ -31,6 +31,5 @@ autosource nas autosource fuck autosource download -#test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh" - +eval "$(zoxide init --cmd cd zsh)" From 1c5a3ba8e8f6787b532e2a73275c6bc6f52aa83b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Ole=20H=C3=BCbner?= Date: Sat, 24 May 2025 00:59:06 +0200 Subject: [PATCH 10/10] feat(download): update qobuz stuff --- .zsh_functions/download.zsh | 45 ++++++++++++++++++++++++++++--------- .zsh_functions/jellyfin.zsh | 8 +++++++ .zshrc | 1 + 3 files changed, 43 insertions(+), 11 deletions(-) create mode 100644 .zsh_functions/jellyfin.zsh diff --git a/.zsh_functions/download.zsh b/.zsh_functions/download.zsh index 8baa34e..0d289f8 100644 --- a/.zsh_functions/download.zsh +++ b/.zsh_functions/download.zsh @@ -29,8 +29,9 @@ fi mdl () { cwd=$(pwd) -share_on_nas="192.168.84.3/media" +share_on_nas="$NAS_IP/media" path_on_nas="Music/__INBOX" +jelly_wait=150 check_smb_mount() { mount | grep -q "$mount_point" } @@ -66,23 +67,45 @@ fi echo "Unmounting SMB share..." sleep 1 -umount "$mount_point" +/sbin/umount -f "$mount_point" cd $cwd -open "http://bliss.lan/" +if declare -f jelly_rescan > /dev/null; then + echo "Waiting $jelly_wait secs before triggering automatic library scan..." + sleep $jelly_wait + jelly_rescan + echo "done" +fi } - d () { local url="${1:-$(pbpaste)}" - if [[ -z "$url" ]] - then + local used_clipboard=0 + + if [[ -z "$url" ]]; then echo "No URL provided and clipboard is empty." return 1 fi + + # Check if URL came from clipboard + if [[ -z "$1" ]]; then + echo "started via clipboard" + used_clipboard=1 + fi + case "$url" in - (*youtube*|*youtu.be*) echo "Detected YouTube URL: $url" - ytr "$url" ;; - (*qobuz*) echo "Detected Qobuz URL: $url" - mdl "$url" ;; - (*) echo "Unknown URL: $url" ;; + (*youtube*|*youtu.be*) + echo "Detected YouTube URL: $url" + ytr "$url" + ;; + (*qobuz*) + echo "Detected Qobuz URL: $url" + mdl "$url" + if [[ $used_clipboard -eq 1 ]]; then + osascript -e "display dialog \"Done with Qobuz: $url\" buttons {\"OK\"}" + fi + ;; + (*) + echo "Unknown URL: $url" + ;; esac } + diff --git a/.zsh_functions/jellyfin.zsh b/.zsh_functions/jellyfin.zsh new file mode 100644 index 0000000..79b15db --- /dev/null +++ b/.zsh_functions/jellyfin.zsh @@ -0,0 +1,8 @@ +jelly_rescan(){ +JELLYFIN_URL="http://$NAS_IP:8096" +API_KEY="$(pass jelly)" +LIBRARY_ID="8a05b0252259a1dbd62df97522638439" + +curl -X POST -H "X-Emby-Token: $API_KEY" \ + "$JELLYFIN_URL/Library/VirtualFolders/$LIBRARY_ID/Refresh" +} diff --git a/.zshrc b/.zshrc index 3c4544a..eb977ad 100755 --- a/.zshrc +++ b/.zshrc @@ -30,6 +30,7 @@ autosource milan autosource nas autosource fuck autosource download +autosource jellyfin eval "$(zoxide init --cmd cd zsh)"