Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Open-Source Spotify App (github.com/thasianx)
345 points by thasian on Dec 23, 2019 | hide | past | favorite | 110 comments


This is an iOS app, but if it isn’t what you were hoping for, check out these other projects.

A CLI UI for Spotify [0] Spotify as a daemon [1]

[0] https://github.com/Rigellute/spotify-tui

[1] https://github.com/Spotifyd/spotifyd


I haven't been able to get spotifyd to work, but I've been using Mopidy and MopidySpotify for years.


What frontend have you been using for mopidy? I've been looking into it as a potential Clementine replacement since Clementine's Spotify support is dead.

Basically I want a good interface for managing large playlists (so nativeish lists with multi select support for add/remove/reorder, not an album art focused UI), and support for mixing Spotify, local and network shared tracks in a single playlist.


Mopidy Iris is the most polished but it doesn't yet support the latest and greatest Mopidy v3.

https://mopidy.com/ext/


It was ~5 years ago, but I used ncmpcpp and Spotify with great success.


Does anyone know why Spotify doesn’t pursue name rights or DMCA takedowns in all these OSS projects, as they reverse engineer and use Spotify’s name? Snapchat practices DMCA/copyright for a lot for these sort of projects.


"Laws can definitely help, but it doesn't take away the problem. The only way to solve the problem was to create a service that was better than piracy and at the same time compensates the music industry – that gave us Spotify."

- Daniel Ek (Spotify co-founder)


I wish the TV industry can accept way of Spotify is the way to go. Instead, now we have dozens of streaming platforms with exclusive contents.


They can't, because they have a different business model. For TV content producers, consumers paying for content (with either dollars or eyeballs) is their main source of income. But for musicians, most of their money comes from playing live shows. So Spotify can be much more relaxed about revenue than HBO.



It also costs a good deal less for a band to put out an album than it does to make a season of game of thrones.


And an album provides far more recurring revenue than a movie does. I’ve listened to my favorite albums hundreds of times. I’ve watched my favorite television shows twice, three times at most.


What's the "way of Spotify" in your post? One single company toll-gating all content? That doesn't sound like the ideal to me.


Multiple companies having libraries of essentially all content. I can choose between Spotify, Apple Music, whatever Google rebrands their product to every month, etc.


They seem to have a pretty open api so I'm not sure there's actually any reverse engineering going on. They even allow you to build an app that streams audio in sync with the Spotify app. So it doesn't look they are violating anything in terms of functionality. They might be forced to change their name though (just guessing)

https://developer.spotify.com/documentation/

https://developer.spotify.com/documentation/ios/


Those aren’t REST APIs to gather data about songs or your history. They are native APIs to control Spotify app on that machine etc.

I think a fair amount of their business relies on gathering data from people and recommending music. They don’t let 3rd parties to do that.


Perhaps, but they also have APIs for song data and user listening preferences. It's actually pretty impressive how accessible their platform is to developers.

[1] https://developer.spotify.com/discover/#recommendations


I imagine that as long as these don’t give non-paying users access to premium features Spotify don’t mind.

Any Snapchat client, however, can save snaps. So to ensure none of them does, only the official client should be available.


Snapchat and Spotify have very different kinds of business models.




Been using this for a while on a media center RPI3.

https://github.com/dtcooper/raspotify


Thanks for taking the time to share :)


I'm working on a web player ripping off the winamp UI.

https://roadtolarissa.com/winampify


Support for classic skins is what will make this a hit


On archive.org, you can choose webamp as an alternative audio player: https://webamp.org/


Whippin' the llama's ass


There's also Spotiamp. Not sure if it it still works.


IIRC The name got wrongly mixed up with some people hacking the Spotify API to boost their songs' play count and I think the project ultimately died because of that rep

A truly tragic loss IMHO



Nah, ludde wrote spotiamp while working for Spotify. He's same guy that wrote utorrent and tunsafe (unofficial windows wireguard app). I believe it was a one-off project. There was a security vulnerability in the latest version of the app, but spotify fixed server-side and the older versions were not affected. There was an unrelated spotiamp project that I think was a winamp plugin, that's the bad one.

Spotiamp still mostly works but libspotify clients are deprecated, so search is broken and you need to jam spotify url's in to add music.


This is cool. I've been wanting to modify Spotify to use the WhoSampled API to auto-suggest, Amazon Prime X-ray style the songs a given song samples. Maybe i'll do it now.


That’s definitely possible. You can modify seeds with Spotify’s api


This is a fantastic idea! I love listening to music that samples my favorite tunes.


Can you ELI5 I'm interested in knowing more


Amazon Prime Video has an X-Ray feature that shows stuff like which actors are in a scene you are watching. In a lot of music is very common for Artis to use "samples", i.e. you take a small piece of a song and incorporate it into your new song.

Who sampled lists every sample a song used. Take good life by Kanye West for example https://www.whosampled.com/Kanye-West/Good-Life/

So I think what he means is using who sampled data and Spotify music to create a player where you can click x-ray and it shows you the samples from that segment of the song


My first thought, upon seeing this is licensed under the GPLv3, is that it wouldn't be legal to run under iOS, as the Tivoization aspect would come into play. However, as there is but one author, this issue doesn't materialize, although the sole author is the only one who can legally submit this to run under any machine, barring that private app exception I'm rather certain someone would mention if I didn't first.

It's nice that you've chosen the GPL, as I also prefer that license, but what value do you see in this software that only you can modify for use? Do you intend to release an Android or other port, at some point?


Thank you for the comment. I learned a few things about licensing. The main reason I chose GPL was because I don't want someone else building a commercial closed source application based on my app; others can still fork the project and modify it.

I don't intend to release this app on any other platform but others who want to may feel free - I think GPL allows for this. In the end, I don't really care what others do with my app as long as they consult me about what they want to do with it, which MIT is too loose for. If others want to release an app based on mine, they can feel free.


> The main reason I chose GPL was because I don't want someone else building a commercial closed source application based on my app; others can still fork the project and modify it.

GPL is generally the best choice for that.

> In the end, I don't really care what others do with my app as long as they consult me about what they want to do with it

There’s no popular license that I know of that requires people to tell you about their fork. They can just release it and publish the code along with it.


Sure there is: CDDL. It requires one to give the changes back, as opposed to passing them to whoever they distribute to.


For anyone else unfamiliar with that term:

> Tivoization is the creation of a system that incorporates software under the terms of a copyleft software license, but uses hardware restrictions to prevent users from running modified versions of the software on that hardware. [...] Stallman believes this practice denies users some of the freedom that [GPL] was designed to protect.

-- https://en.wikipedia.org/wiki/Tivoization


Apple doesn't allow GPLv3 code if there are multiple contributors? I thought they didn't allow GPLv3 code at all (and that this app required you to compile and install it as as a developer .. never had an eyeProduct so I'm not even sure what the dev process is like).


If there's a single author, they own ultimate copyright to the code and can submit it to the app store under a different license.


Just to clarify for the developer, thasian, because you have all rights in the code you can license it differently to different users. The version on github will be gpl; you presumably could have different license for app store purchasers. I think the ios port of Vim is done this way, it's github link is https://github.com/terrychou/iVim . Not sure if that's actually the way terrychou did it, but surely you could ask him about it.


In that case, what license should I change to? As long as others who want to release an app based on my source code consults me about it, I will let them.


I see nothing wrong with GPLv3 here; what exactly is the problem? Tivoization doesn’t make sense because people can just recompile the app themselves and install it.


It would be nice if their API provided endpoints for Spotify for Artists. There is a lot of opportunity there to make apps that support musicians and labels.


I think I get what you're saying: endpoints that artists can use that would be beneficial towards their brand.


To clarify for OP, "Spotify for Artists" is the Spotify app that artists use for analytics and the like.


Is this an actual Spotify app that streams music or can you just control music playing on other devices/apps (like the cli UI's)?


None of the above. My app pulls in music using Spotify’s api. To stream music, it redirects you to the Spotify app.


What does “pull in” mean here?


Retrieves music from Spotify's database based on a set of parameters.


As in, actual audio? Or metadata?


Pulls in metadata. I use the metadata's external url to open the track in spotify.


It would’ve been better if you had answered the question clearly at the first instance. This thread seemed like playing 20 questions.


“To stream music, it redirects you to the Spotify app.”

Seemed pretty obvious to me.


He said it “pulls in music”. That’s seems obvious too.


Yeah. That and "retrieves music" both sound like it's actually pulling encoded audio files down


Tangentially related - I wrote a C library for spotify's web api: https://gitlab.com/finnoleary/spotifyc

I've been working on the cli client and shuffling things about directory wise so I don't think it compiles anymore atm. But the library works fine. Actually in retrospect I think I might revert and splt them into separate repos...


This is super interesting. I worked with Spotify’s original C SDK on iOS about 6 years ago. We ran into some issues with it aggressively loading playlists and metadata and running out of memory on large accounts. Some years later they put out a new iOS SDK that fixed all of the issues and was generally more of a native-feeling SDK on iOS, long after the project had been scrapped.

Is this at all related or inspired by their original C SDK?


Must've been a lot of work. I considered writing a library for the Web API in Swift, but there's just too much maintenance. There were also some weird bugs I encountered when parsing JSON like the time stamps being in the wrong format.


Yeah. I just leave the json parsing up to the caller partly as a simplification, but also because I might accidentally discard data they want (Like, ideally that should never happen but our world is not ideal). The only thing it wraps is the authentication (to make life easier), and the web request. The C code is generated from a small python script that's generated directly from the documentation so it's relatively easy to keep up-to-date, the sacrifice is it is a bit more fragile than I like.


I have a question for those familiar with Spotify API. Do they serve you the song's audio bits and if they do how do they do DRM?


libspotify used to do that but they deprecated that(iirc it still works), today the only supported playback option they have is a js player which requires decrypting DRM content in browser.


I used their C API a long time ago. Back then, you registered a bunch of callback functions. One of those was to get raw uncompressed audio. IIRC, they used Vorbis internally, but once it reached your callback function, it was just decoded raw PCM data.

I, uh, wrote my own little "player" with this: https://youtu.be/8ejnGARQIJ0


Hi! I haven't used the Spotify API, so this is just a guess. The demo app has a "Sign in with Spotify" component of their authentication so my guess is that you make an API request to Spotify for a specfic song and Spotify sends back to you a cryptographically signed URL that expires after a reasonable amount of time that lets you access the entire song in MP3 form and contingent on using their API you only use it transiently to play to this specific user.


I don’t think this is how it works. I haven’t played with the API but I’ve dug around a bit in the source for the Spotify client.

More likely, it’s by sending a stream of data or otherwise its sending encrypted chunks for which Spotify has a decoder integrated. That’s how the desktop client works at least.

Your prediction seems unlikely to me for the reason that any transmission of unencrypted data like that exposes Spotify to having their whole library scraped.

Not that it’s technically impossible already, but I would say incredibly infeasible.


The old API (libspotify) did decrypt raw audio data and hand it to the player. This is likely why it was killed (that and an inability to tie usage to apps, only to users).

The currently supported SDKs are for web, iOS and Android which perform the decryption via EME or platform specific DRM support. They also require app specific oauth authentication.

However, libspotify's playback endpoints still work, likely due to them still supporting older hardware devices (other endpoints, most notably search are now broken). This is ultimately what most open source native clients use, either using archived builds of libspotify (for e.g. Clementine or mopidy) or reimplentations of it (librespot, Spotifyd).

Because the new API is so locked down it's likely that open source apps won't ever migrate to it (without the raw audio data they can't integrate it with most of their features), and will have to drop support when the last endpoints supporting libspotify style playback are pulled.


Mopidy does indeed still use libspotify through our pyspotify Python 3 bindings. Search and everything relating to playlists is broken in libspotify[0] so we use the Web API for this functionality in Mopidy 3 (just released). Spotify's newer browser-only streaming library is useless to us.

I believe that librespot (at least one of the implementations) now supports audio from Spotify's new HTTP endpoints, rather than via the 'Mercury' protobuf stuff that libspotify uses. The point being that it might still have a future after Spotify finally kills the remaining parts of libspotify.

Disclaimer: I'm a Mopidy developer.

[0] https://jodal.no/2016/02/18/guide-to-poor-api-management/

Edit: oh, and you do need an API key to use libspotify, which Spotify no longer provide. So that kills off any new users from adopting libspotify/pyspotify, even if they could live with the short-commings.


Spotify's own web player does make the EME/CDM icon thingy appear in Firefox in the URL bar.


Interesting..

> 'and provides users with important metrics like their top tracks, top artists, and recently played tracks, queryable by time range'

Is your feature selling point the time range ? I'm confused.. Looks like spotify has this already...

EDIT: I get it now: Change the title to : Manage your own Spotify

Any extra functionality ?


Never really considered that but I guess the selling point would be the fact that users get notified when their favorite artists release new songs. My app is one of many that does song pulling but it uses the Spotify api, one means to an end. The community can add extra features: all I’ve created is something that’s possible with the Spotify api that others can branch off of


Don't think about selling it.

If you enjoy it, keep it up and just use it as a nice playground to show off.

> all I’ve created is something that’s possible with the Spotify api

Yup.. In a great way. Don't put yourself down. This is cool


I'm pretty sure he only meant selling point as a "why should I care about your repo" or "what purpose is this program trying to fulfill" statement: not actually suggesting to selling as a product


Right. Once again, never really thought of that. It could be a useful tool for others to learn off of: the app employs a MVVM and Coordinator architecture with reactive bindings. It's also a good example of using the Spotify Web API for Swift since there aren't many examples out there.


' It's also a good example of using the Spotify Web API for Swift since there aren't many examples out there'

There is never any harm to educate others; I'm not so strong on Swift at all, but I really appreciate the area that I dig into too. This project, is well worthy of a follow.


OT: does anyone know why an existing playlist would suddenly become something comepletwly different?

I used to listen to a Carnatic Classical playlist (Here’s a playlist for you… Carnatic Classical by Spotify https://open.spotify.com/playlist/37i9dQZF1DWZqTcNLmb3sH?si=...) and now it’s just changed to something completely different. Honestly this made me want to leave!


I don't think playlists are market specific so I'd guess that was either just human error or some automated script on Spotify's part going wrong. Google cache confirms that the same playlist ID was used for the one you are looking for.


Spotify curated playlists are often dynamic - they will often get updated or completely redone every once in a while. I guess that can be a feature but it is not how I listen to music.

If I find a playlist I like, either from spotify or somewhere else, I make sure to make a local copy of that playlist in my account to make sure it doesn't change. Because when you add such a playlist you don't copy it, you subscribe to it.

(Ctrl+a to select all songs, ctrl+c, make new playlist, ctrl+v. Might be an even easier and more direct way but I don't have spptify in front of me).


Someone should rebuild turntable.fm using Spotify


Yeah I did this in my own way - it’s not an exact clone but it’s heavily inspired by ttfm. I built https://www.jqbx.fm check it out - would love your feedback :)


It’s awesome. Definitely going to be using this a lot once the break is over. Thank you!


I think somebody did. Go on Twitter and put turntable.fm in your tweet. They'll come calling. I otherwise don't remember their name.


I think jqbx.fm is what you’re looking for. Only works with Spotify Premium from what I’m aware though.


It seems like they've used RXswift for making this app. Honestly, Reactive Programming still looks like magic for me, is it worth it to abandon the old-school MVC and start learning that concept? Why should I start my new projects with RX?


Is this all you ? Or you have some friends with you ?

It's really nice for 1 person.


Only me


I guess, it's a lot of time, but do you use it? Is that why you made it ?

I'd love to send 100 questions on.


That was one of my intentions. I also started this project to learn more about reactive programming and exploring the technical sides of creating views in Swift.


Swift I'm not familiar with Swift personally, but given what you've laid out; it's language agnostic.

You've committed a lot time to it.. A lot of us have ideas of somthing simular, but we get busy... This is the time to cut and run.

Are you currently employeyed ? (no need to give who).

How much time did you commit to this, kinda cool piece that is expected a lot of time!

As I said before, I have 100 questions!

Full disclosure: I'm a cpp heart with a current role in cs


I think this conversation would best be continued by email, which is in my bio.

To answer your questions, I will be interning at a company starting January. I worked on this project for less than a month. Since I'm a 1st year in college, I also have my studies but I try to code at least 2 hours a day.


Not sure how to send a PM here, but, if this is all you, you should spend your time changing/making shit, I just was in another topic about startups and entrepreneurs. over here : https://news.ycombinator.com/item?id=21865065

You kinda fit the bill of : yeah I do it because I can.

Much love


Good eye! I’m really into entrepreneurship: starting a podcast next year and going to do validation on an idea I have before I start building an mvp.


Hey man. This is awesome stuff. I'm actually an entrepreneur as well building a social music app. Email me if you're interested, I can tell you more about it.

A lot of the initial work will be using the Spotify API and others to aggregate musician data.

I've registered the LLC and my cofounder and I have been brainstorming the software, but haven't really started anything yet.

Have been too busy with the holidays and vacation.

Edit: email is in my about


It's super late over here, but I would love to hear more from you. If there's anyway here let me know.


I'm impressed. Well done.


Tangentially related, does the Linux spotify app provides any additional features to the web-based client?


Why isn’t Spotified concerned about people making apps that rip their content?

Is audio piracy not a thing anymore?


Spotify are not enabling audio piracy by much because they don't provide an audio stream for songs via their API (beyond a short sample).


@dang Maybe add Show HN: prefix?


Fastest and most reliable way to contact them is via the Contact link in the footer.


Damn you right. First post on HN. I can't do anything. Maybe mods can.


Interesting, I didn't know Spotify had an API to play music on iOS…


Every spotify app can act as a remote control if spotify already plays on another device. E.g. if spotify plays music on a PC, then you select another song in the smartphone app, it will actually change the playback on the PC. I guess the api allows to tap into that.


They do, but it’s not as nice as it used to be (I’m not sure it was ever nice but it’s gotten worse)


You would have to use the iOS api if u want to do any remote playing.


looks like you're using the web api instead of the IOS sdk? any reason for that? is the ios sdk not in swift yet ? It was a pain to setup the last time i looked at it.


The documentation for the iOS Sdk is terrible. It's also in Obj-c. The Web API is pretty clear and we all love JSON. The only thing I could see myself using the iOS Sdk for is remote playing.


Could you ELI5 I'm interested in trying this out.

Thanks




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: