mirror of
https://github.com/VueTubeApp/VueTube
synced 2025-01-06 23:51:13 +00:00
Merge pull request #204 from 404-Program-not-found/main
Chore: Small fixes
This commit is contained in:
commit
7bf8a745b8
7 changed files with 52 additions and 119 deletions
|
@ -6,7 +6,9 @@
|
|||
>
|
||||
<div id="details">
|
||||
<a
|
||||
:href="video.navigationEndpoint.browseEndpoint.canonicalBaseUrl"
|
||||
:href="
|
||||
this.$rendererUtils.getNavigationEndpoints(video.navigationEndpoint)
|
||||
"
|
||||
class="avatar-link pt-2"
|
||||
>
|
||||
<v-img
|
||||
|
|
|
@ -31,8 +31,9 @@
|
|||
<div id="details">
|
||||
<a
|
||||
:href="
|
||||
video.shortBylineText.runs[0].navigationEndpoint.browseEndpoint
|
||||
.canonicalBaseUrl
|
||||
this.$rendererUtils.getNavigationEndpoints(
|
||||
video.shortBylineText.runs[0].navigationEndpoint
|
||||
)
|
||||
"
|
||||
class="avatar-link pt-2"
|
||||
>
|
||||
|
|
|
@ -6,14 +6,24 @@
|
|||
text.navigationEndpoint && text.navigationEndpoint.webviewEndpoint
|
||||
"
|
||||
>
|
||||
<a @click="openExternal(parseLinks(text))" :key="index" class="link">{{
|
||||
text.text
|
||||
}}</a>
|
||||
<a
|
||||
@click="
|
||||
openExternal(this.$rendererUtils.getNavigationEndpoints(text))
|
||||
"
|
||||
:key="index"
|
||||
class="link"
|
||||
>{{ text.text }}</a
|
||||
>
|
||||
</template>
|
||||
<template v-else-if="checkInternal(text)">
|
||||
<a @click="openInternal(parseLinks(text))" :key="index" class="link">{{
|
||||
text.text
|
||||
}}</a>
|
||||
<template v-else-if="this.$rendererUtils.checkInternal(text)">
|
||||
<a
|
||||
@click="
|
||||
openInternal(this.$rendererUtils.getNavigationEndpoints(text))
|
||||
"
|
||||
:key="index"
|
||||
class="link"
|
||||
>{{ text.text }}</a
|
||||
>
|
||||
</template>
|
||||
<template v-else> {{ text.text }} </template>
|
||||
</template>
|
||||
|
@ -28,28 +38,6 @@ export default {
|
|||
props: ["render"],
|
||||
|
||||
methods: {
|
||||
parseLinks(base) {
|
||||
const navEndpoint = base.navigationEndpoint;
|
||||
if (!navEndpoint) return;
|
||||
if (navEndpoint.webviewEndpoint) {
|
||||
return navEndpoint.webviewEndpoint.url;
|
||||
} else if (navEndpoint.browseEndpoint) {
|
||||
return navEndpoint.browseEndpoint.canonicalBaseUrl;
|
||||
} else if (navEndpoint.watchEndpoint) {
|
||||
return `/watch?v=${navEndpoint.watchEndpoint.videoId}`;
|
||||
} else if (navEndpoint.navigationEndpoint) {
|
||||
return; //for now
|
||||
}
|
||||
},
|
||||
checkInternal(base) {
|
||||
const navEndpoint = base.navigationEndpoint;
|
||||
if (!navEndpoint) return false;
|
||||
if (navEndpoint.browseEndpoint || navEndpoint.watchEndpoint) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
async openExternal(url) {
|
||||
await Browser.open({ url: url });
|
||||
},
|
||||
|
|
|
@ -31,8 +31,9 @@
|
|||
<div id="details">
|
||||
<a
|
||||
:href="
|
||||
video.shortBylineText.runs[0].navigationEndpoint.browseEndpoint
|
||||
.canonicalBaseUrl
|
||||
this.$rendererUtils.getNavigationEndpoints(
|
||||
video.shortBylineText.runs[0].navigationEndpoint
|
||||
)
|
||||
"
|
||||
class="avatar-link pt-2"
|
||||
>
|
||||
|
|
|
@ -87,7 +87,6 @@ export default {
|
|||
|
||||
mounted() {
|
||||
this.accentColor = this.$vuetify.theme.themes.dark.primary.base;
|
||||
this.roblox = localStorage.getItem("roblox") === "true";
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
|
|
@ -1,87 +1,28 @@
|
|||
import Innertube from "./innertube";
|
||||
import constants from "./constants";
|
||||
// General utility functions for the renderers
|
||||
class rendererUtils {
|
||||
static getNavigationEndpoints(base) {
|
||||
const navEndpoint = base.navigationEndpoint;
|
||||
if (!navEndpoint) return;
|
||||
if (navEndpoint.webviewEndpoint) {
|
||||
return navEndpoint.webviewEndpoint.url;
|
||||
} else if (navEndpoint.browseEndpoint) {
|
||||
return navEndpoint.browseEndpoint.canonicalBaseUrl;
|
||||
} else if (navEndpoint.watchEndpoint) {
|
||||
return `/watch?v=${navEndpoint.watchEndpoint.videoId}`;
|
||||
} else if (navEndpoint.navigationEndpoint) {
|
||||
return; //for now
|
||||
}
|
||||
}
|
||||
|
||||
// Pointer object, give a key and it will return with a method
|
||||
function useRender(video, renderer) {
|
||||
switch (renderer) {
|
||||
case "videoWithContextRenderer":
|
||||
return videoWithContextRenderer(video);
|
||||
case "gridVideoRenderer":
|
||||
return gridVideoRenderer(video);
|
||||
case "compactAutoplayRenderer":
|
||||
return compactAutoplayRenderer(video);
|
||||
case "compactVideoRenderer":
|
||||
return compactVideoRenderer(video);
|
||||
default:
|
||||
return undefined;
|
||||
static checkInternal(base) {
|
||||
const navEndpoint = base.navigationEndpoint;
|
||||
if (!navEndpoint) return false;
|
||||
if (navEndpoint.browseEndpoint || navEndpoint.watchEndpoint) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function gridVideoRenderer(video) {
|
||||
return {
|
||||
id: video.videoId,
|
||||
title: video.title?.runs[0].text,
|
||||
thumbnail: Innertube.getThumbnail(video.videoId, "max"),
|
||||
channel: video.shortBylineText?.runs[0]
|
||||
? video.shortBylineText.runs[0].text
|
||||
: video.longBylineText?.runs[0].text,
|
||||
channelId: (video.shortBylineText?.runs[0]
|
||||
? video.shortBylineText.runs[0]
|
||||
: video.longBylineText?.runs[0]
|
||||
).navigationEndpoint?.browseEndpoint?.browseId,
|
||||
channelURL: `${constants.YT_URL}/${
|
||||
(video.shortBylineText?.runs[0]
|
||||
? video.shortBylineText.runs[0]
|
||||
: video.longBylineText?.runs[0]
|
||||
).navigationEndpoint?.browseEndpoint?.canonicalBaseUrl
|
||||
}`,
|
||||
channelThumbnail: video.channelThumbnail?.thumbnails[0],
|
||||
metadata: {
|
||||
published: video.publishedTimeText?.runs[0].text,
|
||||
views: video.shortViewCountText?.runs[0].text,
|
||||
length: video.lengthText?.runs[0].text,
|
||||
overlayStyle: video.thumbnailOverlays?.map(
|
||||
(overlay) => overlay.thumbnailOverlayTimeStatusRenderer?.style
|
||||
),
|
||||
overlay: video.thumbnailOverlays?.map(
|
||||
(overlay) =>
|
||||
overlay.thumbnailOverlayTimeStatusRenderer?.text.runs[0].text
|
||||
),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function compactAutoplayRenderer(video) {
|
||||
video = video.contents;
|
||||
let item;
|
||||
if (video) item = video[0];
|
||||
if (item) return useRender(item[Object.keys(item)[0]], Object.keys(item)[0]);
|
||||
else return undefined;
|
||||
}
|
||||
|
||||
function compactVideoRenderer(video) {
|
||||
return {
|
||||
id: video.videoId,
|
||||
title: video.title?.runs[0].text,
|
||||
thumbnail: Innertube.getThumbnail(video.videoId, "max"),
|
||||
channel: video.shortBylineText?.runs[0].text,
|
||||
channelURL:
|
||||
video.shortBylineText?.runs[0].navigationEndpoint?.browseEndpoint
|
||||
?.canonicalBaseUrl,
|
||||
channelThumbnail: video.channelThumbnail?.thumbnails[0].url,
|
||||
metadata: {
|
||||
views: video.viewCountText?.runs[0].text,
|
||||
length: video.lengthText?.runs[0].text,
|
||||
publishedTimeText: video.publishedTimeText.runs[0].text,
|
||||
overlayStyle: video.thumbnailOverlays?.map(
|
||||
(overlay) => overlay.thumbnailOverlayTimeStatusRenderer?.style
|
||||
),
|
||||
overlay: video.thumbnailOverlays?.map(
|
||||
(overlay) =>
|
||||
overlay.thumbnailOverlayTimeStatusRenderer?.text.runs[0].text
|
||||
),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export default useRender;
|
||||
export default rendererUtils;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import { Http } from "@capacitor-community/http";
|
||||
import Innertube from "./innertube";
|
||||
import constants from "./constants";
|
||||
import useRender from "./renderers";
|
||||
import rendererUtils from "./renderers";
|
||||
import { Buffer } from "buffer";
|
||||
|
||||
//--- Logger Function ---//
|
||||
|
@ -143,5 +143,6 @@ const innertubeModule = {
|
|||
export default ({ app }, inject) => {
|
||||
inject("youtube", { ...searchModule, ...innertubeModule });
|
||||
inject("logger", logger);
|
||||
inject("rendererUtils", rendererUtils);
|
||||
};
|
||||
logger(constants.LOGGER_NAMES.init, "Program Started");
|
||||
|
|
Loading…
Reference in a new issue