Created
February 25, 2019 04:24
-
-
Save maikelthedev/96a1461e79c66d678f63c400fd3c108d to your computer and use it in GitHub Desktop.
Like Discovery Weekly from Spotify but better and free of charge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/fish | |
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 Info | cut -d/ -f5 | |
end | |
function getsongurl | |
lynx --dump "https://www.youtube.com/results?search_query=$argv" | grep watch | head -1 | cut -d" " -f4 | |
end | |
# Ok so ignore everything before here | |
function playmore | |
rm -f /tmp/songs/* | |
rm -f -d /tmp/songs | |
mkdir /tmp/songs | |
set first true | |
mpc clear | |
for song in (findrelated $argv) | |
youtube-dl -f 140 (getsongurl $song) -o /tmp/songs/$song.m4a | |
# No need to wait for the others to download to start playing | |
mpc insert file:///tmp/songs/$song.m4a | |
if test $first = true | |
mpc play | |
set first false | |
end | |
end | |
end | |
# Will do this at some point, need to think whether it is necessary to get the | |
# mp4tags or not. Because technically we're deleting the files anyway. | |
# originally this was here due to the spurious characters from Youtube videos | |
# that broke Mopidy | |
# function rename_files | |
# for file in (ls *) | |
# set artist (echo $file | cut -d"-" -f1) | |
# set track (echo $file | cut -d"-" -f2 | sed 's/[()]//g') | |
# mp4tags $file -s $track -a $artist | |
# set num (math $num+1) | |
# mv $file (echo $num).m4a | |
# end | |
# end | |
#if you're not using this file as a function / alias of Fish shell in the folder | |
# .config/fish/functions then uncomment the line below. | |
#playmore $argv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Newflash:
mpc load playlistname
Notice that it is the name of the list, not of the file.
Once loaded you have to play it so
mpc play