Skip to content

Commit

Permalink
添加影人简介
Browse files Browse the repository at this point in the history
  • Loading branch information
AlifeLine committed Aug 21, 2021
1 parent b3fc32a commit 65f6728
Show file tree
Hide file tree
Showing 15 changed files with 563 additions and 27 deletions.
Binary file modified .vs/Emby.Plugins.Douban/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file modified .vs/Emby.Plugins.Douban/v16/.suo
Binary file not shown.
45 changes: 25 additions & 20 deletions Configuration/configPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,25 @@
<input id="MinRequestInternalMs" name="MinRequestInternalMs" type="number" is="emby-input" min="0" />
<div class="fieldDescription">最小请求间隔,单位为毫秒</div>
</div>
<div class="checkboxContainer checkboxContainer-withDescription">
<label>
<input type="checkbox" is="emby-checkbox" id="isUserLogin" />
<span>模拟登录获取信息,(登录后能获得更多的信息推荐登录)</span>
</label>
<div class="fieldDescription checkboxFieldDescription"></div>
</div>
<div class="inputContainer">
<label class="inputeLabel inputLabelUnfocused" for="username">手机号/邮箱</label>
<input id="username" name="username" type="number" is="emby-input" min="0" />
<div class="fieldDescription">豆瓣登录的手机号或者邮箱,没有请先注册</div>
<div>
<div class="checkboxContainer checkboxContainer-withDescription">
<label>
<input type="checkbox" is="emby-checkbox" id="isUserLogin" />
<span>模拟登录获取信息,(登录后能获得更多的信息推荐登录)</span>
</label>
<div class="fieldDescription checkboxFieldDescription"></div>
</div>
<div class="inputContainer">
<label class="inputLabel inputLabel-float inputLabelUnfocused" for="douabnusername">手机号/邮箱:</label>
<input is="emby-input" id="douabnusername" name="douabnusername" class="emby-input" label="手机号/邮箱:">
<div class="fieldDescription">豆瓣登录的手机号或者邮箱,没有请先注册</div>
</div>

<label class="inputeLabel inputLabelUnfocused" for="password">密码</label>
<input id="password" name="password" type="number" is="emby-input" min="0" />
<div class="fieldDescription">不能使用短信验证码,请输入你的密码</div>
<div class="inputContainer">
<label class="inputLabel inputLabel-float inputLabelUnfocused" for="douabnpassword">密码:</label>
<input is="emby-input" id="douabnpassword" name="douabnpassword" class="emby-input" label="密码:">
<div class="fieldDescription">不能使用短信验证码,请输入你的密码</div>
</div>
</div>
<div>
<button is="emby-button" type="submit" class="raised button-submit block emby-button">
Expand All @@ -45,12 +49,13 @@
};

$('#DoubanProviderConfigPage').on('pageshow', function () {
var page = this;
Dashboard.showLoadingMsg();
ApiClient.getPluginConfiguration(DoubanProviderConfig.pluginUniqueId).then(function (config) {
$('#MinRequestInternalMs').val(config.MinRequestInternalMs).change();
$('#username').val(config.doubanPhoneorEmail).change();
$('#password').val(config.password).change();
$('#isUserLogin').val(config.isUserLogin).change();
$('#douabnusername').val(config.doubanPhoneorEmail).change();
$('#douabnpassword').val(config.doubanPassword).change();
page.querySelector('#isUserLogin').checked = config.isUserLogin;
Dashboard.hideLoadingMsg();
});
});
Expand All @@ -59,9 +64,9 @@
Dashboard.showLoadingMsg();
ApiClient.getPluginConfiguration(DoubanProviderConfig.pluginUniqueId).then(function (config) {
config.MinRequestInternalMs = $('#MinRequestInternalMs').val();
config.doubanPhoneorEmail = $('#username').val();
config.password = $('#password').val();
config.isUserLogin = $('#isUserLogin').val();
config.doubanPhoneorEmail = $('#douabnusername').val();
config.doubanPassword = $('#douabnpassword').val();
config.isUserLogin = $('#isUserLogin').prop('checked');
ApiClient.updatePluginConfiguration(DoubanProviderConfig.pluginUniqueId, config).then(function (result) {
Dashboard.processPluginConfigurationUpdateResult(result);
});
Expand Down
22 changes: 17 additions & 5 deletions Providers/BaseProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ public Task<HttpResponseMessage> GetImageResponse(string url,
MediaType type = typeof(T) == typeof(Movie) ? MediaType.movie : MediaType.tv;
return await _doubanClient.GetSubject(sid, type, cancellationToken);
}

protected async Task<Response.ElessarSubject> getPersonInfo(string doubanId,
CancellationToken cancellationToken)
{
return await _doubanClient.getPersonInfo(doubanId, cancellationToken);
}
protected async Task<MetadataResult<T>> GetMetadata<T>(string sid, CancellationToken cancellationToken)
where T : BaseItem, new()
{
Expand All @@ -109,11 +113,12 @@ protected async Task<MetadataResult<T>> GetMetadata<T>(string sid, CancellationT
var subjectCredits=await _doubanClient.GetSubjectCredits(sid, type, cancellationToken);
result.Item = TransMediaInfo<T>(subject);
result.Item.SetProviderId(ProviderID, sid);
TransPersonInfo(subjectCredits.credits.ElementAt(0).celebrities, PersonType.Director).ForEach(result.AddPerson);
TransPersonInfo(subjectCredits.credits.ElementAt(1).celebrities, PersonType.Actor).ForEach(result.AddPerson);
var tt1 = TransPersonInfo(subjectCredits.credits[0].celebrities, PersonType.Director);
var tt2 = TransPersonInfo(subjectCredits.credits[1].celebrities, PersonType.Director);
TransPersonInfo(subjectCredits.credits[0].celebrities, PersonType.Director).ForEach(result.AddPerson);
TransPersonInfo(subjectCredits.credits[1].celebrities, PersonType.Actor).ForEach(result.AddPerson);
result.QueriedById = true;
result.HasMetadata = true;

return result;
}

Expand Down Expand Up @@ -156,7 +161,14 @@ private static List<PersonInfo> TransPersonInfo(
var result = new List<PersonInfo>();
foreach (var Celebrities in CelebritiesList)
{
if (Celebrities.name == "")
{
continue;
}
var role = Regex.Replace(Celebrities.character, @"(.*\()(.*)(\).*)", "$2");
var uri = Celebrities.uri;
string[] str2 = uri.Split('=');
var personId = str2[str2.Length-1];
var personInfo = new PersonInfo
{
Name = Celebrities.name,
Expand All @@ -165,7 +177,7 @@ private static List<PersonInfo> TransPersonInfo(
Role = role?? Celebrities.character
};

personInfo.SetProviderId(ProviderID, Celebrities.id);
personInfo.SetProviderId(ProviderID, personId);
result.Add(personInfo);
}
return result;
Expand Down
22 changes: 22 additions & 0 deletions Providers/FrodoAndroidClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,28 @@ public FrodoAndroidClient(IJsonSerializer jsonSerializer,
_logger.LogCallerInfo($"Finish doing GetSubject by Id: {doubanID}");
return subject;
}
public async Task<Response.ElessarSubject> getPersonInfo(string doubanID, CancellationToken cancellationToken)
{
_logger.LogCallerInfo($"Start to elessarSubject by Id: {doubanID}");

string path = $"/api/v2/elessar/subject/{doubanID}";
// Try to use cache firstly.
if (_cache.TryGet<Response.ElessarSubject>(path, out Response.ElessarSubject elessarSubject))
{
_logger.LogCallerInfo($"Get subject {doubanID} from cache");
return elessarSubject;
}

Dictionary<string, string> queryParams = new Dictionary<string, string>();
var contentStream = await GetResponse(path, queryParams, cancellationToken);
//_logger.LogCallerInfo($"SubjectCredits: {contentStream}");
elessarSubject = _jsonSerializer.DeserializeFromString<Response.ElessarSubject>(contentStream);
// Add it into cache
_cache.Add(path, elessarSubject);

_logger.LogCallerInfo($"Finish doing elessarSubject by Id: {doubanID}");
return elessarSubject;
}
public async Task<Response.SubjectCredits> GetSubjectCredits(string doubanID, MediaType type, CancellationToken cancellationToken)
{
_logger.LogCallerInfo($"Start to SubjectCredits by Id: {doubanID}");
Expand Down
2 changes: 1 addition & 1 deletion Providers/IDoubanClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public interface IDoubanClient
public Task<Response.Subject> GetSubject(string doubanID, MediaType type,
CancellationToken cancellationToken);
public Task<Response.SubjectCredits> GetSubjectCredits(string doubanID, MediaType type, CancellationToken cancellationToken);

public Task<Response.ElessarSubject> getPersonInfo(string doubanID, CancellationToken cancellationToken);
/// <summary>
/// Search in Douban by a search query.
/// </summary>
Expand Down
228 changes: 228 additions & 0 deletions Providers/Response/ElessarSubject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Emby.Plugins.Douban.Response
{
//如果好用,请收藏地址,帮忙分享。
public class Extra
{
/// <summary>
///
/// </summary>
public List<List<string>> info { get; set; }
/// <summary>
/// 演员 美术 配音 其它 / 一出好戏 非诚勿扰2 全民目击
/// </summary>
public string short_info { get; set; }
/// <summary>
///
/// </summary>
public string header_img { get; set; }
}

public class Cover_img
{
/// <summary>
///
/// </summary>
public string url { get; set; }
/// <summary>
///
/// </summary>
public int width { get; set; }
/// <summary>
///
/// </summary>
public string id { get; set; }
/// <summary>
///
/// </summary>
public int height { get; set; }
}

public class Rating_group
{
/// <summary>
///
/// </summary>
public Rating rating { get; set; }
/// <summary>
///
/// </summary>
public string null_rating_reason { get; set; }
}

public class Large
{
/// <summary>
///
/// </summary>
public string url { get; set; }
/// <summary>
///
/// </summary>
public int width { get; set; }
/// <summary>
///
/// </summary>
public int height { get; set; }
}

public class Normal
{
/// <summary>
///
/// </summary>
public string url { get; set; }
/// <summary>
///
/// </summary>
public int width { get; set; }
/// <summary>
///
/// </summary>
public int height { get; set; }
}

public class Cover
{
/// <summary>
///
/// </summary>
public Large large { get; set; }
/// <summary>
///
/// </summary>
public Normal normal { get; set; }
}

public class Color_scheme
{
/// <summary>
///
/// </summary>
public string is_dark { get; set; }
/// <summary>
///
/// </summary>
public string primary_color_light { get; set; }
/// <summary>
///
/// </summary>
public List<double> _base_color { get; set; }
/// <summary>
///
/// </summary>
public string secondary_color { get; set; }
/// <summary>
///
/// </summary>
public List<double> _avg_color { get; set; }
/// <summary>
///
/// </summary>
public string primary_color_dark { get; set; }
}
public class WorksItem
{
/// <summary>
///
/// </summary>
public List<string> roles { get; set; }
/// <summary>
///
/// </summary>
public Subject subject { get; set; }
}

public class CollectionsItem
{
/// <summary>
///
/// </summary>
public int total { get; set; }
/// <summary>
///
/// </summary>
public List<WorksItem> works { get; set; }
/// <summary>
///
/// </summary>
public string id { get; set; }
/// <summary>
/// 影视
/// </summary>
public string title { get; set; }
}

public class Payload
{
/// <summary>
///
/// </summary>
public List<CollectionsItem> collections { get; set; }
/// <summary>
///
/// </summary>
public string id { get; set; }
/// <summary>
/// 作品集
/// </summary>
public string title { get; set; }
}

public class ModulesItem
{
/// <summary>
///
/// </summary>
public string type { get; set; }
/// <summary>
///
/// </summary>
public Payload payload { get; set; }
}


public class ElessarSubject
{
/// <summary>
///
/// </summary>
public Extra extra { get; set; }
/// <summary>
///
/// </summary>
public Cover_img cover_img { get; set; }
/// <summary>
/// 孙红雷
/// </summary>
public string title { get; set; }
/// <summary>
///
/// </summary>
public Cover cover { get; set; }
/// <summary>
///
/// </summary>
public string uri { get; set; }
/// <summary>
///
/// </summary>
public string latin_title { get; set; }
/// <summary>
///
/// </summary>
public string url { get; set; }
/// <summary>
///
/// </summary>
public string id { get; set; }
/// <summary>
///
/// 简介
/// </summary>
public string desc { get; set; }
}
}
Loading

0 comments on commit 65f6728

Please sign in to comment.