File tree Expand file tree Collapse file tree 2 files changed +23
-4
lines changed
src/ImageWizard.Core/Loaders Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -50,9 +50,6 @@ public HttpLoaderBase(
5050 /// <summary>
5151 /// GetAsync
5252 /// </summary>
53- /// <param name="source"></param>
54- /// <param name="existingCachedData"></param>
55- /// <returns></returns>
5653 public override async Task < LoaderResult > GetAsync ( string source , ICachedData ? existingCachedData )
5754 {
5855 Uri ? url = await CreateRequestUrl ( source ) ;
Original file line number Diff line number Diff line change @@ -23,6 +23,28 @@ public YouTubeLoader(
2323
2424 protected override Task < Uri ? > CreateRequestUrl ( string source )
2525 {
26- return Task . FromResult < Uri ? > ( new Uri ( $ "https://i.ytimg.com/vi/{ source } /maxresdefault.jpg") ) ;
26+ return Task . FromResult < Uri ? > ( new Uri ( source ) ) ;
27+ }
28+
29+ public override async Task < LoaderResult > GetAsync ( string source , ICachedData ? existingCachedData )
30+ {
31+ string [ ] quality = [
32+ "maxresdefault.jpg" , //1920 x 1080
33+ "hq720.jpg" , //1280 x 720
34+ "sddefault.jpg" , //640 x 480
35+ "hqdefault.jpg" , //480 x 360
36+ ] ;
37+
38+ for ( int i = 0 ; i < quality . Length ; i ++ )
39+ {
40+ LoaderResult result = await base . GetAsync ( $ "https://i.ytimg.com/vi/{ source } /{ quality [ i ] } ", existingCachedData ) ;
41+
42+ if ( result . State == LoaderResultState . Success )
43+ {
44+ return result ;
45+ }
46+ }
47+
48+ return LoaderResult . NotFound ( ) ;
2749 }
2850}
You can’t perform that action at this time.
0 commit comments