Closed georgyo closed 3 years ago
This is most likely a possible bug as manifest.m3u8 specifies the correct path per the directory structure, and file plays correctly using VLC. Could you provide some addition details? Such as extra logs if any, go-ipfs or js-ipfs version, and version of hlsjs-ipfs-loader?
I have never coded any javascript before, so I am not going to submit a PR, but I believe this fixes it.
Demo of patched code @ https://shamm.as/video/
diff --git a/src/index.js b/src/index.js
index 4a40a38..9ad06cc 100644
--- a/src/index.js
+++ b/src/index.js
@@ -60,8 +60,7 @@ class HlsjsIPFSLoader {
stats.tfirst = Math.max(performance.now(), stats.trequest)
stats.loaded = 0
- const urlParts = context.url.split("/")
- const filename = urlParts[urlParts.length - 1]
+ const filename = context.url.replace(window.location.href, "")
const options = {}
if (Number.isFinite(context.rangeStart)) {
@@ -115,12 +114,18 @@ class HlsjsIPFSLoader {
async function getFile(ipfs, rootHash, filename, options, debug, abortFlag) {
debug(`Fetching hash for '${rootHash}/${filename}'`)
+ const path = `${rootHash}/${filename}`
+ const pathParts = path.split("/")
+ const short_filename = pathParts.pop()
+ const basePath = pathParts.join("/")
+
+
if(filename === null) {
return cat(rootHash, options, ipfs, debug, abortFlag)
}
- for await (const link of ipfs.ls(rootHash)) {
- if (link.name !== filename) {
+ for await (const link of ipfs.ls(basePath)) {
+ if (link.name !== short_filename) {
continue
}
Attemping to play
mainfest.m3u8
from eitherQmTzZF9GBEGq7m8cWdhoiCLB9U4YY2zEkQGV4sWqdZ2YrT
orQmZ82qHYfPC2vd3BXYZMTBojjAUfXQPKMyky2SSBTQvqUk
both fail because the something is removing the directories from the path.mainfest.m3u8
referencesstream0/stream0.m3u8
however this returns the error:/ipfs/QmZ82qHYfPC2vd3BXYZMTBojjAUfXQPKMyky2SSBTQvqUk/manifest.m3u8
looks like this to ease ticket viewing.