Skip to content

Commit

Permalink
Check that we actually got a PIC0 before we try to process it
Browse files Browse the repository at this point in the history
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
  • Loading branch information
sahlberg committed Aug 7, 2023
1 parent 5ad4301 commit ab6b35c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 17 deletions.
12 changes: 8 additions & 4 deletions gamedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2252,6 +2252,8 @@
'id': 'SLUS00001',
'title': "AIR COMBAT",
'pic0': 'https://images.launchbox-app.com/27c885e5-b210-41d4-b3f9-4c3bc0c7b282.png',
'pic1': 'https://images.launchbox-app.com/8181cf02-1af0-4a99-8f75-7f5e44acf1f4.jpg',
'snd0': 'https://www.youtube.com/watch?v=STJm1RoLYLo&list=PL4385054D3D733B93&index=1',
},
'SLUS01467': {
'url': "games/U/A/SLUS-01467.html",
Expand Down Expand Up @@ -3056,7 +3058,7 @@
'url': "games/U/B/SCUS-94424.html",
'id': 'SCUS94424',
'title': "BLOODY ROAR 2",
'pic0': 'https://images.launchbox-app.com/d3a7fc00-9bf0-4aff-8d63-72a05dc21847.png',
'pic0': 'https://images.launchbox-app.com/639ce357-42e8-4de5-9f18-0901e3d5a20a.png',
'pic1': 'https://images.launchbox-app.com/968d92a9-cc09-44bb-8f70-a31dce56a03a.jpg',
'snd0': 'https://www.youtube.com/watch?v=D1UhYyRdKnY&list=PL9DF2CA195A156BE1&index=1',
'manual': 'https://archive.org/download/SonyPlaystationManuals/Bloody%20Roar%20II%20%28USA%29_jp2.zip',
Expand Down Expand Up @@ -12077,6 +12079,8 @@
'id': 'SCES00007',
'title': "AIR COMBAT",
'pic0': 'https://images.launchbox-app.com/27c885e5-b210-41d4-b3f9-4c3bc0c7b282.png',
'pic1': 'https://images.launchbox-app.com/8181cf02-1af0-4a99-8f75-7f5e44acf1f4.jpg',
'snd0': 'https://www.youtube.com/watch?v=STJm1RoLYLo&list=PL4385054D3D733B93&index=1',
},
'SLES03743': {
'url': "games/P/A/SLES-03743.html",
Expand Down Expand Up @@ -13611,7 +13615,7 @@
'url': "games/P/B/SLES-01722.html",
'id': 'SLES01722',
'title': "BLOODY ROAR 2 - BRINGER OF THE NEW AGE",
'pic0': 'https://images.launchbox-app.com/d3a7fc00-9bf0-4aff-8d63-72a05dc21847.png',
'pic0': 'https://images.launchbox-app.com/639ce357-42e8-4de5-9f18-0901e3d5a20a.png',
'pic1': 'https://images.launchbox-app.com/968d92a9-cc09-44bb-8f70-a31dce56a03a.jpg',
'snd0': 'https://www.youtube.com/watch?v=D1UhYyRdKnY&list=PL9DF2CA195A156BE1&index=1',
'manual': 'https://archive.org/download/SonyPlaystationManuals/Bloody%20Roar%20II%20%28USA%29_jp2.zip',
Expand Down Expand Up @@ -33107,7 +33111,7 @@
'url': "games/J/B/SCPS-45374.html",
'id': 'SCPS45374',
'title': "BLOODY ROAR 2 - BRINGER OF THE NEW AGE",
'pic0': 'https://images.launchbox-app.com/d3a7fc00-9bf0-4aff-8d63-72a05dc21847.png',
'pic0': 'https://images.launchbox-app.com/639ce357-42e8-4de5-9f18-0901e3d5a20a.png',
'pic1': 'https://images.launchbox-app.com/968d92a9-cc09-44bb-8f70-a31dce56a03a.jpg',
'snd0': 'https://www.youtube.com/watch?v=D1UhYyRdKnY&list=PL9DF2CA195A156BE1&index=1',
'manual': 'https://archive.org/download/SonyPlaystationManuals/Bloody%20Roar%20II%20%28USA%29_jp2.zip',
Expand All @@ -33116,7 +33120,7 @@
'url': "games/J/B/SLPS-01842.html",
'id': 'SLPS01842',
'title': "BLOODY ROAR 2 - BRINGER OF THE NEW AGE",
'pic0': 'https://images.launchbox-app.com/d3a7fc00-9bf0-4aff-8d63-72a05dc21847.png',
'pic0': 'https://images.launchbox-app.com/639ce357-42e8-4de5-9f18-0901e3d5a20a.png',
'pic1': 'https://images.launchbox-app.com/968d92a9-cc09-44bb-8f70-a31dce56a03a.jpg',
'snd0': 'https://www.youtube.com/watch?v=D1UhYyRdKnY&list=PL9DF2CA195A156BE1&index=1',
'manual': 'https://archive.org/download/SonyPlaystationManuals/Bloody%20Roar%20II%20%28USA%29_jp2.zip',
Expand Down
11 changes: 6 additions & 5 deletions pop-fe-ps3.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,12 @@ def update_assets(self):
self.pic0 = popfe.get_image_from_theme(self._theme, disc_id, 'pop-fe-ps3-work', 'PIC0.png')
if not self.pic0:
self.pic0 = popfe.get_pic0_from_game(disc_id, game, self.cue_file_orig)
temp_files.append('pop-fe-ps3-work/PIC0.PNG')
self.pic0.resize((128,80), Image.Resampling.BILINEAR).save('pop-fe-ps3-work/PIC0.PNG')
self.pic0_tk = tk.PhotoImage(file = 'pop-fe-ps3-work/PIC0.PNG')
c = self.builder.get_object('pic0_canvas', self.master)
c.create_image(0, 0, image=self.pic0_tk, anchor='nw')
if self.pic0:
temp_files.append('pop-fe-ps3-work/PIC0.PNG')
self.pic0.resize((128,80), Image.Resampling.BILINEAR).save('pop-fe-ps3-work/PIC0.PNG')
self.pic0_tk = tk.PhotoImage(file = 'pop-fe-ps3-work/PIC0.PNG')
c = self.builder.get_object('pic0_canvas', self.master)
c.create_image(0, 0, image=self.pic0_tk, anchor='nw')

print('Fetching PIC1') if verbose else None
self.pic1 = None
Expand Down
11 changes: 6 additions & 5 deletions pop-fe-psp.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,12 @@ def on_path_changed(self, event):
self.pic0 = popfe.get_image_from_theme(self._theme, disc_id, 'pop-fe-psp-work', 'PIC0.png')
if not self.pic0:
self.pic0 = popfe.get_pic0_from_game(disc_id, game, cue_file_orig)
temp_files.append('pop-fe-psp-work/PIC0.PNG')
self.pic0.resize((128,80), Image.Resampling.BILINEAR).save('pop-fe-psp-work/PIC0.PNG')
self.pic0_tk = tk.PhotoImage(file = 'pop-fe-psp-work/PIC0.PNG')
c = self.builder.get_object('pic0_canvas', self.master)
c.create_image(0, 0, image=self.pic0_tk, anchor='nw')
if self.pic0:
temp_files.append('pop-fe-psp-work/PIC0.PNG')
self.pic0.resize((128,80), Image.Resampling.BILINEAR).save('pop-fe-psp-work/PIC0.PNG')
self.pic0_tk = tk.PhotoImage(file = 'pop-fe-psp-work/PIC0.PNG')
c = self.builder.get_object('pic0_canvas', self.master)
c.create_image(0, 0, image=self.pic0_tk, anchor='nw')

print('Fetching PIC1') if verbose else None
self.pic1 = None
Expand Down
13 changes: 10 additions & 3 deletions pop-fe.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ def fetch_cached_file(path):
if ret.status_code != 200:
raise Exception('Failed to fetch file ', PSX_SITE + path)

return ret.content.decode(ret.apparent_encoding)

if ret.apparent_encoding:
return ret.content.decode(ret.apparent_encoding)
else:
return ret.content

def fetch_cached_binary(path):
try:
Expand Down Expand Up @@ -283,7 +285,10 @@ def get_pic_from_game(pic, game_id, game, filename):
ret = requests.get(games[game_id][pic], stream=True)
if ret.status_code == 200:
try:
return Image.open(io.BytesIO(ret.content))
if ret.apparent_encoding:
return Image.open(io.BytesIO(ret.content.decode(ret.apparent_encoding)))
else:
return Image.open(io.BytesIO(ret.content))
except:
print('Failed to parse file', games[game_id][pic])
return None
Expand Down Expand Up @@ -1779,6 +1784,8 @@ def bcd(i):
f.write(generate_sbi(sector_pairs[i][1]))

# Convert scans of the manual into a DOCUMENT.DAT for PSP
# XXX add support for pdf manuals
# https://www.gamesdatabase.org/Media/SYSTEM/Sony_Playstation//Manual/formated/Air_Combat_-_1995_-_Namco_Limited.pdf
def create_manual(source, gameid, subdir='./pop-fe-work/'):
# already have a manual in the proper format
if source[-7:] == '.manual':
Expand Down

0 comments on commit ab6b35c

Please sign in to comment.