Skip to content

Commit

Permalink
增加公众评分,目前支持fc2club.net、javdb8.com
Browse files Browse the repository at this point in the history
  • Loading branch information
JavScraper committed Jun 20, 2021
1 parent 33bcef7 commit f414eb1
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Emby.Plugins.JavScraper/JavMovieProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ from p in ps.DefaultIfEmpty()
ForcedSortName = m.Num,
ExternalId = m.Num
};

if (m.CommunityRating >= 0 && m.CommunityRating <= 10)
metadataResult.Item.CommunityRating = m.CommunityRating;

#if !__JELLYFIN__
if (!string.IsNullOrWhiteSpace(m.Set))
metadataResult.Item.AddCollection(m.Set);
Expand Down
16 changes: 15 additions & 1 deletion Emby.Plugins.JavScraper/Scrapers/FC2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private async Task<JavVideo> GetById(string id)
//尝试获取 a 标签的内容
var aa = n.SelectNodes("./a");
var value = aa?.Any() == true ? string.Join(", ", aa.Select(o => o.InnerText.Trim()).Where(o => string.IsNullOrWhiteSpace(o) == false && !o.Contains("本资源")))
: null;
: n.InnerText?.Split(':').Last();

if (string.IsNullOrWhiteSpace(value) == false)
dic[name] = value;
Expand All @@ -161,6 +161,19 @@ string getDate()
return dm.Groups["date"].Value.Replace('/', '-');
}

float? GetCommunityRating()
{
var value = GetValue("影片评分");
if (string.IsNullOrWhiteSpace(value))
return null;
var m = Regex.Match(value, @"(?<rating>[\d.]+)");
if (m.Success == false)
return null;
if (float.TryParse(m.Groups["rating"].Value, out var rating))
return rating / 10.0f;
return null;
}

var samples = node.SelectNodes("//ul[@class='slides']/li/img")?
.Select(o => o.GetAttributeValue("src", null)).Where(o => o != null).Select(o => new Uri(client.BaseAddress, o).ToString()).ToList();
var m = new JavVideo()
Expand All @@ -180,6 +193,7 @@ string getDate()
Genres = genres,
Actors = actors,
Samples = samples,
CommunityRating = GetCommunityRating(),
};
//去除标题中的番号
if (string.IsNullOrWhiteSpace(m.Num) == false && m.Title?.StartsWith(m.Num, StringComparison.OrdinalIgnoreCase) == true)
Expand Down
14 changes: 14 additions & 0 deletions Emby.Plugins.JavScraper/Scrapers/JavDB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,19 @@ List<string> GetActors()
return ac;
}

float? GetCommunityRating()
{
var value = GetValue("評分");
if (string.IsNullOrWhiteSpace(value))
return null;
var m = Regex.Match(value, @"(?<rating>[\d.]+)分");
if (m.Success == false)
return null;
if (float.TryParse(m.Groups["rating"].Value, out var rating))
return rating / 5.0f * 10f;
return null;
}

List<string> GetSamples()
{
return doc.DocumentNode.SelectNodes("//div[@class='tile-images preview-images']/a")
Expand All @@ -243,6 +256,7 @@ List<string> GetSamples()
Genres = GetGenres(),
Actors = GetActors(),
Samples = GetSamples(),
CommunityRating = GetCommunityRating(),
};

m.Plot = await GetDmmPlot(m.Num);
Expand Down
5 changes: 5 additions & 0 deletions Emby.Plugins.JavScraper/Scrapers/JavVideo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ public class JavVideo : JavVideoIndex
/// </summary>
public List<string> Samples { get; set; }

/// <summary>
/// 公众评分 0-10之间。
/// </summary>
public float? CommunityRating { get; set; }

/// <summary>
/// %genre:中文字幕?中文:%
/// </summary>
Expand Down

0 comments on commit f414eb1

Please sign in to comment.