tweak mc import to cover all available games

This commit is contained in:
13xforever 2020-04-03 18:46:31 +05:00
parent 2cf25f069a
commit c1d1c612be
5 changed files with 182 additions and 14 deletions

View File

@ -508,10 +508,28 @@ namespace CompatBot.Commands
} }
var json = File.ReadAllText(scoreJson); var json = File.ReadAllText(scoreJson);
var scoreList = JsonConvert.DeserializeObject<Metacritic[]>(json); var scoreList = JsonConvert.DeserializeObject<List<Metacritic>>(json);
Config.Log.Debug($"Importing {scoreList.Length} Metacritic items"); Config.Log.Debug($"Importing {scoreList.Count} Metacritic items");
var duplicates = new List<Metacritic>();
duplicates.AddRange(
scoreList.Where(i => i.Title.StartsWith("Disney") || i.Title.StartsWith("DreamWorks") || i.Title.StartsWith("PlayStation"))
.Select(i => i.WithTitle(i.Title.Split(' ', 2)[1]))
);
duplicates.AddRange(
scoreList.Where(i => i.Title.Contains("A Telltale Game"))
.Select(i => i.WithTitle(i.Title.Substring(0, i.Title.IndexOf("A Telltale Game") - 1).TrimEnd(' ', '-', ':')))
);
duplicates.AddRange(
scoreList.Where(i => i.Title.StartsWith("MLB "))
.Select(i => i.WithTitle($"Major League Baseball {i.Title[4..]}"))
);
duplicates.AddRange(
scoreList.Where(i => i.Title.Contains("HAWX"))
.Select(i => i.WithTitle(i.Title.Replace("HAWX", "H.A.W.X")))
);
using var db = new ThumbnailDb(); using var db = new ThumbnailDb();
foreach (var mcScore in scoreList.Where(s => s.CriticScore.HasValue || s.UserScore.HasValue)) foreach (var mcScore in scoreList.Where(s => s.CriticScore > 0 || s.UserScore > 0))
{ {
if (Config.Cts.IsCancellationRequested) if (Config.Cts.IsCancellationRequested)
return; return;
@ -526,13 +544,8 @@ namespace CompatBot.Commands
item.Notes = mcScore.Notes; item.Notes = mcScore.Notes;
} }
await db.SaveChangesAsync().ConfigureAwait(false); await db.SaveChangesAsync().ConfigureAwait(false);
var title = mcScore.Title; var title = mcScore.Title;
if (title.StartsWith("Disney*Pixar") || title.StartsWith("DreamWorks"))
title = title.Split(' ', 2)[1];
else if (title.IndexOf("A Telltale Game") > 0)
title = title.Substring(0, title.IndexOf("A Telltale Game") - 1).TrimEnd(' ', '-', ':');
var matches = db.Thumbnail var matches = db.Thumbnail
.Where(t => t.MetacriticId == null) .Where(t => t.MetacriticId == null)
.AsEnumerable() .AsEnumerable()

View File

@ -109,6 +109,25 @@ namespace CompatBot.Commands
} }
} }
[Command("title_marks"), Aliases("trademarks", "tms")]
[Description("Strips trade marks and similar cruft from game titles in local database")]
public async Task TitleMarks(CommandContext ctx)
{
var changed = 0;
using var db = new ThumbnailDb();
foreach (var thumb in db.Thumbnail)
{
var newTitle = thumb.Name.StripMarks();
if (newTitle != thumb.Name)
{
changed++;
thumb.Name = newTitle;
}
}
await db.SaveChangesAsync();
await ctx.RespondAsync($"Fixed {changed} title{(changed == 1 ? "" : "s")}").ConfigureAwait(false);
}
public static async Task<string> FixChannelMentionAsync(CommandContext ctx, string msg) public static async Task<string> FixChannelMentionAsync(CommandContext ctx, string msg)
{ {
if (string.IsNullOrEmpty(msg)) if (string.IsNullOrEmpty(msg))

View File

@ -105,5 +105,16 @@ namespace CompatBot.Database
public byte? CriticScore { get; set; } public byte? CriticScore { get; set; }
public byte? UserScore { get; set; } public byte? UserScore { get; set; }
public string Notes { get; set; } public string Notes { get; set; }
public Metacritic WithTitle(string title)
{
return new Metacritic
{
Title = title,
CriticScore = CriticScore,
UserScore = UserScore,
Notes = Notes,
};
}
} }
} }

View File

@ -39,10 +39,13 @@ namespace CompatBot.Utils
public static string StripMarks(this string str) public static string StripMarks(this string str)
{ {
return str?.Replace("(R)", "", StringComparison.InvariantCultureIgnoreCase) return str?.Replace("(R)", " ", StringComparison.InvariantCultureIgnoreCase)
.Replace("®", "") .Replace("®", " ")
.Replace("(TM)", "", StringComparison.InvariantCultureIgnoreCase) .Replace("(TM)", " ", StringComparison.InvariantCultureIgnoreCase)
.Replace("™", ""); .Replace("™", " ")
.Replace(" ", " ")
.Replace(" : ", ": ")
.Trim();
} }
public static string StripQuotes(this string str) public static string StripQuotes(this string str)

View File

@ -453,6 +453,11 @@
"UserScore": 53, "UserScore": 53,
"ReleaseDate": "2014-07-08" "ReleaseDate": "2014-07-08"
}, },
{
"Title": "Another World",
"UserScore": 53,
"ReleaseDate": "2014-07-08"
},
{ {
"Title": "Apache: Air Assault", "Title": "Apache: Air Assault",
"CriticScore": 66, "CriticScore": 66,
@ -909,6 +914,11 @@
"UserScore": 79, "UserScore": 79,
"ReleaseDate": "2016-08-30" "ReleaseDate": "2016-08-30"
}, },
{
"Title": "Attack on Titan - Wings of Freedom",
"UserScore": 79,
"ReleaseDate": "2016-08-30"
},
{ {
"Title": "Auditorium HD", "Title": "Auditorium HD",
"CriticScore": 79, "CriticScore": 79,
@ -4730,6 +4740,11 @@
"UserScore": 70, "UserScore": 70,
"ReleaseDate": "2011-09-13" "ReleaseDate": "2011-09-13"
}, },
{
"Title": "Elemental Monster: Online Card Game",
"UserScore": 70,
"ReleaseDate": "2011-09-13"
},
{ {
"Title": "Elevator Action Deluxe", "Title": "Elevator Action Deluxe",
"CriticScore": 54, "CriticScore": 54,
@ -5175,6 +5190,11 @@
"UserScore": 73, "UserScore": 73,
"ReleaseDate": "2014-09-16" "ReleaseDate": "2014-09-16"
}, },
{
"Title": "Fibbage",
"UserScore": 73,
"ReleaseDate": "2014-09-16"
},
{ {
"Title": "FIFA 14", "Title": "FIFA 14",
"CriticScore": 86, "CriticScore": 86,
@ -5629,6 +5649,7 @@
}, },
{ {
"Title": "Geometry Wars 3: Dimensions Evolved", "Title": "Geometry Wars 3: Dimensions Evolved",
"UserScore": 80,
"ReleaseDate": "2015-03-31" "ReleaseDate": "2015-03-31"
}, },
{ {
@ -7070,6 +7091,11 @@
"UserScore": 69, "UserScore": 69,
"ReleaseDate": "2012-02-07" "ReleaseDate": "2012-02-07"
}, },
{
"Title": "Jak 3",
"UserScore": 69,
"ReleaseDate": "2012-02-07"
},
{ {
"Title": "Jak and Daxter Collection", "Title": "Jak and Daxter Collection",
"CriticScore": 81, "CriticScore": 81,
@ -7086,6 +7112,11 @@
"UserScore": 66, "UserScore": 66,
"ReleaseDate": "2012-02-07" "ReleaseDate": "2012-02-07"
}, },
{
"Title": "Jak II",
"UserScore": 66,
"ReleaseDate": "2012-02-07"
},
{ {
"Title": "JAM Live Music Arcade", "Title": "JAM Live Music Arcade",
"ReleaseDate": "2012-05-15" "ReleaseDate": "2012-05-15"
@ -7228,6 +7259,14 @@
}, },
{ {
"Title": "Jurassic Park: The Game - Episode 1: The Intruder", "Title": "Jurassic Park: The Game - Episode 1: The Intruder",
"CriticScore": 53,
"UserScore": 47,
"ReleaseDate": "2016-03-07"
},
{
"Title": "Jurassic Park: The Game - Episode 1",
"CriticScore": 53,
"UserScore": 47,
"ReleaseDate": "2016-03-07" "ReleaseDate": "2016-03-07"
}, },
{ {
@ -8458,6 +8497,11 @@
"CriticScore": 53, "CriticScore": 53,
"ReleaseDate": "2011-03-25" "ReleaseDate": "2011-03-25"
}, },
{
"Title": "Mayhem",
"CriticScore": 53,
"ReleaseDate": "2011-03-25"
},
{ {
"Title": "Medal of Honor", "Title": "Medal of Honor",
"CriticScore": 75, "CriticScore": 75,
@ -8636,10 +8680,19 @@
"UserScore": 68, "UserScore": 68,
"ReleaseDate": "2010-12-21" "ReleaseDate": "2010-12-21"
}, },
{
"Title": "NEOGEO STATION Metal Slug",
"UserScore": 68,
"ReleaseDate": "2010-12-21"
},
{ {
"Title": "Metal Slug 3", "Title": "Metal Slug 3",
"ReleaseDate": "2015-03-24" "ReleaseDate": "2015-03-24"
}, },
{
"Title": "NEOGEO STATION Metal Slug 3",
"ReleaseDate": "2015-03-24"
},
{ {
"Title": "Metro: Last Light", "Title": "Metro: Last Light",
"CriticScore": 80, "CriticScore": 80,
@ -9897,6 +9950,11 @@
"UserScore": 79, "UserScore": 79,
"ReleaseDate": "2015-04-22" "ReleaseDate": "2015-04-22"
}, },
{
"Title": "Oddworld: New \u0027n\u0027 Tasty",
"UserScore": 79,
"ReleaseDate": "2015-04-22"
},
{ {
"Title": "Oddworld: Munch\u0027s Oddysee HD", "Title": "Oddworld: Munch\u0027s Oddysee HD",
"UserScore": 70, "UserScore": 70,
@ -10036,7 +10094,7 @@
"ReleaseDate": "2010-11-23" "ReleaseDate": "2010-11-23"
}, },
{ {
"Title": "Pac-Man Championship Edition DX \u002B", "Title": "Pac-Man Championship Edition DX\u002B",
"UserScore": 76, "UserScore": 76,
"ReleaseDate": "2013-09-25" "ReleaseDate": "2013-09-25"
}, },
@ -10380,6 +10438,11 @@
"UserScore": 74, "UserScore": 74,
"ReleaseDate": "2013-09-02" "ReleaseDate": "2013-09-02"
}, },
{
"Title": "Port Royale 3 Gold Edition",
"UserScore": 74,
"ReleaseDate": "2013-09-02"
},
{ {
"Title": "Port Royale 3: Pirates and Merchants", "Title": "Port Royale 3: Pirates and Merchants",
"UserScore": 74, "UserScore": 74,
@ -10630,6 +10693,12 @@
"UserScore": 75, "UserScore": 75,
"ReleaseDate": "2010-06-01" "ReleaseDate": "2010-06-01"
}, },
{
"Title": "Pure Football",
"CriticScore": 46,
"UserScore": 75,
"ReleaseDate": "2010-06-01"
},
{ {
"Title": "Puzzle Agent", "Title": "Puzzle Agent",
"CriticScore": 66, "CriticScore": 66,
@ -11062,6 +11131,11 @@
"UserScore": 82, "UserScore": 82,
"ReleaseDate": "2016-01-19" "ReleaseDate": "2016-01-19"
}, },
{
"Title": "Resident Evil 0",
"UserScore": 82,
"ReleaseDate": "2016-01-19"
},
{ {
"Title": "Resident Evil 4 HD", "Title": "Resident Evil 4 HD",
"CriticScore": 84, "CriticScore": 84,
@ -11150,6 +11224,11 @@
"UserScore": 81, "UserScore": 81,
"ReleaseDate": "2015-01-20" "ReleaseDate": "2015-01-20"
}, },
{
"Title": "Resident Evil",
"UserScore": 81,
"ReleaseDate": "2015-01-20"
},
{ {
"Title": "Resident Evil: Chronicles HD Collection", "Title": "Resident Evil: Chronicles HD Collection",
"CriticScore": 70, "CriticScore": 70,
@ -12176,6 +12255,11 @@
"UserScore": 51, "UserScore": 51,
"ReleaseDate": "2015-09-20" "ReleaseDate": "2015-09-20"
}, },
{
"Title": "Skylanders SuperChargers Portal Owner's Pack",
"UserScore": 51,
"ReleaseDate": "2015-09-20"
},
{ {
"Title": "Skylanders Swap Force", "Title": "Skylanders Swap Force",
"CriticScore": 83, "CriticScore": 83,
@ -12344,6 +12428,16 @@
"UserScore": 69, "UserScore": 69,
"ReleaseDate": "2014-07-01" "ReleaseDate": "2014-07-01"
}, },
{
"Title": "Sniper Elite 3",
"UserScore": 69,
"ReleaseDate": "2014-07-01"
},
{
"Title": "Sniper Elite 3 Ultimate Edition",
"UserScore": 69,
"ReleaseDate": "2014-07-01"
},
{ {
"Title": "Sniper Elite V2", "Title": "Sniper Elite V2",
"CriticScore": 70, "CriticScore": 70,
@ -13070,6 +13164,12 @@
"UserScore": 72, "UserScore": 72,
"ReleaseDate": "2007-05-02" "ReleaseDate": "2007-05-02"
}, },
{
"Title": "Super Rub\u0027a\u0027Dub",
"CriticScore": 49,
"UserScore": 72,
"ReleaseDate": "2007-05-02"
},
{ {
"Title": "Super Sidekicks", "Title": "Super Sidekicks",
"ReleaseDate": "2010-12-21" "ReleaseDate": "2010-12-21"
@ -13833,6 +13933,11 @@
"UserScore": 73, "UserScore": 73,
"ReleaseDate": "2012-04-10" "ReleaseDate": "2012-04-10"
}, },
{
"Title": "Pinball Arcade",
"UserScore": 73,
"ReleaseDate": "2012-04-10"
},
{ {
"Title": "The Pinball Arcade: Table Pack 1 - Medieval Madness and The Machine: Bride of Pin-Bot", "Title": "The Pinball Arcade: Table Pack 1 - Medieval Madness and The Machine: Bride of Pin-Bot",
"ReleaseDate": "2012-06-12" "ReleaseDate": "2012-06-12"
@ -14378,6 +14483,11 @@
"UserScore": 71, "UserScore": 71,
"ReleaseDate": "2012-11-06" "ReleaseDate": "2012-11-06"
}, },
{
"Title": "ToeJam and Earl",
"UserScore": 71,
"ReleaseDate": "2012-11-06"
},
{ {
"Title": "ToeJam \u0026 Earl in Panic on Funkotron", "Title": "ToeJam \u0026 Earl in Panic on Funkotron",
"ReleaseDate": "2012-11-06" "ReleaseDate": "2012-11-06"
@ -14995,6 +15105,12 @@
"UserScore": 66, "UserScore": 66,
"ReleaseDate": "2012-11-28" "ReleaseDate": "2012-11-28"
}, },
{
"Title": "Under Defeat HD: Deluxe Edition",
"CriticScore": 73,
"UserScore": 66,
"ReleaseDate": "2012-11-28"
},
{ {
"Title": "Under Night In-Birth Exe:Late", "Title": "Under Night In-Birth Exe:Late",
"CriticScore": 80, "CriticScore": 80,
@ -15393,6 +15509,12 @@
"UserScore": 43, "UserScore": 43,
"ReleaseDate": "2012-04-03" "ReleaseDate": "2012-04-03"
}, },
{
"Title": "Wheels of Destruction",
"CriticScore": 49,
"UserScore": 43,
"ReleaseDate": "2012-04-03"
},
{ {
"Title": "Wheels of Destruction: World Tour - Moscovian Mayhem", "Title": "Wheels of Destruction: World Tour - Moscovian Mayhem",
"ReleaseDate": "2012-06-12" "ReleaseDate": "2012-06-12"