diff --git a/config/autostart.lua b/config/autostart.lua index 74ed8e6..9794098 100644 --- a/config/autostart.lua +++ b/config/autostart.lua @@ -12,7 +12,7 @@ hl.on("hyprland.start", function () hl.exec_cmd("tmux new-session -d -s ydotool 'ydotoold'") hl.exec_cmd("tmux new-session -d -s ollama '/usr/bin/ollama serve'") hl.exec_cmd("tmux new-session -d -s fah 'cd ~/.local/share/fah && fah-client'") - hl.exec_cmd("tmux new-session -d -s carla 'carla -n /home/honney/Downloads/test.carxp'") + hl.exec_cmd("tmux new-session -d -s carla 'carla -n /home/honney/Music/1Player.carxp'") hl.exec_cmd("bash -c '~/.config/hypr/scripts/goxlr/goxlr-start.sh > ~/.config/hypr/scripts/goxlr/goxlr-start.log'") hl.exec_cmd("bash -c 'sleep 2 && ~/.config/hypr/scripts/wallpapers/random_wallpaper.sh > ~/.config/hypr/scripts/wallpapers/random_wallpaper.log'") @@ -26,6 +26,8 @@ hl.on("hyprland.start", function () hl.exec_cmd("tmux new-session -d -s ollama '/usr/bin/ollama serve'") hl.exec_cmd("nextcloud") hl.exec_cmd("discord") + elseif HOSTNAME == "honney-opencode" then + hl.exec_cmd("tmux new-session -d -s oc 'cd ~/Projects && opencode web --hostname 0.0.0.0 --port 4096'") end hl.exec_cmd("bash -c '~/.config/hypr/scripts/autostart/autostart.sh > ~/.config/hypr/scripts/autostart/autostart.log'") diff --git a/scripts/writing/tmdb-debug.sh b/scripts/writing/tmdb-debug.sh new file mode 100644 index 0000000..e242979 --- /dev/null +++ b/scripts/writing/tmdb-debug.sh @@ -0,0 +1,94 @@ +#!/bin/bash + +set -x + +tmdbid() { + local type q url + type="$1" + shift + + q=$(printf '%s' "$*" | jq -sRr @uri) + echo "tmdbid: type=$type encoded query: $q" >&2 + + if [ "$type" = "tv" ]; then + url="https://www.themoviedb.org/search/tv?query=$q" + else + url="https://www.themoviedb.org/search/movie?query=$q" + fi + echo "tmdbid: url: $url" >&2 + + local result + result=$(curl -sL -A 'Mozilla/5.0' "$url" \ + | grep -oE '/(movie|tv)/[0-9]+' \ + | head -1 \ + | cut -d/ -f3) + echo "tmdbid: result: $result" >&2 + echo "$result" +} + +clean_title() { + local s="$1" + echo "clean_title: input: $s" >&2 + + s=$(echo "$s" | sed -E 's/ *\([^)]*[0-9]{4}[^)]*\)//') + echo "clean_title: after year removal: $s" >&2 + + s="${s//ä/ae}"; s="${s//ö/oe}"; s="${s//ü/ue}" + s="${s//Ä/Ae}"; s="${s//Ö/Oe}"; s="${s//Ü/Ue}" + echo "clean_title: after umlauts: $s" >&2 + + s=$(echo "$s" | tr -d '0-9') + echo "clean_title: after number removal: $s" >&2 + + s=$(echo "$s" | tr -cd '[:alpha:] [:space:]') + echo "clean_title: after special char removal: $s" >&2 + + s=$(echo "$s" | tr -s ' ') + echo "clean_title: final: $s" >&2 + + echo "$s" +} + +ws="${1:-3}" + +title=$(hyprctl clients -j | jq ".[] | select(.workspace.id == $ws)" | grep "The Movie Database" | sed 's/ — The Movie Database.*//' | sed 's/ "title": "//' | sed 's/"$//') +echo "title: $title" >&2 + +search_title=$(echo "$title" | sed -E 's/ *\([^)]*\) *//g') +echo "search_title: $search_title" >&2 + +if echo "$title" | grep -qi "TV [Ss]eries"; then + type="tv" +else + type="movie" +fi +echo "detected type: $type" >&2 + +tmdbid=$(tmdbid "$type" "$search_title") +echo "tmdbid: $tmdbid" >&2 + +if [ -z "$tmdbid" ]; then + if [ "$type" = "tv" ]; then + echo "retrying as movie" >&2 + tmdbid=$(tmdbid "movie" "$search_title") + else + echo "retrying as tv" >&2 + tmdbid=$(tmdbid "tv" "$search_title") + fi + echo "tmdbid (retry): $tmdbid" >&2 +fi + +if [[ $title =~ ([0-9]{4}) ]]; then + year="${BASH_REMATCH[1]}" +else + year="" +fi +echo "year: $year" >&2 + +clean=$(clean_title "$title") +echo "clean: $clean" >&2 + +result="$clean ($year) [tmdb-$tmdbid]" +echo "final wtype input: $result" >&2 + +wtype "$result" diff --git a/scripts/writing/tmdb.sh b/scripts/writing/tmdb.sh index 270c2b2..5db7167 100755 --- a/scripts/writing/tmdb.sh +++ b/scripts/writing/tmdb.sh @@ -1,15 +1,20 @@ #!/bin/bash tmdbid() { - local q url + local type q url + type="$1" + shift - # encode query safely q=$(printf '%s' "$*" | jq -sRr @uri) - url="https://www.themoviedb.org/search/movie?query=$q" + if [ "$type" = "tv" ]; then + url="https://www.themoviedb.org/search/tv?query=$q" + else + url="https://www.themoviedb.org/search/movie?query=$q" + fi curl -sL -A 'Mozilla/5.0' "$url" \ - | grep -oE '/movie/[0-9]+' \ + | grep -oE '/(movie|tv)/[0-9]+' \ | head -1 \ | cut -d/ -f3 } @@ -17,8 +22,8 @@ tmdbid() { clean_title() { local s="$1" - # remove (year) style parentheses - s=$(echo "$s" | sed -E 's/ *\([0-9]{4}\)//') + # remove (year) or (TV Series year) style parentheses + s=$(echo "$s" | sed -E 's/ *\([^)]*[0-9]{4}[^)]*\)//') # umlaut replacement s="${s//ä/ae}"; s="${s//ö/oe}"; s="${s//ü/ue}" @@ -36,16 +41,34 @@ clean_title() { echo "$s" } -title=$(hyprctl clients -j | jq '.[] | select(.workspace.id == 3)' | grep "The Movie Database" | sed 's/ — The Movie Database.*//' | sed 's/ "title": "//g') -tmdbid=$(tmdbid "$title") +ws="${1:-3}" -year="${title: -6}" +title=$(hyprctl clients -j | jq ".[] | select(.workspace.id == $ws)" | grep "The Movie Database" | sed 's/ — The Movie Database.*//' | sed 's/ "title": "//' | sed 's/"$//') -if [ -z "$tmdbid" ]; then - new_title="${title//\ ([0-9][0-9][0-9][0-9])/}" - tmdbid=$(tmdbid "$new_title") +search_title=$(echo "$title" | sed -E 's/ *\([^)]*\) *//g') + +if echo "$title" | grep -qi "TV [Ss]eries"; then + type="tv" +else + type="movie" fi -clean=$(clean_title "$title") +tmdbid=$(tmdbid "$type" "$search_title") -wtype "$clean $year [tmdb-$tmdbid]" +if [ -z "$tmdbid" ]; then + if [ "$type" = "tv" ]; then + tmdbid=$(tmdbid "movie" "$search_title") + else + tmdbid=$(tmdbid "tv" "$search_title") + fi +fi + +if [[ $title =~ ([0-9]{4}) ]]; then + year="${BASH_REMATCH[1]}" +else + year="" +fi + +clean=$(clean_title "$title") + +wtype "$clean ($year) [tmdb-$tmdbid]"