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

keep downloading file even if vlc is closed. #239

Closed
JiPaix opened this issue Aug 3, 2021 · 6 comments
Closed

keep downloading file even if vlc is closed. #239

JiPaix opened this issue Aug 3, 2021 · 6 comments
Assignees
Labels
CLI command-line interface related issues enhancement New feature or request wontfix This will not be worked on

Comments

@JiPaix
Copy link
Owner

JiPaix commented Aug 3, 2021

Originally posted by @omgbox in #229 (comment)
Solution: #239 (comment)

keep downloading file even if vlc socket is closed . its not really important but would be nice as not to restart the same download.

sockets

@JiPaix JiPaix self-assigned this Aug 3, 2021
@JiPaix JiPaix added CLI command-line interface related issues enhancement New feature or request labels Aug 3, 2021
@JiPaix
Copy link
Owner Author

JiPaix commented Aug 3, 2021

This could be done but I think this is multilayered problem.

Partial files are considered broken, although VLC can read through them.

  • Problem:
    • xdccJS doesn't keep the whole file in memory. It fills a 1024kb buffer and release it through the pipe.
    • Taking VLC as an example (but most applications do the same):
      VLC receives those 1024kb packets, once a packet is read its released from RAM while upcoming packets are stacked up (waiting for you to advance through your file).
  • Solutions:
    • Keep the whole file in memory until the file is complete (meh)
    • Save the file on disk while piping, I could use the error shown in the screenshot to be a trigger of whether or not the file should be kept.
      • What about user intention/consent ?
      • Users would explicitly indicate they want to use pipe with a --pipe option while also providing a --path
  • Attempt (kinda failed):
    • I tried to implement a system where the file is saved on disk and piped to vlc at the same time, using the API instead of the CLI (its more convenient)
      • Catching the error when VLC closes mid download is working, the download is saved on disk.
      • Theses errors aren't triggered by you closing VLC but by xdccJS sending data to VLC which is closed.
        • Meaning there's no error if the download is complete but VLC still plays the remaining data.
      • Since we are using VLC pipe, the player has no way to know when you hit the end of the file, which means VLC has to be closed manually
    • and since VLC itself doesn't know, there's no way to differentiate theses two cases:
      • xdccJS completely downloaded a file => User closes VLC midway through the video/audio file
      • xdccJS completely downloaded a file => User closes VLC at the end of the video/audio file

Conclusion:

The only way i see this is to write both a file and pipe the data, either by manually deleting the file once you don't need it or always keeping the same file (so it's overwritten once you start a new download)

@omgbox
Copy link

omgbox commented Aug 3, 2021

I tried to implement a system where the file is saved on disk and piped to vlc at the same time

wow this is complicated its beyond my understanding . why not use a tiny static file server for the file on disk and serve that file to vlc this way you might avoid having to start another process. As for user intention or consent , since the default is to save file to disk example C:/downloads , why not attached a flag to --path-vlc this will save to disk and start http server and send url to vlc. you would only need to just open http server address http://localhost:8888/$file to stream. now even if the http server has been terminated the xdccjs downloading would still continue until user cancels

write both a file and pipe the data,

this would be a two process sounds complicated and expansive, I think its fast to just use a static server to serve from folder.

this is all very interesting

@JiPaix
Copy link
Owner Author

JiPaix commented Aug 3, 2021

why not use a tiny static file server for the file on disk and serve that file to vlc [...]

[...] you would only need to just open http server address http://localhost:8888/$file to stream. now even if the http server has been terminated the xdccjs downloading would still continue until user cancels

You can already do that without any file server or addition to xdccJS
xdccJS --host irc.server.net --bot "something" --download 100 > temp.mkv & vlc temp.mkv

⚠️ Windows users:
git bash is required, it comes with better tools than the default command prompt.
Just install it and use it as if you were using CMD or NodeJS command prompt

wow this is complicated its beyond my understanding.

This is because i was looking for a more global solution that would work with any program, not just VLC.

why not attached a flag to --path-vlc

This is kinda the same reason as above and also a matter of choice:

  • I don't want the CLI to deviate from the "simple" task its given.
  • Every functionalities for a specific program or library should be done using the API

@JiPaix JiPaix added the wontfix This will not be worked on label Aug 3, 2021
@omgbox
Copy link

omgbox commented Aug 4, 2021

the & in cmd will wait until download has completed only after that it will start vlc streaming

xdccJS --host irc.server.net --bot "something" --download 100 > temp.mkv & vlc temp.mkv

this works perfectly without vlc everything working good.

xdccJS --host irc.server.net --bot "something" --download 100 | mpv -

on some irc servers users have to be on a second channel to download how would i add that second channel

xdccJS --host irc.server.net --bot "something" --channel "second?" --download 100 | mpv -

many thanks the profile saving is working again !

@JiPaix
Copy link
Owner Author

JiPaix commented Aug 4, 2021

the & in cmd will wait until download has completed only after that it will start vlc streaming

That's the precise reason i said windows user need git bash. the default cmd can only run commands one after another.

on some irc servers users have to be on a second channel to download how would i add that second channel

documentation says -c, --channel [chan...] channel(s) to join (without #) so xdccJS --channel chan1 chan2 chan3

@omgbox
Copy link

omgbox commented Aug 4, 2021

thanks for clearing that, everything is working no issues to report. great work done many thanks.

@JiPaix JiPaix pinned this issue Aug 8, 2021
@JiPaix JiPaix closed this as completed Aug 8, 2021
Repository owner locked as resolved and limited conversation to collaborators Aug 8, 2021
@JiPaix JiPaix changed the title keep downloading file even if socket is closed. keep downloading file even if vlc is closed. Aug 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLI command-line interface related issues enhancement New feature or request wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants