root@Buffalo:~# cat /mnt/sd/bin/fmstart #!/bin/sh username=$(sed -nr 's/^username=(.*)/\1/p' ~/.bashfm) password=$(sed -nr 's/^password=([^[:space:]]*).*/\1/p' ~/.bashfm) mediaplayer=$(sed -nr 's/^mediaplayer=(.*)/\1/p' ~/.bashfm) if [ ! -z "$password" ]; then passwordmd5=$(echo -n $password | md5sum | sed -nr 's/([^[:space:]]*).*/\1/p') else passwordmd5=$(sed -nr 's/^passwordmd5=([^[:space:]]*).*/\1/p' ~/.bashfm) fi echo 'username='$username > ~/.bashfm echo 'password=' >> ~/.bashfm echo 'mediaplayer='"$mediaplayer" >> ~/.bashfm echo 'passwordmd5='$passwordmd5 >> ~/.bashfm login_url='http://ws.audioscrobbler.com/radio/handshake.php?' login_url="$login_url"'version=1.1.1&platform=linux&username=' login_url="$login_url"$username'&passwordmd5='$passwordmd5 login_url="$login_url"'&debug=0&partner=' echo "login_url=$login_url" >> ~/.bashfm wget -q -O - "$login_url" >> ~/.bashfm echo >> ~/.bashfm
root@Buffalo:~# cat ~/.bashfm username=ichbins password=123456 mediaplayer=/mnt/sd/bin/mpc add
root@Buffalo:~# cat /mnt/sd/bin/mpc #!/bin/sh echo "$*" | nc localhost 6600
root@Buffalo:~# cat /mnt/sd/bin/fmpersonal #!/bin/sh # # "fmpersonal" plays user's personal radio station # session=$(sed -nr 's/^session=(.*)/\1/p' ~/.bashfm) username=$(sed -nr 's/^username=(.*)/\1/p' ~/.bashfm) tuning_url='http://ws.audioscrobbler.com/radio/adjust.php?' tuning_url="${tuning_url}session=${session}&url=lastfm://user/" tuning_url="${tuning_url}${username}/personal" #echo "$tuning_url" wget -q -O - "$tuning_url" echo
root@Buffalo:~# /mnt/sd/bin/fmpersonal response=OK url=http://www.last.fm/listen/user/IchBins/personal stationname=IchBins's Library Radio
root@Buffalo:~# cat /mnt/sd/bin/fmart #!/bin/sh # "fmart" plays the radio station corresponding to a # certain artist. It takes the artist's name as command # line argument. Use quotes when the artist's name # contains spaces. # # Example: # fmart 'jahcoozi' artist=$(echo $1 | sed 's/ /%20/g') session=$(sed -nr 's/^session=(.*)/\1/p' ~/.bashfm) tuning_url='http://ws.audioscrobbler.com/radio/adjust.php?' tuning_url="${tuning_url}session=${session}&url=lastfm://artist/" tuning_url="${tuning_url}${artist}/similarartists&debug=0" #echo "$tuning_url" wget -q -O - "$tuning_url" echo
root@Buffalo:~# /mnt/sd/bin/fmart response=FAILED error=4 root@Buffalo:~# /mnt/sd/bin/fmart "Knorkator" response=OK url=http://www.last.fm/listen/artist/Knorkator/similarartists stationname=Knorkator Radio
root@Buffalo:~# cat /mnt/sd/bin/fmget #!/bin/sh # "fmget" gets list of mp3's from a radiostation and # adds it into the current playlist # # Example: # fmart 'Depeche Mode'; fmget session=$(sed -nr 's/^session=(.*)/\1/p' ~/.bashfm) mplayer=$(sed -nr 's/^mediaplayer=(.*)/\1/p' ~/.bashfm) tuning_url='http://ws.audioscrobbler.com/radio/xspf.php?' tuning_url="${tuning_url}sk=${session}" tuning_url="${tuning_url}&discovery=0&desktop=1.5.1" #echo "$tuning_url" mp3list=$(wget -q -O - "$tuning_url" | sed -nr "s/.*<location>(.*)<\/location>/\1/p") for i in $mp3list; do #echo $i $mplayer "$i" done
root@Buffalo:~# /mnt/sd/bin/fmget OK MPD 0.16.0 OK OK MPD 0.16.0 OK OK MPD 0.16.0 OK OK MPD 0.16.0 OK OK MPD 0.16.0 OK
Source: https://habr.com/ru/post/144116/
All Articles