Skip to content

Commit

Permalink
improve stream end detect
Browse files Browse the repository at this point in the history
  • Loading branch information
Last-Order committed Jan 25, 2022
1 parent 18b4625 commit 7f16913
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "minyami",
"version": "4.4.14",
"version": "4.5.0",
"description": "",
"main": "dist/exports.js",
"types": "dist/exports.d.ts",
Expand Down
1 change: 0 additions & 1 deletion src/core/archive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ class ArchiveDownloader extends Downloader {
*/
async parse() {
// parse m3u8
console.log(this.m3u8);
if (this.m3u8.encryptKeys.length > 0) {
// Encrypted
const key = this.m3u8.encryptKeys[0];
Expand Down
8 changes: 6 additions & 2 deletions src/core/live.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@ export default class LiveDownloader extends Downloader {
this.m3u8 = (await loadM3U8(this.m3u8Path, this.retries, this.timeout)) as Playlist;
} catch (e) {
if (this.finishedChunkCount > 0) {
// Stop downloading
this.isEnd = true;
const responseStatus = e?.response?.status;
if (!!responseStatus && responseStatus >= 400 && responseStatus <= 599) {
logger.info("M3U8 file is no longer available. Stop downloading.");
// Stop downloading
this.isEnd = true;
}
} else {
logger.error("Aborted due to critical error.", e);
this.emit("critical-error", e);
Expand Down

0 comments on commit 7f16913

Please sign in to comment.