Skip to content

Commit

Permalink
fix: fix for empty thumbnails.
Browse files Browse the repository at this point in the history
  • Loading branch information
pixkk committed Aug 22, 2024
1 parent d4bc02c commit c4e3879
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion NUXT/components/Player/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
}"
>
<video
preload="metadata"
ref="player"
v-touch="{
up: () => {
Expand Down Expand Up @@ -53,7 +54,7 @@
}rem 0rem 0rem !important`
: '0',
}"
:poster="$youtube.getThumbnail($route.query.v, 'max', [])"
:poster="$youtube.getThumbnail($route.query.v, '', [])"
@loadedmetadata="checkDimensions()"
@click="controlsHandler()"
/>
Expand Down
17 changes: 13 additions & 4 deletions NUXT/plugins/youtube.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,18 @@ const innertubeModule = {
getThumbnail(id, resolution, backupThumbnail) {
// 19.08.2024 - backupThumbnail temporary unused
if (resolution === "max") {
return `https://img.youtube.com/vi/${id}/maxresdefault.jpg`;
} else {
return `https://img.youtube.com/vi/${id}/hqdefault.jpg`;
let maxResUrl = `https://img.youtube.com/vi/${id}/maxresdefault.jpg`;
let xhr = new XMLHttpRequest();

xhr.open('GET', maxResUrl, false);
xhr.send();
if (xhr.status === 200) {
return maxResUrl;
} else {
return `https://img.youtube.com/vi/${id}/mqdefault.jpg`;
}
}
return `https://img.youtube.com/vi/${id}/mqdefault.jpg`;
},

async getChannel(url, tab="main", continuation = null) {
Expand Down Expand Up @@ -420,7 +428,8 @@ const innertubeModule = {

async getContinuation(continuation, endpoint, mode = "android") {
let contextAdditional = {};
if (mode.toLowerCase() == "web") {
console.log("mode: ", mode);
if (mode.toLowerCase() === "web") {
contextAdditional = {
...contextAdditional,
...{
Expand Down

0 comments on commit c4e3879

Please sign in to comment.