Skip to content

Instantly share code, notes, and snippets.

@Dark-Kernel
Created January 19, 2025 12:08
Show Gist options
  • Select an option

  • Save Dark-Kernel/7205b6b3f05f51de74a05706622568d5 to your computer and use it in GitHub Desktop.

Select an option

Save Dark-Kernel/7205b6b3f05f51de74a05706622568d5 to your computer and use it in GitHub Desktop.
Music Scriptss...
#!/bin/bash
url="https://live.musopen.org:8085/streamvbr0"
pkill -f $url || mpv "$url"
#!/bin/bash
for ((i = 40; i <= 65; i++)); do
mpv $(curl -s "https://www.tree.fm/forest/$i" | grep -oi "https://newnow.cool/forest.*.mp3")
done
#!/bin/bash
mus=$(curl -s -H "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36" "https://soundcloud.com/search?q=$1" | grep -Eo '<li><h2>.*' | grep -Eo 'href=".*"' | cut -d = -f2 )
arr=()
while IFS= read -r val; do
arr+=("$val")
done < <(printf '%s\n' "$mus")
if [ "$2" == "l" ]; then
sel=$(echo "$mus" | sed "s/'//g; s/\"//g" | fzf)
mpv "https://soundcloud.com$sel"
elif [ "$2" == "p" ]; then
first=$(echo "https://soundcloud.com$arr" | sed "s/'//g; s/\"//g")
mpv "$first"
fi
#!/bin/zsh
raw=$(curl "https://www.last.fm/search?q=$1" | tee >(pup 'a.chartlist-play-button attr{href}') >(pup 'a.chartlist-play-button attr{data-artist-name}') | pup 'a.chartlist-play-button attr{data-track-name}')
data=()
while IFS= read -r val; do
data+=("'$val'")
done < <(printf '%s\n' $raw)
name=${data[1,9]}
artist=${data[10,18]}
link=${data[19,27]}
eval "names=($name)"
eval "artists=($artist)"
eval "links=($link)"
art=()
for i in {1..9}
do
art+=$(echo -e "'${names[$i]} | ${artists[$i]} | ${links[$i]}'")
done
eval "comb=($art)"
echo "${comb[@]/%/\n}" | sed 's/^ //' | dmenu -l 10 | cut -d '|' -f 3 | xargs -I{} -n 1 mpv --no-video "{}"
#!/bin/bash
search_lastfm() {
local query="$1"
local raw=$(curl -s "https://www.last.fm/search?q=$query")
local artists=$(echo "$raw" | pup 'a.chartlist-play-button attr{data-artist-name}')
local tracks=$(echo "$raw" | pup 'a.chartlist-play-button attr{data-track-name}')
local links=$(echo "$raw" | pup 'a.chartlist-play-button attr{href}')
paste <(echo "$tracks") <(echo "$artists") <(echo "$links") |
while IFS=$'\t' read -r track artist link; do
if [ -n "$track" ] && [ -n "$artist" ] && [ -n "$link" ]; then
echo "lastfm | $track | $artist | $link"
fi
done
}
search_ytmusic() {
local query="$1"
yt-dlp "ytsearch9:$query" -j 2>/dev/null |
jq -r '[.title, .uploader, .webpage_url] | @tsv' |
while IFS=$'\t' read -r title uploader url; do
if [ -n "$title" ] && [ -n "$url" ]; then
echo "ytmusic | $title | $uploader | $url"
fi
done
}
search_ytmusic "$1"
#!/bin/bash
# mpv "https://youtube.com/$(curl -s "https://vid.puffyan.us/search?q=$query" | grep -Eo "watch\?v=.{11}" | dmenu -l 10)"
query=$(printf '%s' "$*" | tr ' ' '+')
video_content="https://youtube.com/$(curl -s "https://vid.puffyan.us/search?q=$query")"
watch_id="$(grep -Eo "watch\?v=.{11}" <<< "$video_content")"
watch_ids=($(grep -Eo "watch\?v=[^ ]+" <<< "$watch_id" | uniq))
title=()
for i in $(seq 1 10); do
title+=("$( pup "div.pure-u-md-1-4:nth-child($i) > div:nth-child(1) > div:nth-child(2) > a:nth-child(1) > p:nth-child(1) text{}" <<< "$video_content")")
done
bar=$(IFS=$'\n' ; echo "${title[*]}" | dmenu -b -l 5 )
foo=$(IFS=$'\n' ; echo "${title[*]}" | grep -n "$bar" | cut -f1 -d: | tr '\n' ' ')
mpv -ytdl-raw-options='format="mp4,best[height<1081]"' -vo=gpu --video-sync=display-resample "https://youtube.com/${watch_ids[$((foo-1))]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment