25huizengek1 / ViTune

An Android application for seamless music streaming
https://vitune.app
GNU General Public License v3.0
226 stars 11 forks source link

Pre-cache large songs in chunks #290

Open th3y opened 1 month ago

th3y commented 1 month ago

Would be interested, based on podcast and large video music, that these elements could be pre-cached in chunks, since there's a limit of 10MB of download, using &range=x-y in chunks could help to accelerate the process, instead of waiting an eternity:

So, if the video is more than 10MB, ie: 30 MB, the precache should download it in 3 chunks &range=0-10000000 &range=10000001=20000000 &range=20000001=30000000

Of course there should be limit (Not gonna download 200MB of precache single video) More info at reverse-engineering-youtube-revisited

25huizengek1 commented 1 month ago

What makes this behavior more useful is that the threshold doesn't actually apply to the overall size of the stream, but rather to the size of the requested part. In other words, if you try fetching only a portion of the data — using the Range HTTP header — YouTube will serve the corresponding content at full speed, as long as the specified byte range is smaller than 10 megabytes.

I actually did not know about this. I'll take a look.

25huizengek1 commented 4 weeks ago

There was already some chunking going on, but I added the Range header as specified in the blog, shouldn't harm anyone, right?

Interesting blog post though, maybe it's a good idea to revisit the way ViTune gets data from YouTube because they seem to approach it in a way that cleverly bypasses some restrictions (currently, we rely on Piped for that)

25huizengek1 commented 3 weeks ago

https://github.com/25huizengek1/ViTune/commit/6f1d8d68f3025cf5777d46693f3b9a1322fb348e#commitcomment-142163297