You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
2.4 KiB
49 lines
2.4 KiB
function videoAPIPeerTube( contentFilename ){
|
|
let file = filesWithMetadata[contentFilename]
|
|
//if (!file) return
|
|
// can be removed for URLs as those are not with metadata
|
|
|
|
let contentType = file.contentType
|
|
|
|
// mereology option
|
|
let openingOptions = filesWithMetadata[contentFilename].openingOptions
|
|
// can be used via e.g. showFile("https://fabien.benetou.fr/?action=source",{ mereology:"whole"})
|
|
|
|
// filtering, only applying what's next to a certain content type and/or with filename filtering with .startsWith() .endsWith() .includes() or regex
|
|
if ( contentFilename.includes("/api/v1/search/videos") ) { // peertube API, not specific enough
|
|
// could verify instead via header i.e x-powered-by: PeerTube
|
|
console.log('it is a PeerTube API call', contentFilename)
|
|
|
|
fetch( contentFilename ).then( r => r.json() ).then( json => {
|
|
const rootEl = document.createElement("a-entity")
|
|
rootEl.jsonfromapi = json // rarely so big that it makes any difference to have it twice, on here and on individual items
|
|
// having a root element to attach on makes manipulation later on easier and safer, bringing a context for later modifications
|
|
file.filteredEl = rootEl
|
|
rootEl.test = _ => console.log( 'test' )
|
|
// function that can then be called on the created element later on
|
|
// e.g. filesWithMetadata["https://companion.benetou.fr/saved/pdfxml/3209542.3209570.xml"].filteredEl.nextPage('ok')
|
|
AFRAME.scenes[0].appendChild(rootEl)
|
|
json.data.map( (d,i) => {
|
|
let el = document.createElement("a-image")
|
|
rootEl.appendChild(el)
|
|
el.setAttribute("position", ""+(-1+Math.random())+" "+(Math.random()+1)+" -0.5" )
|
|
el.setAttribute("scale", ".2 .1 .1")
|
|
el.setAttribute("src", contentFilename.replace(/\/api.*/,'') + d.thumbnailPath)
|
|
el.setAttribute("target", "")
|
|
el.jsonfromapi = d
|
|
el.id = "video_"+d.name
|
|
})
|
|
|
|
|
|
AFRAME.scenes[0].emit('videoapipeertube_loaded', contentFilename)
|
|
// to use the event consider :
|
|
//AFRAME.scenes[0].addEventListener("videoapipeertube_loaded", e => console.log(e))
|
|
|
|
} );
|
|
}
|
|
applyNextFilter( contentFilename )
|
|
// can stop here or move on to the next filter that might or not be applied
|
|
}
|
|
sequentialFilters.push( videoAPIPeerTube )
|
|
// adding this to the list of filters to go through, order matters
|
|
// typically one would be generic filters first then more specific ones after
|
|
|