I have spare Raspberry Pi and a project idea in mind but I don't really know where to start with this

I have spare Raspberry Pi and a project idea in mind but I don't really know where to start with this.

So my idea is that the Pi would play music from spotify 24/7 and record the audio output as mp3 file. Then, when the song ends, it would name that file accordingly like "Artist - Song name" or something, even tagging would be cool but not really neccessary.
How could I do this?

Bonus features like showing the current song on 1602 lcd screen would be cool too.

Other urls found in this thread:

manual.audacityteam.org/man/tutorial_recording_audio_playing_on_the_computer.html
wiki.python.org/moin/Audio/
developer.spotify.com/web-api/
github.com/plamere/spotipy
twitter.com/SFWRedditImages

Not very useful because without premium subscription you will only get like 96kbps

paying premium wouldn't really be problem.

Spotify API for queries (Song info + Playback) and ALSA for recording, I guess. Python for wiring things up and you should be good to go.

If you have premium why do you wanna rip the music anyway?

Start from alsa, record some audio using its api. I guess you can also do that with some python library. You will need Spotify premium for querying and add-free stream. I guess It is also possible to do that without premium, but you will have to do a lot of handwork to get things in place

To have it with me and for the "why not"?

Isn't there a way to grab/rip the direct stream data directly instead of "recording"? Or is this what you mean with ALSA?

I dunno, seems easier to just record it.

Tor exit node.

what do you mean?

My bad. Normally these threads are "what can I do with a raspberry pi"
P.S. your spotify ripping is dumb. Unless you are targeting Spofify exclusive music.
If you can't find the music you want elsewhere then it's properly not worth having.
Fuck install limewire. that's still a working network.

There is no "direct" way, you are in theory limited to what Spotify's APIs and TOS limit to. The thing is, you can bypass it by recording your audio driver output (That's called ripping). Just make a playlist, run it and record your audio. This entire process can be scripted

It's not about finding the music I want to listen, it's more about a dump idea of having all the music. (Yes, this is datahoarding)

Alsa is one of Linux audio drivers.. As I said, you could also find already built audio recording libraries for python. Your project is not that complex, really

Spotify audio is encrypted when sent via streaming, it gets decrypted by your client when it is playing, so no, you can't sniff the network and get the audio. The easiest way is playing the audio and recording it (Keep in mind that if you skip songs, or if it cuts the audio for some reason, your recording may get weird)

Ok, is there a quality loss then? Or is this bytewise the original stream?

It is the same as the stream (96kbps). If you have Spotify premium (You'll need it for querying the API), you can change it to a higher quality.

>Or is this bytewise the original stream?
If you record it losslessly, yes.

With a free account, the highest quality you can get is 160kbps Vorbis.

>There is no "direct" way, you are in theory limited to what Spotify's APIs and TOS limit to.
>The thing is, you can bypass it by recording your audio driver output
???
how would directly capturing it be a higher bitrate?
the information never exists regardless of how many samples and how many bits you use to sample the lossy stream

He meant directly recording it, he wasn't talking about bitrate

directly recording from where

the bitstream from spotify.

Winamp used to have a plugin called "streamripper" where you could actually capture the original bytestream in original quality.

why would the bitstream from spotify be higher quality than the 96kbps from wherever
that would waste so much bandwidth

I'm talking about directly recording your audio using some software, like audacity. The difference is that instead of recording your microphone, you record what is currently playing on the ouput of your soundcard.

what are you on about

manual.audacityteam.org/man/tutorial_recording_audio_playing_on_the_computer.html

The idea is playing audio from Spotify and recording it using the method above.

This process can be scripted, and it is also what OP's looking for (So it can be used 24/7 by the RPi).

To script it, you will need to access Spotify APIs (That way you can invoke calls to Spotify's audio player, like Play, Stop, Skip, Get Track info, etc)

Second, you will have to record the audio just like audacity does, but, as there isn't any audacity apis (That I'm aware of), you should use other method to do so. Python has a multitude of libraries to do anything that you could possible imagine, recording audio is one of those things.

Refer to wiki.python.org/moin/Audio/ to get more info.

Third, you write a python script that wires everything up (Query api, record audio, save to disk) and it should be gold.

Then if you want to print the stuff to an LCD, you just have to get the file name that is on disk (Or you could also query the API), and do the hardware related stuff to setup it. Easy stuff

>The idea is playing audio from Spotify and recording it using the method above.
this will be higher quality than what spotify gives you how?

It's à good idea with the raspberry pi, but how could you write the title of each song ?
Years ago, Radio blog record song on radio et can download them ^^

The audio quality that is streamed from Spotify is one thing, the quality that the recording will be stored by audacity/python is other thing. You can have a FLAC quality coming from spotify, and a recording of 32kb. In the end it will be bad.

If you pay spotify premium, you can increase the audio quality and get, lets say, 320kb, that way, you setup audacity/whatever to store at 320kb and it work as intended.

developer.spotify.com/web-api/

There are sample applications on the docs

PS: Keep in mind that all of these stuff is breaking Spotify Terms of Service.. Do it on your own risk!

There is a wrapper to the Spotify's API written in python.

github.com/plamere/spotipy

50% done.