Skip to content

Commit

Permalink
Added alternate image source URL for LibRetro (also, Happy New Year!)
Browse files Browse the repository at this point in the history
  • Loading branch information
CatmanFan committed Jan 1, 2025
1 parent 3faec55 commit 7f57516
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions FriishProduce/_classes/Databases/LibRetro.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ private static string db_url(int i)

else return null;
}

private static string db_img(string name, int source = 0)
{
return source == 1
? "https://archive.org/download/No-Intro_Thumbnails_2016-04-10/" + Uri.EscapeUriString(db_name) + ".zip/" + Uri.EscapeUriString(db_name) + "/Named_Titles/" + Uri.EscapeUriString(name.Replace('/', '_').Replace('&', '_')) + ".png"
: "https://thumbnails.libretro.com/" + Uri.EscapeUriString(db_name) + "/Named_Titles/" + Uri.EscapeUriString(name.Replace('/', '_').Replace('&', '_') + ".png");
}
#endregion

public static DataTable Parse(Platform In)
Expand Down Expand Up @@ -151,7 +158,7 @@ public static DataTable Parse(Platform In)
if (name == null && (line.Contains("name \"") || line.Contains("comment \"")) && !line.Contains("rom ("))
{
name = line.Replace("\t", "").Replace("name \"", "").Replace("comment \"", "").Replace("\"", "");
image = "https://archive.org/download/No-Intro_Thumbnails_2016-04-10/" + Uri.EscapeUriString(db_name) + ".zip/" + Uri.EscapeUriString(db_name) + "/Named_Titles/" + Uri.EscapeUriString(name.Replace('/', '_')) + ".png";
image = db_img(name);
}

if (line.Contains("year "))
Expand Down Expand Up @@ -241,7 +248,20 @@ public static (string Name, string Serial, string Year, string Players, string I
// Do something
}
}
catch { rows[0][5] = null; }
catch
{
rows[0][5] = db_img(rows[0][1]?.ToString(), 1);

try
{
using (WebClient c = new WebClient())
using (Stream s = c.OpenRead(rows[0][5]?.ToString()))
{
// Do something
}
}
catch { rows[0][5] = null; }
}

return (rows[0][1]?.ToString(), rows[0][2]?.ToString(), rows[0][3]?.ToString(), rows[0][4]?.ToString(), rows[0][5]?.ToString());
}
Expand Down

0 comments on commit 7f57516

Please sign in to comment.