Skip to content

Commit 2e8aad4

Browse files
committed
解决刷新元数据时,封面和背景不刷新的问题。
1 parent ca86e4a commit 2e8aad4

File tree

3 files changed

+26
-21
lines changed

3 files changed

+26
-21
lines changed

Emby.Plugins.JavScraper/Data/ApplicationDbContext.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,19 @@ public JavVideo FindJavVideo(string provider, string url)
118118
else
119119
return Metadata.FindOne(o => o.url == url && o.provider == provider)?.data;
120120
}
121+
122+
/// <summary>
123+
/// 查找视频元数据
124+
/// </summary>
125+
/// <param name="provider"></param>
126+
/// <param name="url"></param>
127+
/// <returns></returns>
128+
public Metadata FindMetadata(string provider, string url)
129+
{
130+
if (string.IsNullOrWhiteSpace(provider))
131+
return Metadata.FindOne(o => o.url == url);
132+
else
133+
return Metadata.FindOne(o => o.url == url && o.provider == provider);
134+
}
121135
}
122136
}

Emby.Plugins.JavScraper/JavImageProvider.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,21 +73,19 @@ DynamicImageResponse GetResult()
7373
return img;
7474
}
7575

76-
if (local != null)
77-
return GetResult();
78-
7976
JavVideoIndex index = null;
8077
if ((index = item.GetJavVideoIndex(_jsonSerializer)) == null)
8178
{
8279
_logger?.Info($"{nameof(GetImage)} name:{item.Name} JavVideoIndex not found.");
8380
return GetResult();
8481
}
8582

86-
JavVideo m = Plugin.Instance.db.FindJavVideo(index.Provider,index.Url);
87-
88-
if (m == null)
83+
var metadata = Plugin.Instance.db.FindMetadata(index.Provider, index.Url);
84+
if (metadata == null || local?.DateModified.ToLocalTime() >= metadata.modified)
8985
return GetResult();
9086

87+
var m = metadata?.data;
88+
9189
if (string.IsNullOrWhiteSpace(m.Cover) && m.Samples?.Any() == true)
9290
m.Cover = m.Samples.FirstOrDefault();
9391

Emby.Plugins.JavScraper/JavMovieProvider.cs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
using System.Collections.Generic;
2222
using System.Linq;
2323
using System.Net;
24-
using System.Net.Http;
25-
using System.Reflection;
2624
using System.Text.RegularExpressions;
2725
using System.Threading;
2826
using System.Threading.Tasks;
@@ -95,20 +93,15 @@ public async Task<MetadataResult<Movie>> GetMetadata(MovieInfo info, Cancellatio
9593
return metadataResult;
9694
}
9795

98-
JavVideo m = null;
99-
if (info.IsAutomated)
100-
m = Plugin.Instance.db.FindJavVideo(index.Provider, index.Url);
101-
102-
if (m == null)
103-
{
104-
var sc = Plugin.Instance.Scrapers.FirstOrDefault(o => o.Name == index.Provider);
105-
if (sc == null)
106-
return metadataResult;
96+
var sc = Plugin.Instance.Scrapers.FirstOrDefault(o => o.Name == index.Provider);
97+
if (sc == null)
98+
return metadataResult;
10799

108-
m = await sc.Get(index);
109-
if (m != null)
110-
Plugin.Instance.db.SaveJavVideo(m);
111-
}
100+
var m = await sc.Get(index);
101+
if (m != null)
102+
Plugin.Instance.db.SaveJavVideo(m);
103+
else
104+
m = Plugin.Instance.db.FindJavVideo(index.Provider, index.Url);
112105

113106
if (m == null)
114107
{

0 commit comments

Comments
 (0)