Add video support (experimental!)

This commit is contained in:
Cadence Fish
2020-01-30 04:20:20 +13:00
parent 95cc416e08
commit a5ab771969
7 changed files with 96 additions and 43 deletions

View File

@@ -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."
}

View File

@@ -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 {