yausername / youtubedl-android

youtube-dl for android
GNU General Public License v3.0
934 stars 172 forks source link

destroyProcessByID not working with external executables running in child processes #261

Open waqas-334 opened 6 months ago

waqas-334 commented 6 months ago

Hey, I am downloading an RTMP file from a site and using a Timer that reads the size of the file from the disk every second.

Downloading works fine but it continues even after I call destroyProccessById() and it returns true. In the screenshot, as you can see, the timer prints the file size that is continuously increasing, which means file is being downloaded in the background.

Any remedy for this?

Screenshot 2023-12-26 at 9 19 08 AM
waqas-334 commented 6 months ago

I am using following commands if that helps

-o, -i, --no-part, --download ffmpeg, -v, -d <file_address>

JunkFood02 commented 6 months ago

If you're using an external downloader like ffmpeg or aria2c, it should be launched and running in another process, which is out of our controll. We can only use the Java API to destroy the original process which runs yt-dlp

waqas-334 commented 6 months ago

uh ho, any work around for this?

farimarwat commented 6 months ago

@JunkFood02 Is it not possible to get PID of ffmpeg and kill that via BuildProcess()/RunTime execution?. Steps Should be:

  1. List PIDs
  2. Find the lib name in proc/pid/map
  3. If exists() then kill
JunkFood02 commented 6 months ago

@farimarwat I'm quite busy right now but feel free to try it yourself and submit a PR! If you need additional input then don't hesitate to ask

waqas-334 commented 6 months ago

More findings: I am convinced that this problem is deriving from yt-dlp, because:

  1. I started the download process using yt-dlp --downloader ffmpeg --no-part "https://cammodels.com/cam/Redhotwifey"
  2. It worked and file begins downloading,
  3. I searched for currently running processes using ps aux | greg yt-dlp -i
  4. Which returned a process details, including the id
  5. I killed the process using kill <process-id>
  6. Process killed but the file continued downloading
  7. I searched for FFmpeg related processes using the above command
  8. That returned 3 ffmpeg-related processes
  9. I killed them one by one, and that made the download process stop.

So the solution would be to figure out the process id that yt-dlp is using to start ffmpeg

farimarwat commented 6 months ago

@farimarwat I'm quite busy right now but feel free to try it yourself and submit a PR! If you need additional input then don't hesitate to ask

I need permissions to create PR. Kindly send me contribution link. Because when ever i try to push a commit, it gives error:

PS C:\Users\BISMILLAH\Downloads\youtubedl-android> git push origin master remote: Permission to yausername/youtubedl-android.git denied to farimarwat. fatal: unable to access 'https://github.com/yausername/youtubedl-android.git/': The requested URL returned error: 403

I am working on the issue and almost near to solve this.

JunkFood02 commented 6 months ago

@farimarwat Please fork this repository and have the work done in your own repo, from which you can submit the pull request to this one

Refer to GitHub docs: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork

JunkFood02 commented 6 months ago

See also: https://github.com/JunkFood02/Seal/issues/180

farimarwat commented 6 months ago

@JunkFood02 I have updated my code to target only the selected process. I have tested it and working fine. For instance if there are 3 processids(running ffmpeg), it will kill that ffmpeg process. So give me feedback and if you agree with the code then kindly merge it. We have to update it in our project.

JunkFood02 commented 6 months ago

@farimarwat Just build the library on your own fork with jitpack https://jitpack.io/#farimarwat/youtubedl-android