This repository was archived by the owner on Feb 27, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +35
-27
lines changed Expand file tree Collapse file tree 4 files changed +35
-27
lines changed Original file line number Diff line number Diff line change 54
54
}rem 0rem 0rem !important`
55
55
: '0',
56
56
}"
57
- :poster =" getThumbnail($route.query.v)"
57
+ :poster =" $youtube. getThumbnail($route.query.v, 'max', [] )"
58
58
@loadedmetadata =" checkDimensions()"
59
59
@click =" controlsHandler()"
60
60
/>
@@ -352,7 +352,6 @@ import progressbar from "~/components/Player/progressbar.vue";
352
352
import sponsorblock from " ~/components/Player/sponsorblock.vue" ;
353
353
354
354
import backType from " ~/plugins/classes/backType" ;
355
- import Thumbnail from " ~/plugins/thumbnail" ;
356
355
357
356
export default {
358
357
components: {
@@ -624,11 +623,6 @@ export default {
624
623
this .$refs .player .playbackRate = speed;
625
624
this .$refs .audio .playbackRate = speed;
626
625
},
627
- getThumbnail (query ) {
628
- const thumbnail = new Thumbnail ();
629
-
630
- return thumbnail .getThumbnail (query, " max" , []);
631
- },
632
626
checkDimensions () {
633
627
if (this .$refs .player .videoHeight > this .$refs .player .videoWidth ) {
634
628
this .isVerticalVideo = true ;
Original file line number Diff line number Diff line change @@ -262,6 +262,20 @@ class Innertube {
262
262
} ) ;
263
263
}
264
264
265
+ // Static methods
266
+
267
+ static getThumbnail ( id , resolution ) {
268
+ if ( resolution == "max" ) {
269
+ const url = `https://img.youtube.com/vi/${ id } /maxresdefault.jpg` ;
270
+ let img = new Image ( ) ;
271
+ img . src = url ;
272
+ img . onload = function ( ) {
273
+ if ( img . height !== 120 ) return url ;
274
+ } ;
275
+ }
276
+ return `https://img.youtube.com/vi/${ id } /mqdefault.jpg` ;
277
+ }
278
+
265
279
// Simple Wrappers
266
280
async getRecommendationsAsync ( ) {
267
281
const rec = await this . browseAsync ( "recommendations" ) ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -91,14 +91,30 @@ const innertubeModule = {
91
91
async getVid ( id ) {
92
92
try {
93
93
return await InnertubeAPI . VidInfoAsync ( id ) ;
94
- } catch ( error ) { }
94
+ } catch ( error ) {
95
+ }
96
+ } ,
97
+
98
+ getThumbnail ( id , resolution , backupThumbnail ) {
99
+ if ( resolution == "max" ) {
100
+ const url = `https://img.youtube.com/vi/${ id } /maxresdefault.jpg` ;
101
+ let img = new Image ( ) ;
102
+ img . src = url ;
103
+ img . onload = function ( ) {
104
+ if ( img . height !== 120 ) return url ;
105
+ } ;
106
+ }
107
+ if ( backupThumbnail [ backupThumbnail . length - 1 ] )
108
+ return backupThumbnail [ backupThumbnail . length - 1 ] . url ;
109
+ else return `https://img.youtube.com/vi/${ id } /mqdefault.jpg` ;
95
110
} ,
96
111
97
112
async getChannel ( url ) {
98
113
try {
99
114
const response = await InnertubeAPI . getChannelAsync ( url ) ;
100
115
return response . data ;
101
- } catch ( error ) { }
116
+ } catch ( error ) {
117
+ }
102
118
} ,
103
119
104
120
// It just works™
@@ -161,7 +177,8 @@ const innertubeModule = {
161
177
try {
162
178
const response = await InnertubeAPI . getSearchAsync ( query ) ;
163
179
return response . contents . sectionListRenderer ;
164
- } catch ( err ) { }
180
+ } catch ( err ) {
181
+ }
165
182
} ,
166
183
167
184
async saveApiStats ( query , url ) {
You can’t perform that action at this time.
0 commit comments