mirror of
https://git.sr.ht/~cadence/bibliogram
synced 2025-12-15 19:05:09 +00:00
Add video support (experimental!)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
const constants = require("../constants")
|
||||
const {proxyImage, proxyExtendedOwner} = require("../utils/proxyurl")
|
||||
const {proxyImage, proxyVideo} = require("../utils/proxyurl")
|
||||
|
||||
class TimelineBaseMethods {
|
||||
constructor() {
|
||||
@@ -21,10 +21,18 @@ class TimelineBaseMethods {
|
||||
}
|
||||
}
|
||||
|
||||
isVideo() {
|
||||
return this.data.__typename === "GraphVideo"
|
||||
}
|
||||
|
||||
getDisplayUrlP() {
|
||||
return proxyImage(this.data.display_url)
|
||||
}
|
||||
|
||||
getVideoUrlP() {
|
||||
return proxyVideo(this.data.video_url)
|
||||
}
|
||||
|
||||
getAlt() {
|
||||
return this.data.accessibility_caption || "No image description available."
|
||||
}
|
||||
|
||||
@@ -203,6 +203,12 @@ class TimelineEntry extends TimelineBaseMethods {
|
||||
}
|
||||
}
|
||||
|
||||
fetchVideoURL() {
|
||||
if (!this.isVideo()) return Promise.resolve(null)
|
||||
else if (this.data.video_url) return Promise.resolve(this.getVideoUrlP())
|
||||
else return this.update().then(() => this.getVideoUrlP())
|
||||
}
|
||||
|
||||
async fetchFeedData() {
|
||||
const children = await this.fetchChildren()
|
||||
return {
|
||||
|
||||
@@ -5,6 +5,12 @@ function proxyImage(url, width) {
|
||||
return "/imageproxy?"+params.toString()
|
||||
}
|
||||
|
||||
function proxyVideo(url) {
|
||||
const params = new URLSearchParams()
|
||||
params.set("url", url)
|
||||
return "/videoproxy?"+params.toString()
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../types").ExtendedOwner} owner
|
||||
*/
|
||||
@@ -15,4 +21,5 @@ function proxyExtendedOwner(owner) {
|
||||
}
|
||||
|
||||
module.exports.proxyImage = proxyImage
|
||||
module.exports.proxyVideo = proxyVideo
|
||||
module.exports.proxyExtendedOwner = proxyExtendedOwner
|
||||
|
||||
Reference in New Issue
Block a user