7
7
using MediaBrowser . Controller . Providers ;
8
8
using MediaBrowser . Model . Dto ;
9
9
using MediaBrowser . Model . Entities ;
10
- using MediaBrowser . Model . Extensions ;
11
10
using MediaBrowser . Model . Providers ;
12
11
using Microsoft . AspNetCore . Http ;
13
12
using Microsoft . Extensions . Logging ;
@@ -53,16 +52,16 @@ public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, Cancell
53
52
{
54
53
return Enumerable . Empty < RemoteImageInfo > ( ) ;
55
54
}
56
- var imageLanguages = this . GetImageLanguageParam ( item . PreferredMetadataLanguage , primary . Language ) ;
57
- var backdropImgs = await this . GetBackdrop ( item , imageLanguages , cancellationToken ) . ConfigureAwait ( false ) ;
58
- var logoImgs = await this . GetLogos ( item , imageLanguages , cancellationToken ) . ConfigureAwait ( false ) ;
55
+ var backdropImgs = await this . GetBackdrop ( item , primary . PrimaryLanguageCode , cancellationToken ) . ConfigureAwait ( false ) ;
56
+ var logoImgs = await this . GetLogos ( item , primary . PrimaryLanguageCode , cancellationToken ) . ConfigureAwait ( false ) ;
59
57
60
58
var res = new List < RemoteImageInfo > {
61
59
new RemoteImageInfo
62
60
{
63
61
ProviderName = this . Name ,
64
62
Url = this . GetDoubanPoster ( primary ) ,
65
63
Type = ImageType . Primary ,
64
+ Language = "zh" ,
66
65
} ,
67
66
} ;
68
67
res . AddRange ( backdropImgs ) ;
@@ -133,7 +132,7 @@ public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, Cancell
133
132
/// Query for a background photo
134
133
/// </summary>
135
134
/// <param name="cancellationToken">Instance of the <see cref="CancellationToken"/> interface.</param>
136
- private async Task < IEnumerable < RemoteImageInfo > > GetBackdrop ( BaseItem item , string imageLanguages , CancellationToken cancellationToken )
135
+ private async Task < IEnumerable < RemoteImageInfo > > GetBackdrop ( BaseItem item , string alternativeImageLanguage , CancellationToken cancellationToken )
137
136
{
138
137
var sid = item . GetProviderId ( DoubanProviderId ) ;
139
138
var tmdbId = item . GetProviderId ( MetadataProvider . Tmdb ) ;
@@ -157,6 +156,7 @@ private async Task<IEnumerable<RemoteImageInfo>> GetBackdrop(BaseItem item, stri
157
156
Height = x . Height ,
158
157
Width = x . Width ,
159
158
Type = ImageType . Backdrop ,
159
+ Language = "zh" ,
160
160
} ;
161
161
}
162
162
else
@@ -166,46 +166,48 @@ private async Task<IEnumerable<RemoteImageInfo>> GetBackdrop(BaseItem item, stri
166
166
ProviderName = this . Name ,
167
167
Url = this . GetProxyImageUrl ( x . Large ) ,
168
168
Type = ImageType . Backdrop ,
169
+ Language = "zh" ,
169
170
} ;
170
171
}
171
172
} ) . ToList ( ) ;
172
173
173
174
}
174
175
}
175
176
176
- // 背景图缺失,从TheMovieDb补充背景图
177
- if ( list . Count == 0 && config . EnableTmdbBackdrop && ! string . IsNullOrEmpty ( tmdbId ) )
177
+ // 添加 TheMovieDb 背景图为备选
178
+ if ( config . EnableTmdbBackdrop && ! string . IsNullOrEmpty ( tmdbId ) )
178
179
{
179
180
var language = item . GetPreferredMetadataLanguage ( ) ;
180
181
var movie = await this . _tmdbApi
181
- . GetMovieAsync ( tmdbId . ToInt ( ) , language , imageLanguages , cancellationToken )
182
+ . GetMovieAsync ( tmdbId . ToInt ( ) , language , language , cancellationToken )
182
183
. ConfigureAwait ( false ) ;
183
184
184
185
if ( movie != null && ! string . IsNullOrEmpty ( movie . BackdropPath ) )
185
186
{
186
- this . Log ( "GetBackdrop from tmdb id: {0} lang: {1}" , tmdbId , imageLanguages ) ;
187
+ this . Log ( "GetBackdrop from tmdb id: {0} lang: {1}" , tmdbId , language ) ;
187
188
list . Add ( new RemoteImageInfo
188
189
{
189
190
ProviderName = this . Name ,
190
191
Url = this . _tmdbApi . GetBackdropUrl ( movie . BackdropPath ) ,
191
192
Type = ImageType . Backdrop ,
193
+ Language = language ,
192
194
} ) ;
193
195
}
194
196
}
195
197
196
198
return list ;
197
199
}
198
200
199
- private async Task < IEnumerable < RemoteImageInfo > > GetLogos ( BaseItem item , string imageLanguages , CancellationToken cancellationToken )
201
+ private async Task < IEnumerable < RemoteImageInfo > > GetLogos ( BaseItem item , string alternativeImageLanguage , CancellationToken cancellationToken )
200
202
{
201
203
var tmdbId = item . GetProviderId ( MetadataProvider . Tmdb ) ;
202
204
var list = new List < RemoteImageInfo > ( ) ;
203
205
var language = item . GetPreferredMetadataLanguage ( ) ;
204
206
if ( this . config . EnableTmdbLogo && ! string . IsNullOrEmpty ( tmdbId ) )
205
207
{
206
- this . Log ( "GetLogos from tmdb id: {0} lang: {1} " , tmdbId , imageLanguages ) ;
208
+ this . Log ( "GetLogos from tmdb id: {0}" , tmdbId ) ;
207
209
var movie = await this . _tmdbApi
208
- . GetMovieAsync ( tmdbId . ToInt ( ) , language , imageLanguages , cancellationToken )
210
+ . GetMovieAsync ( tmdbId . ToInt ( ) , null , null , cancellationToken )
209
211
. ConfigureAwait ( false ) ;
210
212
211
213
if ( movie != null && movie . Images != null )
@@ -224,7 +226,9 @@ private async Task<IEnumerable<RemoteImageInfo>> GetLogos(BaseItem item, string
224
226
}
225
227
}
226
228
227
- return list . OrderByLanguageDescending ( language ) ;
229
+ // TODO:jellyfin 内部判断取哪个图片时,还会默认使用 OrderByLanguageDescending 排序一次,这里排序没用
230
+ // 默认图片优先级是:默认语言 > 无语言 > en > 其他语言
231
+ return this . AdjustImageLanguagePriority ( list , language , alternativeImageLanguage ) ;
228
232
}
229
233
230
234
}
0 commit comments