Skip to content

Commit

Permalink
Skip EXIF check on unsupported formats
Browse files Browse the repository at this point in the history
  • Loading branch information
corbindavenport committed Jun 11, 2024
1 parent ac8d594 commit ed1754a
Showing 1 changed file with 43 additions and 40 deletions.
83 changes: 43 additions & 40 deletions data/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,51 +96,54 @@
$handle = fopen($filename, "r");
$data = fread($handle, filesize($filename));

// Get EXIF data
$exif = exif_read_data($handle);
if (is_array($exif) && array_key_exists('Model', $exif)) {
// Read software string in 3DS screenshots
// Read software string in 3DS screenshots
if ($exif['Model'] === 'Nintendo 3DS') {
// All the regions from the titlelist
// GB = EUR/PAL
// KR AND TW are Korea and Taiwan
// filenames are titlelist_$region.json
// files from hax0kartik/3dsdb(values retrived from eshop directly)

/*
EACH GAME IN THE JSON IS MADE LIKE THIS:
{
"Name": "Shovel Software Insurance Claim",
"UID": "50010000049535",
"TitleID": "000400000F715C00",
"Version": "N/A",
"Size": "25.7 MB [206 blocks]",
"Product Code": "KTR-N-CF6P",
"Publisher": "Batafurai"
},
BUNCH OF STUFF FOR RATING BUT IT ISN'T WHAT WE SEARCH.(only need names and title id)
the title id is in the attributes of <title> so we have to access via the ->attributes()->id thing.
*/

$regions = ["GB", "JP", "KR", "TW", "US"];
// Match ID with game title if possible
$id = strtoupper($exif['Software']);
foreach($regions as $region) { // FOR EACH REGION!!
$json=json_decode(file_get_contents('titlelist/list_'.$region.'.json'));
foreach($json as $game) {
if ($game->TitleID == '000400000'.$id.'00') {
// Update software name
// Only read EXIF data from JPEG images
if ($img['type'] === 'image/jpeg') {
// Get EXIF data
$exif = exif_read_data($handle);
if (is_array($exif) && array_key_exists('Model', $exif)) {
// Read software string in 3DS screenshots
// Read software string in 3DS screenshots
if ($exif['Model'] === 'Nintendo 3DS') {
// All the regions from the titlelist
// GB = EUR/PAL
// KR AND TW are Korea and Taiwan
// filenames are titlelist_$region.json
// files from hax0kartik/3dsdb(values retrived from eshop directly)

/*
EACH GAME IN THE JSON IS MADE LIKE THIS:
{
"Name": "Shovel Software Insurance Claim",
"UID": "50010000049535",
"TitleID": "000400000F715C00",
"Version": "N/A",
"Size": "25.7 MB [206 blocks]",
"Product Code": "KTR-N-CF6P",
"Publisher": "Batafurai"
},
BUNCH OF STUFF FOR RATING BUT IT ISN'T WHAT WE SEARCH.(only need names and title id)
the title id is in the attributes of <title> so we have to access via the ->attributes()->id thing.
*/

$regions = ["GB", "JP", "KR", "TW", "US"];
// Match ID with game title if possible
$id = strtoupper($exif['Software']);
foreach($regions as $region) { // FOR EACH REGION!!
$json=json_decode(file_get_contents('titlelist/list_'.$region.'.json'));
foreach($json as $game) {
if ($game->TitleID == '000400000'.$id.'00') {
// Update software name


$software = str_replace("\u2122", "", $game->Name);
break 2; // in order to break fully of 2 foreachs.
$software = str_replace("\u2122", "", $game->Name);
break 2; // in order to break fully of 2 foreachs.
}
}
}
}
}
}
}

// Set up image upload with selected service
Expand Down

0 comments on commit ed1754a

Please sign in to comment.