last day (15 days later) » 

7:37 PM
0
A: Prompt to download a stream of multiple files as one

Endless I'm surprised javascript can't just create a "virtual localhost connection" where it uses some generator to "yield" the contents of each file... Well, if you use a service worker then you can manipulate the response and give it a readableStream which you can "yield" the content of each file....

 
It could be swapped out with yield and bluebird-coroutine for example but i used async to let it be up do you wanna do (async/await is not yet available) unless you use a transpiler
 
This looks really interesting and I'll totally try this out. I don't really know javascript, so I'll have to learn this part because this is literally the only function I need on that website. I'll report back soon :)
One question, can I do it in <script> or is it Node.js way? I'm getting Uncaught SyntaxError: Unexpected token function even when I "use strict";
 
This is only client side, so do it inside a <script> tag. This won't work in Node.
 
It doesn't let me use it in <script> tag. It's es6/7 as you said. As soon as I use async it throws an error.
 
async isn't available in any browser as of yet
I updated the answer to be a generator, yield + bluebird coroutine operator, it's similar to how async/await works but can be used today but now you also need to include bluebird into your website
 
7:37 PM
Just tried it and it downloads the files but produced onefile.txt is an empty file.
 
Maybe figured out what the error was... should be !done && ... can you test it?
 
Yeah, it works, but what am I supposed to do with the intercept-me-nr... and /mitm.html?version=0.2.0 popping up?
 
Hi, are you there?
 
 
3 hours later…
10:32 PM
The mitm.html should just be visible for a split sec. If you were to run on a https site then it would be hidden.
you shouldn't really do anything with them
 
10:57 PM
Hey, I'm sorry I didn't check stackoverflow since your last comment
 
np
 
I changed the fetch to have "no-cors", I think that ignores the origin thing, right?
 
dose everything work okey now?
yes, i think it will ignore
 
The only issue I had with it was new tabs opening with mitm.html and the intercept-me
On default the popup windows are blocked in chrome, so I had to whitelist the website to make the entire script work
When it's blocked it doesn't progress
 
hmm, you should see at most 1 new tab being opening and closing for a split second...
 
11:03 PM
to make that tab open I still have to whitelist the website
chrome blocks popup windows
isn't there a way to make that request in code instead of opening a new tab?
And one more thing. Does the script join files in list order or randomly? If I had 100 files, would they be joined in order from first to last?
 
yes, they will be joined in order, the way it currently works now is that it will download one file at the time, write it to the file and then download the next one
 
That's what I thought it does
 
could maybe build something more complex like multi threaded download... but that is more complicated
 
It's a great script really, thanks very much for it. I was actually thinking of making it into a chrome extension instead of making a website. I don't know how I would proceed with that, but all I need is your StreamSaver and bluebird to make it work.
 
There is two way to get around the popup issue
1) Is to simply use https, then it will use iframes to communicate with the service worker
2) open the link on a user interaction like onclick the popup to get around the blacklist
 
11:09 PM
I think if I use a chrome extension it doesn't need to be https
If I create an extension which fires the download([]) function
I'll do some testing tomorrow
I'll accept your answer as it's really working and I doubt there is any other way to do this.
 
are you going to use my streamsaver in a chrome extension?
Thanks for that
 
I think so
 
Don't think you would be able to use the streamsaver inside a chrome extension, it kind of depends on a service worker, don't know how you would pull that of in chrome...
 
Chrome accepts background and content scripts. I think there must be a way
 
might work inside a background.html
 
11:14 PM
or injected into a website code?
If I injected StreamSaver.js into the website, like google.com
 
if you are injecting it into a website then it could work
 
yeah, that's possible in chrome extensions
 
i know
 
Cool, i have been looking forward to creating SW in chrome extension for a while now
 
11:17 PM
I just want to make an extension for people to be able to download Twitch VODs as one file
since it's split into thousands of mpeg2 ts streams
Thanks again for the help with that question. I hope it's going to work in chrome extension :)
 
tried to look at some video's from twitchvods.com
didn't work
dose it require flash?
 
no
Twitch has their own endpoint called Kraken and Usher
you need to authenticate
and get m3u8 playlist of the VOD
the m3u8 playlist contains all the video.ts fragments of the VOD
then you just download them all and concat
or download only some of them as you like
this is an example of vods
if you open network inspection you can see the m3u8 playlist being downloaded after player is loaded on website
 
I found the m3u8 but the video is still not playing - getting all kind of error in the log
 
its HLS video
its not supported by browsers yet I think
it's html streaming
If you install livestreamer (pip install livestreamer) you can run livestreamer --stream-url <vod link> best
then copy that link to player
 
you can also open the m3u8 url in VLC ;)
 
11:27 PM
yea thats what I said :P
I want to be able to download those segments combined, as one file, using your StreamSaver.js
 
I'm going to try to make a plunker, jsfiddle of some sort :P
 
good luck :D
I already made one extension for twitch github.com/vixing/tbf-extension
code is horrible, but it works
If you download the m3u8 and try to open it in VLC, it won't work, because the files have relative paths, not fulll paths
you would have to open it with full link
 
11:44 PM
still here?
just a quick hack: jsfiddle.net/ntuyd0j2
there should not be any popup or new tabs there...
 

  last day (15 days later) »