-
Notifications
You must be signed in to change notification settings - Fork 47
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
feat: fetch mpd/dash playlists too #35
Conversation
e98e4c6
to
9f8ffa3
Compare
requestRetryDelay = 5000 | ||
} = options; | ||
|
||
let resources = []; | ||
const manifest = {}; | ||
const manifest = {parent}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dash needs access to the parent manifest on child playlists
@@ -147,125 +168,160 @@ const walkPlaylist = function(options) { | |||
visitedUrls = [], | |||
requestTimeout = 1500, | |||
requestRetryMaxAttempts = 5, | |||
dashPlaylist = null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In mpd-parser
we really only mock child playlists. So if we see dashPlaylist
here we know:
- That this playlist won't have a uri, or anything to download
- That this playlist has already been parsed
resources.push(manifest); | ||
visitedUrls.push(manifest.uri); | ||
if (dashPlaylist) { | ||
requestPromise = Promise.resolve({statusCode: 200}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only request when needed.
|
||
let dash; | ||
|
||
if (!dashPlaylist) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only parse when needed.
@@ -68,15 +68,15 @@ const WriteData = function(decrypt, concurrency, resources) { | |||
operations.push(function() { | |||
return writeFile(r.file, r.content); | |||
}); | |||
} else if (r.key && decrypt) { | |||
} else if (r.uri && r.key && decrypt) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ignore any file that does not have a uri, such as dash playlists.
8f73d2b
to
eaf7337
Compare
bff5fe6
to
e8114da
Compare
eaf7337
to
a67a125
Compare
Looks like this works for simple mpds, it didn't work for the SIDX mpd that we have linked in VHS master. |
Fixed the sidx case and decryption, seems like aes-decrypter expects a Uint8Array and not an ArrayBuffer, not sure when this happened. |
if (err) { | ||
return reject(err); | ||
} | ||
return resolve(new Buffer(bytes)); | ||
return resolve(Buffer.from(bytes)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new Buffer
is deprecated in current nodejs
and this is now the reccomended usage.
}; | ||
|
||
const decryptFile = function(content, encryption) { | ||
return new Promise(function(resolve, reject) { | ||
/* eslint-disable no-new */ | ||
// this is how you use it, its kind of bad but :shrug: | ||
new AesDecrypter(toArrayBuffer(content), encryption.bytes, encryption.iv, function(err, bytes) { | ||
new AesDecrypter(toUint8Array(content), encryption.bytes, encryption.iv, function(err, bytes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AesDecrypter
expects a Uint8Array
} | ||
return ab; | ||
const toUint8Array = function(nodeBuffer) { | ||
return new Uint8Array(nodeBuffer.buffer, nodeBuffer.byteOffset, nodeBuffer.byteLength / Uint8Array.BYTES_PER_ELEMENT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node
s Buffer
object to Uint8Array
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SIDX and decryption is working now. LGTM.
Closes #34