Skip to content

Commit

Permalink
- Fixed searching for titles with '&', '/' in the name. Probably need…
Browse files Browse the repository at this point in the history
… to add more later.

- Fixed crude japanese detection for some games.
- Updated readme.
  • Loading branch information
KirovAir committed Sep 30, 2019
1 parent c6c725b commit 7475c08
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 20 deletions.
31 changes: 17 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
![Screenshot](https://github.com/KirovAir/TwilightBoxart/raw/master/img/screenshot.png)
![Screenshot](https://github.com/KirovAir/TwilightBoxart/raw/master/img/screenshot.png)

# Twilight Boxart
A boxart downloader written in C#. Uses various sources and scan methods to determine the correct boxart.
Written for TwilightMenu++ but can be used for other loader UI's with some config changes. 😊
Written for [TwilightMenu++](https://github.com/DS-Homebrew/TWiLightMenu) but can be used for other loader UI's with some config changes. 😊

## Supported rom types
* Nintendo - Game Boy
* Nintendo - Game Boy Color
* Nintendo - Game Boy Advance
* Nintendo - Nintendo DS
* Nintendo - Nintendo DSi
* Nintendo - Nintendo DSi (DSiWare)
* Nintendo - Nintendo Entertainment System
* Nintendo - Super Nintendo Entertainment System
* Sega - Mega Drive - Genesis
* Sega - Master System - Mark III
* Sega - Game Gear
System | Matching (in order)
--- | ---
Nintendo - Game Boy | (sha1 / filename)
Nintendo - Game Boy Color | (sha1 / filename)
Nintendo - Game Boy Advance | (sha1 / filename)
Nintendo - Nintendo DS | (titleid / sha1 / filename)
Nintendo - Nintendo DSi | (titleid / sha1 / filename)
Nintendo - Nintendo DSi (DSiWare) | (titleid / sha1 / filename)
Nintendo - Nintendo Entertainment System | (sha1 / filename)
Nintendo - Super Nintendo Entertainment System | (sha1 / filename)
Nintendo - Family Computer Disk System | (sha1 / filename)
Sega - Mega Drive - Genesis | (sha1 / filename)
Sega - Master System - Mark III | (sha1 / filename)
Sega - Game Gear | (sha1 / filename)

## Boxart sources
* [GameTDB](https://gametdb.com) using titleid matching.
* [LibRetro](https://github.com/libretro/libretro-thumbnails) using [NoIntro](https://datomatic.no-intro.org) sha1 matching.
* [LibRetro](https://github.com/libretro/libretro-thumbnails) using [NoIntro](https://datomatic.no-intro.org) sha1 matching or simply filename matching. [LibRetro DAT](https://github.com/libretro/libretro-database/tree/master/dat) is currently added as extra NES sha1 source.

## Download
[Here](https://github.com/KirovAir/TwilightBoxart/releases).
Expand Down
4 changes: 2 additions & 2 deletions TwilightBoxart/BoxartCrawler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public void DownloadArt(string romsPath, string boxArtPath, int defaultWidth, in
{
if (rom.ConsoleType == ConsoleType.SuperNintendoEntertainmentSystem)
{
if ((rom.NoIntroName?.ToLower().EndsWith("(japan)") ?? false) ||
(rom.SearchName?.ToLower().EndsWith("(japan)") ?? false))
if ((rom.NoIntroName?.ToLower().Contains("(japan)") ?? false) ||
(rom.SearchName?.ToLower().Contains("(japan)") ?? false))
{
size = new Size(84, 115);
}
Expand Down
1 change: 0 additions & 1 deletion TwilightBoxart/Helpers/StringExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Linq;
using KirovAir.Core.Utilities;

namespace KirovAir.Core.Extensions
{
Expand Down
9 changes: 7 additions & 2 deletions TwilightBoxart/Models/Base/LibRetroRom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,24 @@ public override void DownloadBoxArt(string targetFile)
}
catch
{
if (NoIntroName == SearchName)
{
throw new NoMatchException("Nothing was found! (Using sha1/filename)");
}
// Else try filename.
DownloadByName(targetFile);
}
}

private void DownloadByName(string targetFile)
{

try
{
DownloadWithRetry(SearchName, targetFile);
}
catch
{
throw new NoMatchException("Could not match rom using sha1 or filename.. Skipping.");
throw new NoMatchException("Nothing was found! (Using sha1/filename)");
}
}

Expand Down Expand Up @@ -67,6 +70,8 @@ private void Download(ConsoleType consoleType, string name, string targetFile)
// We can generate the LibRetro content url based on the NoIntroDb name.
var consoleStr = consoleType.GetDescription().Replace(" ", "_");
var url = $"https://github.com/libretro-thumbnails/{consoleStr}/raw/master/Named_Boxarts/";
name = name.Replace("&", "_"); // Todo: There are probably more replacements going on, search & add them.
name = name.Replace("/", "_");
url = FileHelper.CombineUri(url, $"{name}.png");
ImgDownloader.DownloadAndResize(url, targetFile);
}
Expand Down
13 changes: 12 additions & 1 deletion TwilightBoxart/Models/Base/Rom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,18 @@ public class Rom : IRom
public virtual ConsoleType ConsoleType { get; set; }
public string NoIntroName { get; set; }
public ConsoleType NoIntroConsoleType { get; set; }
public string SearchName => !string.IsNullOrEmpty(FileName) ? Path.GetFileNameWithoutExtension(FileName?.Replace(".lz77", "")) : null;
public string SearchName
{
get
{
if (string.IsNullOrEmpty(FileName))
return null;

var name = Path.GetFileNameWithoutExtension(FileName?.Replace(".lz77", ""));
return name;
}
}

internal ImgDownloader ImgDownloader { get; set; }

public static IRom FromStream(Stream stream, string filename)
Expand Down

0 comments on commit 7475c08

Please sign in to comment.