1818 */
1919#include " scraper.h"
2020#include " oslib/http_client.h"
21+ #include " oslib/storage.h"
2122#include " stdclass.h"
2223#include " emulator.h"
2324#include " imgread/common.h"
@@ -47,6 +48,7 @@ json GameBoxart::to_json(const std::string& baseArtPath) const
4748 { " boxart_url" , boxartUrl },
4849 { " parsed" , parsed },
4950 { " scraped" , scraped },
51+ { " arcade" , arcade },
5052 };
5153 return j;
5254}
@@ -64,28 +66,32 @@ GameBoxart::GameBoxart(const json& j, const std::string& baseArtPath)
6466 loadProperty (boxartUrl, j, " boxart_url" );
6567 loadProperty (parsed, j, " parsed" );
6668 loadProperty (scraped, j, " scraped" );
69+ loadProperty (arcade, j, " arcade" );
6770 if (!boxartPath.empty () && !isAbsolutePath (boxartPath))
6871 boxartPath = baseArtPath + boxartPath;
6972}
7073
71- bool Scraper::downloadImage (const std::string& url, const std::string& localName)
74+ bool Scraper::downloadImage (const std::string& url, const std::string& localName, bool mute )
7275{
7376 DEBUG_LOG (COMMON, " downloading %s" , url.c_str ());
7477 std::vector<u8 > content;
7578 std::string contentType;
7679 if (!http::success (http::get (url, content, contentType)))
7780 {
78- WARN_LOG (COMMON, " downloadImage http error: %s" , url.c_str ());
81+ if (!mute)
82+ WARN_LOG (COMMON, " downloadImage http error: %s" , url.c_str ());
7983 return false ;
8084 }
8185 if (contentType.substr (0 , 6 ) != " image/" )
8286 {
83- WARN_LOG (COMMON, " downloadImage bad content type %s" , contentType.c_str ());
87+ if (!mute)
88+ WARN_LOG (COMMON, " downloadImage bad content type %s" , contentType.c_str ());
8489 return false ;
8590 }
8691 if (content.empty ())
8792 {
88- WARN_LOG (COMMON, " downloadImage: empty content" );
93+ if (!mute)
94+ WARN_LOG (COMMON, " downloadImage: empty content" );
8995 return false ;
9096 }
9197 FILE *f = nowide::fopen (localName.c_str (), " wb" );
@@ -251,5 +257,18 @@ void OfflineScraper::scrape(GameBoxart& item)
251257 break ;
252258 item.searchName = trim_trailing_ws (item.searchName .substr (0 , pos));
253259 }
260+ std::string extension = get_file_extension (item.fileName );
261+ if (extension != " zip" && extension != " 7z" && extension != " lst" )
262+ {
263+ FILE *file = hostfs::storage ().openFile (item.gamePath , " rb" );
264+ if (file != nullptr )
265+ {
266+ fseek (file, 0x30 , SEEK_SET);
267+ u8 buf[0x20 ];
268+ if (fread (buf, 1 , sizeof (buf), file) == sizeof (buf))
269+ item.uniqueId = trim_trailing_ws (std::string (&buf[0 ], &buf[0x20 ]));
270+ fclose (file);
271+ }
272+ }
254273 }
255274}
0 commit comments