blob: 416ada42cff0e872fcaaf637bdf12602c1fe2c75 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Entities;
using System.Collections.Generic;
namespace MediaBrowser.Providers
{
public static class ProviderUtils
{
public static void MergeBaseItemData(BaseItem source, BaseItem target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{
if (!lockedFields.Contains(MetadataFields.Name))
{
if (replaceData || string.IsNullOrEmpty(target.Name))
{
target.Name = source.Name;
}
}
if (replaceData || !target.CommunityRating.HasValue)
{
target.CommunityRating = source.CommunityRating;
}
if (replaceData || !target.EndDate.HasValue)
{
target.EndDate = source.EndDate;
}
if (!lockedFields.Contains(MetadataFields.Genres))
{
if (replaceData || target.Genres.Count == 0)
{
target.Genres = source.Genres;
}
}
if (replaceData || string.IsNullOrEmpty(target.HomePageUrl))
{
target.HomePageUrl = source.HomePageUrl;
}
if (replaceData || !target.IndexNumber.HasValue)
{
target.IndexNumber = source.IndexNumber;
}
if (!lockedFields.Contains(MetadataFields.OfficialRating))
{
if (replaceData || string.IsNullOrEmpty(target.OfficialRating))
{
target.OfficialRating = source.OfficialRating;
}
}
if (replaceData || string.IsNullOrEmpty(target.OfficialRatingDescription))
{
target.OfficialRatingDescription = source.OfficialRatingDescription;
}
if (!lockedFields.Contains(MetadataFields.Overview))
{
if (replaceData || string.IsNullOrEmpty(target.Overview))
{
target.Overview = source.Overview;
}
}
if (replaceData || !target.ParentIndexNumber.HasValue)
{
target.ParentIndexNumber = source.ParentIndexNumber;
}
if (!lockedFields.Contains(MetadataFields.Cast))
{
if (replaceData || target.People.Count == 0)
{
target.People = source.People;
}
}
if (replaceData || !target.PremiereDate.HasValue)
{
target.PremiereDate = source.PremiereDate;
}
if (replaceData || !target.ProductionYear.HasValue)
{
target.ProductionYear = source.ProductionYear;
}
if (!lockedFields.Contains(MetadataFields.Runtime))
{
if (replaceData || !target.RunTimeTicks.HasValue)
{
target.RunTimeTicks = source.RunTimeTicks;
}
}
if (!lockedFields.Contains(MetadataFields.Studios))
{
if (replaceData || target.Studios.Count == 0)
{
target.Studios = source.Studios;
}
}
if (replaceData || !target.VoteCount.HasValue)
{
target.VoteCount = source.VoteCount;
}
foreach (var id in source.ProviderIds)
{
target.ProviderIds[id.Key] = id.Value;
}
if (mergeMetadataSettings)
{
target.ForcedSortName = source.ForcedSortName;
target.LockedFields = source.LockedFields;
target.DontFetchMeta = source.DontFetchMeta;
target.DisplayMediaType = source.DisplayMediaType;
}
}
}
}
|