Skip to content

Support reading PeerTube application/activity+json #688

@jg10-mastodon-social

Description

@jg10-mastodon-social

I managed to get use rdflib.js to read the JSON-LD in https://spectra.video/videos/watch/3a0159d9-4f12-4dd7-b025-afbb663cd19c

Here's what I ended up doing (from a SolidOS instance):

let kb=panes.UI.store
panes.UI.store.fetcher.mediatypes["application/activity+json"]={}
panes.UI.store.fetcher.handlers[6].pattern=new RegExp("application/activity\\+json")
panes.UI.store.fetcher.load(kb.sym("https://spectra.video/videos/watch/3a0159d9-4f12-4dd7-b025-afbb663cd19c"),{force:true,headers:{},credentials: "omit"}).then(
 ()=>console.log(kb.match(kb.sym("https://spectra.video/videos/watch/3a0159d9-4f12-4dd7-b025-afbb663cd19c")))
)

Specifying the media type is required to adjust the accept header, otherwise PeerTube returns html.
The new accept header is image/*;q=0.9, */*;q=0.1, application/rdf+xml;q=0.9, application/xhtml+xml, text/xml;q=0.5, application/xml;q=0.5, text/html;q=0.9, text/plain;q=0.5, text/n3;q=1.0, text/turtle;q=1, application/ld+json;q=0.9, application/activity+json

Specifying the handler pattern is required so that load recognises the media type as parseable by the jsonldparser. To still support jsonld, this should probably be something like pattern=new RegExp("application/(ld|activity)\\+json")

I don't know why the options to load are needed but they seem to be.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions