-
Notifications
You must be signed in to change notification settings - Fork 41
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
get progress #15
Comments
it shows a progress bar for me:
|
yeah but its not exposed |
what do you mean "exposed" ? |
Thanks for responding! What I'm after is the ability to retrieve the percentage download as a float or something so that I can then use that in my applications. Maybe even a choice between your progress bar or be able to retrieve the percentage so that I can do something with it. I haven't looked into detail how you are calculating the percentage but if you can expose this so it can be requested from an application using your library (or a message that suggests Thank you P.S I notice you have segments left, time left and percentage complete. These would all be very useful to be able to access from an application using your library. |
One clarification - it is not my project, i'm just a random person commenting here. Anyway, can't you read the data from stdout in your app? An example in node.js: // index.mjs import { spawn } from "child_process";
const url = "PUT_SUPPORTED_M3U8_LINK_HERE";
const child = spawn("./hlsdl_linux", ["-u", url]); // modify the path to the hlsdl
const extractElapsedTime = (data) => {
const elapsedTimeMatch = data.match(/... ([^ ]+)/);
if (!elapsedTimeMatch) {
return null;
}
return elapsedTimeMatch[1];
}
const extractSegments = (data) => {
const segmentsMatch = data.match(/(\d+) \/ (\d+)/);
if (!segmentsMatch) {
return {
total: null,
downloaded: null,
left: null,
}
}
const segmentsTotal = segmentsMatch[2];
const segmentsDownloaded = segmentsMatch[1];
const segmentsLeft = segmentsTotal - segmentsDownloaded;
return {
total: segmentsTotal,
downloaded: segmentsDownloaded,
left: segmentsLeft,
}
}
const extractPercentage = (data) => {
const percentageMatch = data.match(/([\d.]+)%/);
console.log(data);
if (!percentageMatch) {
return null;
}
return Number(percentageMatch[1]);
}
const extractTimeLeft = (data) => {
const percSignLocation = data.indexOf("%");
if (percSignLocation === -1) {
return null;
}
const afterPerc = data.slice(percSignLocation + 1);
return afterPerc.trim() || null;
}
child.stdout.on("data", (data) => {
const d = String(data).trim();
if (!d.startsWith("Downloading")) {
return;
}
const elapsedTime = extractElapsedTime(d);
const segments = extractSegments(d);
const percentage = extractPercentage(d);
const timeLeft = extractTimeLeft(d);
console.log({
elapsedTime: elapsedTime ?? "unknown",
segmentsDownloaded: segments.downloaded ?? "unknown",
segmentsTotal: segments.total ?? "unknown",
segmentsLeft: segments.left ?? "unknown",
percentage: percentage ?? "unknown",
timeLeft: timeLeft ?? "unknown",
})
}) you need to wrap it up in some function (and rewrite to your app coding language), and instead of printing to console you of course should notify your web app user (idk, websockets maybe) also i see the percentage calculated by hlsdl is basically just downloaded segments / total segments (not counted/guessed by bytes) so you probably can skip the percentage extraction and just do a little math anyway - with current state of hlsdl it's totally possible to achieve what you need - i'm not saying having a flag that will keep outputting data in json for example wouldn't be nice :) |
Sure I can catch the output but that's not the nicest and I think this would be a nice touch to the library, I could always fork it and do this I just think it would be nice that the library supported it! |
Development of this app looks a little bit stale, but I think @canhlinh (and me as well!) will actually appreciate it if you fork it, extend it to have an option to provide what you need and start a PR :) |
oh yeah, i did not think about it i actually like calling big jobs like that as a separate process:
just few points, maybe you will actually consider doing things like i do :) |
yeah i mean an abort functionality in this pkg/library would be great too. |
I might get around to it! - I'll keep you posted |
@amlwwalker @dzek69 Yes, Your request has a very narrow scope. Creating a fork and then customizing it to your specifications is preferable. |
ok happy to fork - i would say as this this is advertised in the README as being a library that can be used within Go code, exposing the progress would be something that the pkg should offer so that users have control over how progress is managed but if you don't want to i'll do it in a fork |
any way to get the progress as the video is downloading?
For instance i want to show a progressbar/spinner...
The text was updated successfully, but these errors were encountered: