diff --git a/home.nix b/home.nix index 72c1b3b..037b5dd 100644 --- a/home.nix +++ b/home.nix @@ -59,11 +59,8 @@ in { })) (nixGLWrap (pkgs.google-chrome.override { commandLineArgs = chromeArgs; })) - (pkgs.writeShellScriptBin "ssh-fix-permissions" '' - chmod 700 ~/.ssh - chmod 600 ~/.ssh/* - chmod 644 -f ~/.ssh/*.pub ~/.ssh/authorized_keys ~/.ssh/known_hosts - '') + (pkgs.writeShellScriptBin "ssh-fix-permissions" (builtins.readFile ./scripts/ssh-fix-permissions.sh)) + (pkgs.writeShellScriptBin "yt-dlp-audio" (builtins.readFile ./scripts/yt-dlp-audio.sh)) ]; file = { ".config/nano/nanorc".text = '' diff --git a/programs/zsh.nix b/programs/zsh.nix index d91f076..1e86b7a 100644 --- a/programs/zsh.nix +++ b/programs/zsh.nix @@ -1,10 +1,8 @@ { config, pkgs, lib, ... }: let omz-plugins = [ - "asdf" "git" "archlinux" - "brew" "composer" "colored-man-pages" "extract" diff --git a/scripts/ssh-fix-permissions.sh b/scripts/ssh-fix-permissions.sh new file mode 100644 index 0000000..9280e9b --- /dev/null +++ b/scripts/ssh-fix-permissions.sh @@ -0,0 +1,4 @@ +#!/bin/bash +chmod 700 ~/.ssh +chmod 600 ~/.ssh/* +chmod 644 -f ~/.ssh/*.pub ~/.ssh/authorized_keys ~/.ssh/known_hosts \ No newline at end of file diff --git a/scripts/yt-dlp-audio.sh b/scripts/yt-dlp-audio.sh new file mode 100644 index 0000000..4014f8f --- /dev/null +++ b/scripts/yt-dlp-audio.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +### Script for downloading albums from Youtube Music ########## +### Usage: ./yt-music-album-download.sh ### + +# - Converts to MP3 from the best quality audio feed +# - Adds track number, album, artist, title, and release year into id3 tags +# - Adds album art embedded thumbnails + +echo "Retrieving album information..." +# Downloading the json data of the first track only +jsondata=`yt-dlp -j --playlist-items 1 $1` + +# Grabbing the "release_year" and "release_date" and comparing which is lowest integer. +# Sometimes Youtube Music doesn't even populate the "release_date" field, but when it does we need to compare it to "release_year" +# If both the "release_date" and "release_year" exist, check which one is the lower integer, and that should be the actual album release year. +jq_release_year_1=`echo $jsondata | jq -r '.release_year'` +jq_release_date=`echo $jsondata | jq -r '.release_date'` +if [ $jq_release_date != 'null' ]; then + jq_release_year_2=${jq_release_date::-4}; + year=$((jq_release_year_1)" \ + --parse-metadata ":(?P)" \ + --parse-metadata ":(?P)" \ + --add-metadata \ + --postprocessor-args "-metadata date='${year}' -metadata artist=\"${artist}\"" \ + --embed-thumbnail \ + --ppa "EmbedThumbnail+ffmpeg_o:-c:v mjpeg -vf crop=\"'if(gt(ih,iw),iw,ih)':'if(gt(iw,ih),ih,iw)'\"" \ + -o "%(playlist_index)s. %(title)s.%(ext)s" "$1"