Skip to content

Instantly share code, notes, and snippets.

@maikelthedev
Last active February 25, 2019 01:05
Show Gist options
  • Save maikelthedev/6ce2fd3aa6a41e9060274894aa102170 to your computer and use it in GitHub Desktop.
Save maikelthedev/6ce2fd3aa6a41e9060274894aa102170 to your computer and use it in GitHub Desktop.
#!/usr/bin/fish
# IF YOU ARE A FISH SHELL USER:
# ----------------------------
# For ease of use, either copy this file inside the ~/.config/fish/functions/ folder.
# IF YOU ARE NOT a FISH SHEL USER:
# ----------------------------
# save it wherever you please
# create a sym link in your favourite folder of $PATH with the name you prefer to call it
# and add at the end of file a new line with just "playsimilar" so the main function is called
function findsong
lynx --dump "https://tunebat.com/Search?q=$argv" | grep " 6. https" | cut -d" " -f5
end
function findrelated
set song (findsong $argv)
lynx --dump $song | grep open.spotify | cut -f3 -d" " | grep spotify | awk '!a[$0]++'
end
function reformatsong
echo $argv | sed 's/https:\/\/open.spotify.com\//spotify:/g' | sed 's/\//:/g'
end
function playsimilar
set songs (findrelated $argv)
mpc stop
mpc clear
for song in $songs
mpc add (reformatsong $song)
end
mpc play
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment