From d6acb3e098b18a7ddb2a1f4518e4318380202d0b Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Wed, 19 Jul 2023 02:54:00 +0100 Subject: [PATCH] Add more DeArrow support. --- src/components/FeedPage.vue | 5 ----- src/components/TrendingPage.vue | 7 +++++++ src/components/WatchVideo.vue | 23 +++++++++++++++++++++++ src/main.js | 5 +++++ 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/components/FeedPage.vue b/src/components/FeedPage.vue index 3bc5d690..41832d59 100644 --- a/src/components/FeedPage.vue +++ b/src/components/FeedPage.vue @@ -170,11 +170,6 @@ export default { onFilterChange() { this.setPreference("feedFilter", this.selectedFilter); }, - fetchDeArrowContent(videoIds) { - return this.fetchJson(this.apiUrl() + "/dearrow", { - videoIds: videoIds.join(","), - }); - }, }, }; diff --git a/src/components/TrendingPage.vue b/src/components/TrendingPage.vue index de2741a0..143b6dfc 100644 --- a/src/components/TrendingPage.vue +++ b/src/components/TrendingPage.vue @@ -29,6 +29,13 @@ export default { this.fetchTrending(region).then(videos => { this.videos = videos; this.updateWatched(this.videos); + const videoIds = this.videos.map(video => video.url.substr(-11)).sort(); + this.fetchDeArrowContent(videoIds).then(json => { + Object.keys(json).forEach(key => { + const video = this.videos.find(video => video.url.substr(-11) == key); + video.dearrow = json[key]; + }); + }); }); }, activated() { diff --git a/src/components/WatchVideo.vue b/src/components/WatchVideo.vue index c6b9721a..3b23bd6b 100644 --- a/src/components/WatchVideo.vue +++ b/src/components/WatchVideo.vue @@ -453,6 +453,17 @@ export default { xmlDoc.querySelectorAll("br").forEach(elem => (elem.outerHTML = "\n")); this.video.description = this.rewriteDescription(xmlDoc.querySelector("body").innerHTML); this.updateWatched(this.video.relatedStreams); + + const videoIds = this.video.relatedStreams + .filter(obj => obj.type === "stream") + .map(video => video.url.substr(-11)) + .sort(); + this.fetchDeArrowContent(videoIds).then(json => { + Object.keys(json).forEach(key => { + const video = this.video.relatedStreams.find(video => video.url.substr(-11) == key); + video.dearrow = json[key]; + }); + }); } }); }, @@ -473,6 +484,18 @@ export default { } } }); + await this.fetchPlaylistPages().then(() => { + const videoIds = this.playlist.relatedStreams + .filter(obj => obj.type === "stream") + .map(video => video.url.substr(-11)) + .sort(); + this.fetchDeArrowContent(videoIds).then(json => { + Object.keys(json).forEach(key => { + const video = this.playlist.relatedStreams.find(video => video.url.substr(-11) == key); + video.dearrow = json[key]; + }); + }); + }); } }, async fetchPlaylistPages() { diff --git a/src/main.js b/src/main.js index d52785be..d022e895 100644 --- a/src/main.js +++ b/src/main.js @@ -542,6 +542,11 @@ const mixin = { return undefined; } }, + fetchDeArrowContent(videoIds) { + return this.fetchJson(this.apiUrl() + "/dearrow", { + videoIds: videoIds.join(","), + }); + }, }, computed: { authenticated(_this) {