Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] What about downloading and storing tracks locally? #234

Closed
acquitelol opened this issue Jul 9, 2024 · 30 comments
Closed

[Question] What about downloading and storing tracks locally? #234

acquitelol opened this issue Jul 9, 2024 · 30 comments

Comments

@acquitelol
Copy link

You mentioned in the README that implementing features such as playlist downloading is not possible because it's server sided, but I propose the following idea:

  1. Use the lyrics service to get a UUID of the song such that it can be found on YouTube or any service where it can be downloaded without the Widevine DRM to prevent playback
  2. Download the song as an MP3 in the highest bitrate allowed by the service, and organize it into a folder in Spotify's Documents directory with the playlist name, or something in that nature
  3. When the user goes offline and attempts to start playback, first try to find the song in that Documents directory, and if it exists play that instead, otherwise notify the song wasn't or couldn't be downloaded

This, of course, sounds easy on paper, but I believe it should definitely be possible. If it's too much of a hassle I can look into trying to find a robust way to do this myself :3

@acquitelol
Copy link
Author

I didn't read the last part - nevermind lmao.

I'll open a PR eventually with my findings.

@yodaluca23
Copy link
Contributor

Hey @acquitelol love your work on Discord mods btw.

If you could implement actually downloading from Spotify instead like how Zotify works, I think this would be better.

#177 (comment)

@whoeevee
Copy link
Owner

whoeevee commented Jul 9, 2024

It would be nice if you could implement the downloading feature as natively as possible. You can add additional settings, etc., but the playback must be seamless and not occur from a third-party menu. Additionally, songs should be shown as downloaded in playlists.

@acquitelol
Copy link
Author

It would be nice if you could implement the downloading feature as natively as possible. You can add additional settings, etc., but the playback must be seamless and not occur from a third-party menu. Additionally, songs should be shown as downloaded in playlists.

Yeah, of course. When it's done I'm hoping it'll look exactly the same in the front-end as if it was downloaded natively. I'm not quite sure if an external API will be needed or not yet because I may be able to use the fact that songs can be played at will without premium to download a pure mp3 without DRM, but I'll have to look into it further

@acquitelol
Copy link
Author

acquitelol commented Jul 9, 2024

Hey @acquitelol love your work on Discord mods btw.

If you could implement actually downloading from Spotify instead like how Zotify works, I think this would be better.

#177 (comment)

My idea is to swizzle the Download Playlist button, and then it'll create a JSON file in the Documents directory that holds the playlist UUID and then an array containing the UUID of every song in the playlist, then it will save the song file itself in a different directory with the name of the file being the UUID of the song.

At app start, if there is an internet connection and the user has chosen to do so, the code should try to sync every playlist with the json file to ensure it has the updated information, downloading any new songs as needed. Then, at offline playback time, it will just search for the UUID in the folder of mp3 files. If it finds it, then it will play that instead. If it doesn't, then it'll report an EeveeSpotify error or something.

You should be able to select whether you want playlists to be automatically synced or not, and if so, how often to do so (every app start being the most frequent, once every 6 months being the least frequent).

I believe every song also has a "download this song" button when you have premium but I don't remember if it does or not. If it doesn't then I might add it and it would simply save the song in the folder of mp3 files allowing you to play it whenever you're offline without it needing to be in a playlist.

I'm not sure whether it would be a good idea to be able to delete specific downloaded songs or just delete everything all at once, I may add both.

I'm open to suggestions!

@whoeevee whoeevee pinned this issue Jul 10, 2024
@TNT599
Copy link

TNT599 commented Aug 6, 2024

Seems theoretically possible and feasible, only thing I want to mention is Zotify and similar are just python scripts which I don't know how easy that is to run on ios and if they need to be translated into swift or something else to work. Might be easier to use the youtube based online ones especially if there's one with an easy to work with API.

@yodaluca23
Copy link
Contributor

Seems theoretically possible and feasible, only thing I want to mention is Zotify and similar are just python scripts which I don't know how easy that is to run on ios and if they need to be translated into swift or something else to work.

Well yes, the implementation would have to be ported to swift, but the logic should be the same...

Might be easier to use the youtube based online ones especially if there's one with an easy to work with API.

Cobalt tools has a good API, but I think it would be infinitely better to download directly from Spotify, as that will have higher quality, ensure your getting the right song, and have the lyrics match properly (as YouTube downloads probably have intros and stuff), as well as others...

@Richard-NDC
Copy link
Contributor

Richard-NDC commented Aug 19, 2024

Hi there, i just find out some projects that can help you with native download (download from youtube)

@NotDarkn
Copy link

Hi there, i just find out some projects that can help you with native download (download from youtube)

tbf, downloading from YouTube is not the best idea mainly due to the fact that you could be downloading songs that have some weird into at the beginning or an outro at the end (depending on the song).

as @yodaluca23 said, "it would be infinitely better to download directly from Spotify"

@Richard-NDC
Copy link
Contributor

Hi there, i just find out some projects that can help you with native download (download from youtube)

tbf, downloading from YouTube is not the best idea mainly due to the fact that you could be downloading songs that have some weird into at the beginning or an outro at the end (depending on the song).

as @yodaluca23 said, "it would be infinitely better to download directly from Spotify"

but we don’t know how to download it directly from spotify so youtube is the easiest way

@yodaluca23
Copy link
Contributor

Hi there, i just find out some projects that can help you with native download (download from youtube)

tbf, downloading from YouTube is not the best idea mainly due to the fact that you could be downloading songs that have some weird into at the beginning or an outro at the end (depending on the song).

as @yodaluca23 said, "it would be infinitely better to download directly from Spotify"

but we don’t know how to download it directly from spotify so youtube is the easiest way

Go look at Zotify source code...

https://github.com/zotify-dev/zotify

@yodaluca23
Copy link
Contributor

yodaluca23 commented Aug 28, 2024

Go look at Zotify source code...

zotify-dev/zotify

Mainly https://github.com/zotify-dev/zotify/blob/21ef30844b2b2588f9e6db8e6e86423699730f92/zotify/track.py#L145 to the end of that file...

@Richard-NDC
Copy link
Contributor

Go look at Zotify source code...
zotify-dev/zotify

Mainly https://github.com/zotify-dev/zotify/blob/21ef30844b2b2588f9e6db8e6e86423699730f92/zotify/track.py#L145 to the end of that file...

i can read python but i can’t code swift, so can your team do it?

@igor199592

This comment has been minimized.

@An0n-00
Copy link
Contributor

An0n-00 commented Sep 6, 2024

Hey Everyone

it would be infinitely better to download directly from Spotify

I totally agree. What I've noticed in the last weeks, is that Spotify cashes songs locally and waits for internet connection to "release" the song from cash. I think this would be possible to circumvent. One would have to implement a local server and when the server recognizes that the user is offline, it jumps into action and acts as Spotify's backend. [That this works, you would have to listen the song before going offline oc.]
What do y'all think?

@Kassra1

This comment was marked as off-topic.

@yodaluca23

This comment was marked as off-topic.

@Kassra1

This comment was marked as off-topic.

@asdfzxcvbn asdfzxcvbn changed the title [Question] What about storing locally? [Question] What about downloading and storing tracks locally? Oct 7, 2024
@ElliotCHEN37
Copy link
Contributor

ElliotCHEN37 commented Oct 7, 2024 via email

@littleblack111
Copy link

I want to propose an idea. What about since they need to download/cache the player, we just don't remove the cache, and as for downloading, we can just trick the server into thinking we're listening to the music, and never remove the cached music.

I know it's cached Becuz I was on a flight where the WiFi can only access their internal service(movie etc) and Spotify says it's offline but some music that I'm previously listening to still plays

@nyakokitsu
Copy link

Zotify uses Librespot to download tracks, it receives streams and saves them into audio files

@An0n-00
Copy link
Contributor

An0n-00 commented Oct 26, 2024

I want to propose an idea. What about since they need to download/cache the player, we just don't remove the cache, and as for downloading, we can just trick the server into thinking we're listening to the music, and never remove the cached music.

lol that is literally what i said here:

#234 (comment)

but I totally agree. it should be possible somehow...

@littleblack111
Copy link

oh i see, sry for the dupe lol

@TLAflash
Copy link

Use spot-dlp that uses Spotify

@An0n-00
Copy link
Contributor

An0n-00 commented Dec 15, 2024

Use spot-dlp that uses Spotify

can you be more specific? i cannot find anything on spot-dlp...

@nyakokitsu
Copy link

Use spot-dlp that uses Spotify

can you be more specific? i cannot find anything on spot-dlp...
@An0n-00, zspotify(uses librespot-python)

@abcdefghi39664
Copy link

Has there been a pr yet? I could try doing this with the info provided

@asdfzxcvbn
Copy link
Collaborator

Has there been a pr yet? I could try doing this with the info provided

not yet. in fact i haven't seen any fork opened to try implementing this

@An0n-00
Copy link
Contributor

An0n-00 commented Jan 6, 2025

Has there been a pr yet? I could try doing this with the info provided

I would say go ahead and see where it leads too. (dont listen to mee tho 💀 )

@whoeevee ?

@asdfzxcvbn
Copy link
Collaborator

Has there been a pr yet? I could try doing this with the info provided

I would say go ahead and see where it leads too.

ofc, theres no harm in trying, and feedback will be provided in the PR if necessary

p.s. don't ping administrators

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests