Install
git clone https://github.com/panticz/spotifyripper.git
cd spotifyripper
./spotifyripper.py
Spotify ripper
https://github.com/panticz/spotifyripper
[embed_url: https://raw.githubusercontent.com/panticz/spotifyripper/master/spotifyripper.py]
Record stream
SPOTIFY=$(pacmd list-sink-inputs | while read line; do
[[ -n $(echo $line | grep "index:") ]] && index=$line
[[ -n $(echo $line | grep Spotify) ]] && echo $index && exit
done | cut -d: -f2)
echo ${SPOTIFY}
# muted
pactl load-module module-null-sink 'sink_name=spotify'
pactl move-sink-input ${SPOTIFY} spotify
parec -d spotify.monitor | oggenc -b 320 -o /tmp/spotify.ogg --raw -
parec --verbose --monitor-stream=${SPOTIFY} | oggenc -b 320 -o /tmp/spotify.ogg --raw -
# v2
# unmuted
#parec --verbose --monitor-stream=${SPOTIFY} | oggencode -b 320 -o /tmp/spotify.ogg --raw -
parec --verbose --monitor-stream=${SPOTIFY} --file-format=wav /tmp/recording.wav
#parec --verbose --monitor-stream=${SPOTIFY} | lame -r --quiet -q 3 --lowpass 17 --abr 192 - /tmp/spotify.mp3
parec -d record-n-play.monitor
# cleanup / restart pulseaudio
# systemctl --user restart pulseaudio.service
pulseaudio -k && pulseaudio --start
Links
https://amish.naidu.dev/blog/dbus/
https://ccoffey.ie/?p=53
https://programtalk.com/vs2/python/14193/spotify-music-downloader/spotify_downloader.py/#
https://pypi.org/project/pulsectl/#usage
http://panticz.de/pulseaudio