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

Download speed is slow #13

Closed
shom13 opened this issue Apr 10, 2022 · 22 comments
Closed

Download speed is slow #13

shom13 opened this issue Apr 10, 2022 · 22 comments
Labels
enhancement New feature or request

Comments

@shom13
Copy link

shom13 commented Apr 10, 2022

Firstly, thank you for the app. This is exactly what i was looking for from a long time.

When i download a song, where is it getting saved, or is it getting saved anywhere at all, as i am not able to locate the file on my phone. Also download takes a while, which surprises me as newpipe extractor should not be taking that long.

@z-huang
Copy link
Owner

z-huang commented Apr 10, 2022

The song is saved in the app-specific external files directory. You'll see them in (/Android/data/com.zionhuang.music/files/media), and the filename is the hash of the song id. How users can receive the files are in the roadmap. Possibly providing a share option in the three-dots song menu and implementing a DocumentProvider. Some ideas are mentioned in #3.

The app uses Android DownloadManager to download files. I also experienced a slow download speed. It shouldn't be that slow, but there seems to be no method to tweak that. I'll implement a custom downloader instead. It should be faster.

@z-huang z-huang added question Further information is requested enhancement New feature or request labels Apr 10, 2022
@z-huang z-huang changed the title Location of downloaded audio Download speed is slow May 11, 2022
@z-huang z-huang mentioned this issue Jul 3, 2022
4 tasks
@z-huang z-huang removed the question Further information is requested label Jul 15, 2022
@ArjixWasTaken
Copy link

I might make a PR for this soon

Oh yeah, thank you for this app, it is exactly what I wanted, I had been planning to make an app like this but I then discovered your app.

Much thanks!

@z-huang
Copy link
Owner

z-huang commented Aug 16, 2022

Have you try the debug APK in feature/innertube branch? Things has changed a lot.

@ArjixWasTaken
Copy link

I haven't taken a look at the code/branches yet, so no

From your reply I guess the downloads are faster now? Great

@z-huang
Copy link
Owner

z-huang commented Aug 16, 2022

From your reply I guess the downloads are faster now?

No, I haven't fixed.

@lovelilke
Copy link

From your reply I guess the downloads are faster now?

No, I haven't fixed.

How about this library https://github.com/lingochamp/FileDownloader

@ArjixWasTaken
Copy link

Or https://github.com/LagradOst/Aria2cButton

A friend made it so I couldn't hold back and not share it.

It uses aria2 to do the downloads.
And you may already know, but aria2 is super fast.

@z-huang
Copy link
Owner

z-huang commented Oct 26, 2022

I haven't spent time on this, so I can't say too much. Maybe eventually I need to write my own library for it, which will take massive time. However, I don't prefer aria2 because it is a command line tool and needs a wrapper to make it a java library.

@ArjixWasTaken
Copy link

I haven't spent time on this, so I can't say too much. Maybe eventually I need to write my own library for it, which will take massive time. However, I don't prefer aria2 because it is a command line tool and needs a wrapper to make it a java library.

Yes, I sent a library that wraps the json rpc aria has.

@z-huang
Copy link
Owner

z-huang commented Oct 26, 2022

I mean the interface may not be rich. Say, it doesn't support proxy.

@ArjixWasTaken
Copy link

aria2's json rpc has everything accessible via the CLI and much more

Extending the wrapper to support proxies won't be that hard.

@z-huang
Copy link
Owner

z-huang commented Oct 27, 2022

I don't think so. In short, it lacks flexibility.

@ArjixWasTaken
Copy link

What?

How does it lack flexibility?
And if you can't be arsed to read the code in order to add proxy support, here are the two places you need to modify so you can use proxies with aria2: AbstractClient.kt#L366-L395 and
Aria2Classes.kt#L36-L106

@z-huang
Copy link
Owner

z-huang commented Oct 27, 2022

Then I'll use other libraries or write one for my own instead. Communicating with a layer of json rpc just looks ugly for me. Also, the file size of a song is roughly 3~5MB. We don't really need a super fast downloader.

@z-huang z-huang mentioned this issue Oct 29, 2022
3 tasks
@ArjixWasTaken
Copy link

Then I'll use other libraries or write one for my own instead. Communicating with a layer of json rpc just looks ugly for me. Also, the file size of a song is roughly 3~5MB. We don't really need a super fast downloader.

The current downloader is capped at 80kb/s, I don't know why, might be because it is using a single connection for each download

The fact is that you will die if you want to download your entire library...and a fast downloader is a must

@Theta-Dev
Copy link

The slow download speed is caused by YouTube's throttling.

If you want to download YouTube streams at full speed, you have to make it look like you are streaming. Download the file in chunks with a maximum size of 10MB and specify the chunk size either using the Range header or the &range=0-10000000 url parameter.

If you use the Range header, YouTube will send you a Content-Range header back, from which you can extract the total file size and figure out, how many more chunks need to be downloaded.

If you are using the URL parameter method (which is used by the YouTube web player), you need to know the total file size beforehand. It can be extracted from YouTube's player response and it is included in the stream URL as well (clen parameter).

You can use concurrent connections to download multiple chunks at a time, but that is optional. Most music tracks are smaller than 10MB anyway, so they can be downloaded in just 1 chunk.

Adding a bit of randomness to the chunk size is good style, yt-dlp does it too, but I dont know if it is really necessary.

@mosestyle
Copy link

@Theta-Dev Is there a way to somehow speed up the download speed or bypass the throttling somehow? 🤔

@RandomModderJDK
Copy link

Also you can add to the auto download feature, that it only downloads when wifi is available

@Sdarfeesh
Copy link
Contributor

@Theta-Dev Is there a way to somehow speed up the download speed or bypass the throttling somehow? 🤔

Found a way to do speed up

  1. Download any song
  2. Pause the download in notification
  3. Resume it
  4. Download is faster than before (2 MB/s for me)
    This is working for me, I'm not sure is it work for th others, but you can try to reproduce it

@Sdarfeesh
Copy link
Contributor

@Theta-Dev Is there a way to somehow speed up the download speed or bypass the throttling somehow? 🤔

Found a way to do speed up

  1. Download any song
  2. Pause the download in notification
  3. Resume it
  4. Download is faster than before (2 MB/s for me)
    This is working for me, I'm not sure is it work for th others, but you can try to reproduce it
ScreenRecord-20230217-204210.mp4

@sami155
Copy link

sami155 commented Jun 22, 2023

@Theta-Dev Is there a way to somehow speed up the download speed or bypass the throttling somehow? 🤔

Found a way to do speed up

  1. Download any song
  2. Pause the download in notification
  3. Resume it
  4. Download is faster than before (2 MB/s for me)
    This is working for me, I'm not sure is it work for th others, but you can try to reproduce it
ScreenRecord-20230217-204210.mp4

I don't have the option to pause the downloads

@z-huang z-huang closed this as completed Jun 23, 2023
@Sdarfeesh
Copy link
Contributor

In the latest debug version, The download speed was improved, but only works for <10min songs, it's still slow to download the songs which are longer than 10min

screen-20230624-124151.mp4

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

No branches or pull requests

9 participants