Skip to content

Commit

Permalink
add archive support for subject / person relations
Browse files Browse the repository at this point in the history
  • Loading branch information
kookxiang committed Dec 1, 2024
1 parent 8fb72b4 commit 870fdb9
Show file tree
Hide file tree
Showing 14 changed files with 584 additions and 69 deletions.
6 changes: 5 additions & 1 deletion Jellyfin.Plugin.Bangumi/Archive/ArchiveData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,9 @@ public class ArchiveData(IApplicationPaths paths)

public ArchiveStore<Person> Person => new(BasePath, "person.jsonlines");

public SubjectEpisodeRelation SubjectEpisode => new(this);
public SubjectRelations SubjectRelations => new(this);

public SubjectEpisodeRelation SubjectEpisodeRelation => new(this);

public SubjectPersonRelation SubjectPersonRelation => new(this);
}
202 changes: 202 additions & 0 deletions Jellyfin.Plugin.Bangumi/Archive/Data/RelatedPerson.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace Jellyfin.Plugin.Bangumi.Archive.Data;

public class RelatedPerson
{
[JsonPropertyName("person_id")]
public int PersonId { get; set; }

[JsonPropertyName("position")]
public short Position { get; set; }

public async Task<Model.RelatedPerson> ToRelatedPerson(ArchiveData archive)
{
var person = await archive.Person.FindById(PersonId);

return new Model.RelatedPerson
{
Id = PersonId,
Type = (int)(person?.Type ?? default),
Name = person?.Name ?? "",
Career = person?.Career,

// https://github.com/bangumi/common/blob/master/subject_staffs.yml
Relation = Position switch
{
1 => "原作",
2 => "导演",
3 => "脚本",
4 => "分镜",
5 => "演出",
6 => "音乐",
7 => "人物原案",
8 => "人物设定",
9 => "构图",
10 => "系列构成",
11 => "美术监督",
13 => "色彩设计",
14 => "总作画监督",
15 => "作画监督",
16 => "机械设定",
17 => "摄影监督",
18 => "监修",
19 => "道具设计",
20 => "原画",
21 => "第二原画",
22 => "动画检查",
23 => "助理制片人",
24 => "制作助理",
25 => "背景美术",
26 => "色彩指定",
27 => "数码绘图",
28 => "剪辑",
29 => "原案",
30 => "主题歌编曲",
31 => "主题歌作曲",
32 => "主题歌作词",
33 => "主题歌演出",
34 => "插入歌演出",
35 => "企画",
36 => "企划制作人",
37 => "制作管理",
38 => "宣传",
39 => "录音",
40 => "录音助理",
41 => "系列监督",
42 => "製作",
43 => "设定",
44 => "音响监督",
45 => "音响",
46 => "音效",
47 => "特效",
48 => "配音监督",
49 => "联合导演",
50 => "背景设定",
51 => "补间动画",
52 => "执行制片人",
53 => "助理制片人",
54 => "制片人",
55 => "音乐助理",
56 => "制作进行", // 管理动画的制作时程、协调各部门作业、回收作画原稿等
57 => "演员监督",
58 => "总制片人",
59 => "联合制片人",
60 => "台词编辑",
61 => "后期制片协调",
62 => "制作助理",
63 => "制作",
64 => "制作协调",
65 => "音乐制作",
66 => "特别鸣谢",
67 => "动画制作",
69 => "CG 导演",
70 => "机械作画监督",
71 => "美术设计",
72 => "副导演",
73 => "OP・ED 分镜",
74 => "总导演",
75 => "3DCG",
76 => "制作协力",
77 => "动作作画监督",
80 => "监制",
81 => "协力",
82 => "摄影",
83 => "制作进行协力",
84 => "设定制作", // 有时需要额外的设计工作,联系负责部门并监督工作确保交付
85 => "音乐制作人",
86 => "3DCG 导演",
87 => "动画制片人",
88 => "特效作画监督",
90 => "作画监督助理",
92 => "主动画师",
1001 => "开发",
1002 => "发行",
1003 => "游戏设计师",
1004 => "剧本",
1005 => "美工",
1006 => "音乐",
1007 => "关卡设计",
1008 => "人物设定",
1009 => "主题歌作曲",
1010 => "主题歌作词",
1011 => "主题歌演出",
1012 => "插入歌演出",
1013 => "原画",
1014 => "动画制作",
1015 => "原作",
1016 => "导演",
1017 => "动画监督",
1018 => "制作总指挥",
1019 => "QC",
1020 => "动画剧本",
1021 => "程序",
1022 => "协力",
1023 => "CG 监修",
1024 => "SD原画",
1025 => "背景",
1026 => "监修",
1027 => "系列构成",
1028 => "企画",
1029 => "机械设定",
1030 => "音响监督",
1031 => "作画监督",
1032 => "制作人",
2001 => "作者",
2002 => "作画",
2003 => "插图",
2004 => "出版社",
2005 => "连载杂志",
2006 => "译者",
2007 => "原作",
2008 => "客串",
2009 => "人物原案",
2010 => "脚本",
2011 => "书系",
2012 => "出品方",
3001 => "艺术家",
3002 => "制作人",
3003 => "作曲",
3004 => "厂牌",
3005 => "原作",
3006 => "作词",
3007 => "录音",
3008 => "编曲",
3009 => "插图",
3010 => "脚本",
3011 => "出版方",
3012 => "母带制作",
3013 => "混音",
3014 => "乐器",
3015 => "声乐",
4001 => "原作",
4002 => "导演",
4003 => "编剧",
4004 => "音乐",
4005 => "执行制片人",
4006 => "共同执行制作",
4007 => "制片人/制作人",
4008 => "监制",
4009 => "副制作人/制作顾问",
4010 => "故事",
4011 => "编审",
4012 => "剪辑",
4013 => "创意总监",
4014 => "摄影",
4015 => "主题歌演出",
4016 => "主演",
4017 => "配角",
4018 => "制作",
4019 => "出品",
_ => null
}
};
}
}

public class RelatedPersonRaw : RelatedPerson
{
[JsonPropertyName("subject_id")]
public int SubjectId { get; set; }
}
88 changes: 88 additions & 0 deletions Jellyfin.Plugin.Bangumi/Archive/Data/RelatedSubject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace Jellyfin.Plugin.Bangumi.Archive.Data;

public class RelatedSubject
{
[JsonPropertyName("related_subject_id")]
public int RelatedSubjectId { get; set; }

[JsonPropertyName("relation_type")]
public short RelationType { get; set; }

public async Task<Model.RelatedSubject> ToRelatedSubject(ArchiveData archive)
{
var subject = await archive.Subject.FindById(RelatedSubjectId);

return new Model.RelatedSubject
{
Id = RelatedSubjectId,
Type = subject?.Type ?? default,
OriginalNameRaw = subject?.OriginalName ?? "",
ChineseNameRaw = subject?.ChineseName,

// https://github.com/bangumi/common/blob/master/subject_relations.yml
Relation = RelationType switch
{
1 => "改编", // 同系列不同平台作品(如柯南漫画与动画版)
2 => "前传", // 发生在故事之前
3 => "续集", // 发生在故事之后
4 => "总集篇", // 对故事的概括版本
5 => "全集", // 相对于剧场版/总集篇的完整故事
6 => "番外篇",
7 => "角色出演", // 相同角色,没有关联的故事
8 => "相同世界观", // 发生在同一个世界观/时间线下,不同的出演角色
9 => "不同世界观", // 相同的主演角色,不同的世界观/时间线设定
10 => "不同演绎", // 相同设定、角色,不同的演绎方式(如EVA原作与新剧场版)
11 => "衍生", // 世界观相同,角色主线与有关联或来自主线,但又非主线的主角们
12 => "主线故事",
14 => "联动", // 出现了被关联作品中的角色
99 => "其他",
1002 => "系列",
1003 => "单行本",
1004 => "画集",
1005 => "前传", // 发生在故事之前
1006 => "续集", // 发生在故事之后
1007 => "番外篇",
1008 => "主线故事",
1010 => "不同版本",
1011 => "角色出演", // 相同角色,没有关联的故事
1012 => "相同世界观", // 发生在同一个世界观/时间线下,不同的出演角色
1013 => "不同世界观", // 相同的出演角色,不同的世界观/时间线设定
1014 => "联动", // 出现了被关联作品中的角色
1099 => "其他",
3001 => "原声集",
3002 => "角色歌",
3003 => "片头曲",
3004 => "片尾曲",
3005 => "插入歌",
3006 => "印象曲",
3007 => "广播剧",
3099 => "其他",
4002 => "前传", // 发生在故事之前/或作品发售之前
4003 => "续集", // 发生在故事之后/或作品发售之后
4006 => "外传",
4007 => "角色出演", // 相同角色,没有关联的故事
4008 => "相同世界观", // 发生在同一个世界观/时间线下,不同的出演角色
4009 => "不同世界观", // 相同的出演角色,不同的世界观/时间线设定
4010 => "不同演绎", // 相同设定、角色,不同的演绎方式
4011 => "不同版本", // 相同故事、角色,画面、音乐或系统改进
4012 => "主线故事",
4013 => "主版本", // 游戏最初发售时的版本
4014 => "联动", // 出现了被关联作品中的角色
4015 => "扩展包",
4016 => "合集", // 收录本作品的合集条目
4017 => "收录作品", // 合集条目中收录的作品
4099 => "其他",
_ => null
}
};
}
}

public class RelatedSubjectRaw : RelatedSubject
{
[JsonPropertyName("subject_id")]
public int SubjectId { get; set; }
}
Loading

0 comments on commit 870fdb9

Please sign in to comment.