public static void MakeIndex() { var artists = new Dictionary <string, int>(); var groups = new Dictionary <string, int>(); var series = new Dictionary <string, int>(); var characters = new Dictionary <string, int>(); var languages = new Dictionary <string, int>(); var types = new Dictionary <string, int>(); var tags = new Dictionary <string, int>(); foreach (var md in HitomiData.Instance.metadata_collection) { add(artists, md.Artists); add(groups, md.Groups); add(series, md.Parodies); add(characters, md.Characters); if (md.Language != null) { add(languages, md.Language.ToLower()); } else { add(languages, md.Language); } if (md.Type != null) { add(types, md.Type.ToLower()); } else { add(types, md.Type); } add(tags, md.Tags); } var index = new HitomiIndexModel(); index.Artists = pp(artists); index.Groups = pp(groups); index.Series = pp(series); index.Characters = pp(characters); index.Languages = pp(languages); index.Types = pp(types); index.Tags = pp(tags); var mdl = new List <HitomiIndexMetadata>(); foreach (var md in HitomiData.Instance.metadata_collection) { var him = new HitomiIndexMetadata(); him.ID = md.ID; him.Name = md.Name; if (md.Artists != null) { him.Artists = md.Artists.Select(x => artists[x]).ToArray(); } if (md.Groups != null) { him.Groups = md.Groups.Select(x => groups[x]).ToArray(); } if (md.Parodies != null) { him.Parodies = md.Parodies.Select(x => series[x]).ToArray(); } if (md.Characters != null) { him.Characters = md.Characters.Select(x => characters[x]).ToArray(); } if (md.Language != null) { him.Language = languages[md.Language.ToLower()]; } else { him.Language = -1; } if (md.Type != null) { him.Type = types[md.Type.ToLower()]; } else { him.Type = -1; } if (md.Tags != null) { him.Tags = md.Tags.Select(x => tags[x]).ToArray(); } mdl.Add(him); } var result = new HitomiIndexDataModel(); result.index = index; result.metadata = mdl; var bbb = MessagePackSerializer.Serialize(result); using (FileStream fsStream = new FileStream("index-metadata.json", FileMode.Create)) using (BinaryWriter sw = new BinaryWriter(fsStream)) { sw.Write(bbb); } }
public static (HitomiIndexModel, List <HitomiIndexMetadata>) MakeIndexF() { var artists = new Dictionary <string, int>(); var groups = new Dictionary <string, int>(); var series = new Dictionary <string, int>(); var characters = new Dictionary <string, int>(); var languages = new Dictionary <string, int>(); var types = new Dictionary <string, int>(); var tags = new Dictionary <string, int>(); foreach (var md in HitomiData.Instance.metadata_collection) { add(artists, md.Artists); add(groups, md.Groups); add(series, md.Parodies); add(characters, md.Characters); if (md.Language != null) { add(languages, md.Language.ToLower()); } else { add(languages, md.Language); } if (md.Type != null) { add(types, md.Type.ToLower()); } else { add(types, md.Type); } add(tags, md.Tags); } var index = new HitomiIndexModel(); index.Artists = pp(artists); index.Groups = pp(groups); index.Series = pp(series); index.Characters = pp(characters); index.Languages = pp(languages); index.Types = pp(types); index.Tags = pp(tags); var mdl = new List <HitomiIndexMetadata>(); foreach (var md in HitomiData.Instance.metadata_collection) { var him = new HitomiIndexMetadata(); him.ID = md.ID; him.Name = md.Name; if (md.Artists != null) { him.Artists = md.Artists.Select(x => artists[x]).ToArray(); } if (md.Groups != null) { him.Groups = md.Groups.Select(x => groups[x]).ToArray(); } if (md.Parodies != null) { him.Parodies = md.Parodies.Select(x => series[x]).ToArray(); } if (md.Characters != null) { him.Characters = md.Characters.Select(x => characters[x]).ToArray(); } if (md.Language != null) { him.Language = languages[md.Language.ToLower()]; } else { him.Language = -1; } if (md.Type != null) { him.Type = types[md.Type.ToLower()]; } else { him.Type = -1; } if (md.Tags != null) { him.Tags = md.Tags.Select(x => tags[x]).ToArray(); } him.DateTime = md.DateTime; mdl.Add(him); } return(index, mdl); }