Skip to content

Commit 2f4077c

Browse files
committed
Added read support for MetronInfo.xml.
It will only read it if the ComicInfo.xml isn't detected. Not all fields are supported, only the one that exists in the ComicInfo.xml. Exporting a file recreates the files, so any xml will be lost. If only a MetronInfo.xml existed it will create a ComicInfo.xml with the values it imported from it.
1 parent 466e220 commit 2f4077c

File tree

3 files changed

+1877
-0
lines changed

3 files changed

+1877
-0
lines changed

ComicRack.Engine/ComicRack.Engine.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<SpecificVersion>False</SpecificVersion>
2323
<HintPath>DLL\sharpPDF.dll</HintPath>
2424
</Reference>
25+
<Reference Include="System.ComponentModel.DataAnnotations" />
2526
<Reference Include="System.IdentityModel" />
2627
<Reference Include="System.ServiceModel" />
2728
<Reference Include="System.Web.Services" />
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Drawing.Text;
4+
using System.IO;
5+
using System.Linq;
6+
using System.Reflection;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
using cYo.Common.Threading;
10+
using cYo.Common.Xml;
11+
12+
namespace cYo.Projects.ComicRack.Engine.IO.Provider.XmlInfo
13+
{
14+
[XmlInfoFile("MetronInfo.xml", 1)]
15+
public class MetronInfoProvider : XmlInfoProvider<MetronInfo>
16+
{
17+
public override ComicInfo ToComicInfo(MetronInfo metronInfo)
18+
{
19+
if (metronInfo == null)
20+
return null;
21+
22+
const string delimiter = ", ";
23+
24+
using (ItemMonitor.Lock(this))
25+
{
26+
ComicInfo comicInfo = new ComicInfo()
27+
{
28+
Publisher = metronInfo.Publisher.Name,
29+
Imprint = metronInfo.Publisher.Imprint.Value,
30+
Writer = string.Join(delimiter, metronInfo.Credits.SelectMany(c =>
31+
c.Roles.Where(r =>
32+
r.Value == RoleValues.Writer ||
33+
r.Value == RoleValues.Plot
34+
).Select(r => c.Creator.Value))),
35+
Penciller = string.Join(delimiter, metronInfo.Credits.SelectMany(c =>
36+
c.Roles.Where(r =>
37+
r.Value == RoleValues.Penciller
38+
).Select(r => c.Creator.Value))),
39+
Inker = string.Join(delimiter, metronInfo.Credits.SelectMany(c =>
40+
c.Roles.Where(r =>
41+
r.Value == RoleValues.Inker ||
42+
r.Value == RoleValues.InkAssists
43+
).Select(r => c.Creator.Value))),
44+
Colorist = string.Join(delimiter, metronInfo.Credits.SelectMany(c =>
45+
c.Roles.Where(r =>
46+
r.Value.ToString().Contains("Color")
47+
).Select(r => c.Creator.Value))),
48+
Editor = string.Join(delimiter, metronInfo.Credits.SelectMany(c =>
49+
c.Roles.Where(r =>
50+
r.Value.ToString().Contains("Editor")
51+
).Select(r => c.Creator.Value))),
52+
Letterer = string.Join(delimiter, metronInfo.Credits.SelectMany(c =>
53+
c.Roles.Where(r =>
54+
r.Value == RoleValues.Letterer
55+
).Select(r => c.Creator.Value))),
56+
CoverArtist = string.Join(delimiter, metronInfo.Credits.SelectMany(c =>
57+
c.Roles.Where(r =>
58+
r.Value == RoleValues.Cover
59+
).Select(r => c.Creator.Value))),
60+
Series = metronInfo.Series.Name,
61+
Number = metronInfo.Number,
62+
Count = metronInfo.Series.IssueCount,
63+
AlternateSeries = metronInfo.Arcs.FirstOrDefault()?.Name,
64+
AlternateNumber = metronInfo.Arcs.FirstOrDefault()?.Number.ToString(),
65+
StoryArc = metronInfo.Stories.FirstOrDefault()?.Value,
66+
Summary = metronInfo.Summary,
67+
Volume = metronInfo.Series?.Volume ?? -1,
68+
Year = metronInfo.CoverDate.Year,
69+
Month = metronInfo.CoverDate.Month,
70+
Day = metronInfo.CoverDate.Day,
71+
Notes = metronInfo.Notes,
72+
Genre = string.Join(delimiter, metronInfo.Genres.Select(g => g.Value)),
73+
Web = metronInfo.UrLs.Where(u => u.Primary)?.FirstOrDefault()?.Value ?? metronInfo.UrLs.FirstOrDefault()?.Value,
74+
PageCount = metronInfo.PageCount,
75+
LanguageISO = metronInfo.Series.Lang,
76+
AgeRating = metronInfo.AgeRating.ToString(),
77+
Characters = string.Join(delimiter, metronInfo.Characters.Select(c => c.Value)),
78+
Teams = string.Join(delimiter, metronInfo.Teams.Select(t => t.Value)),
79+
Locations = string.Join(delimiter, metronInfo.Locations.Select(t => t.Value)),
80+
Tags = string.Join(delimiter, metronInfo.Tags.Select(t => t.Value)),
81+
};
82+
83+
return comicInfo;
84+
}
85+
}
86+
}
87+
}

0 commit comments

Comments
 (0)