Skip to content

Commit

Permalink
Coveralbum hotfix
Browse files Browse the repository at this point in the history
Фикс возникновения ошибки при содержании в тегах некорректного изображения.
  • Loading branch information
Vladya committed Aug 12, 2020
1 parent e227c60 commit 2ecf430
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -134,3 +134,4 @@ log.txt
errors.txt
traceback.txt
game/Test audio/*
WhatPlaying.rpa
1 change: 1 addition & 0 deletions game/AudioMetaData/itunes.py
Expand Up @@ -87,6 +87,7 @@ def coveralbum_tag(self): # Optional
try:
image = ITunesWebParser._openurl(url)
except InternetConnectionError:
self.__coveralbum = "noOptionFound"
return None
except Exception as ex:
self.LOGGER.error("Unrecognized error.\n%s", ex.message)
Expand Down
11 changes: 11 additions & 0 deletions game/WhatPlayingScripts/_imports.rpy
Expand Up @@ -134,3 +134,14 @@ init 1 python in _whatPlaying:
url,
ex.message
)

def is_showable(image_object):
"""
Проверяет возможность показа 'ImageBase' изображения.
"""
if not isinstance(image_object, im.ImageBase):
raise TypeError(__("Переданный тип не 'im.ImageBase'."))
try:
return bool(image_object.load())
except Exception:
return False
10 changes: 9 additions & 1 deletion game/WhatPlayingScripts/displayables.rpy
Expand Up @@ -14,10 +14,18 @@ init 4 python in _whatPlaying:

super(_AlbumCover, self).__init__()

fn = picture_bytedata = None
if metadata_object.coveralbum_tag:
fn, picture_bytedata = metadata_object.coveralbum_tag
fn = "{0} {1}".format(metadata_object.__unicode__(), fn)
else:
if not is_showable(
im.Data(data=picture_bytedata, filename=fn)
):
# Если по каким-то причинам картинка не прогружается
# (Неподдерживаемый формат, огромный размер и т.п.)
fn = picture_bytedata = None

if not (fn and picture_bytedata):
with renpy.file("albumCoverPlaceholders.zip") as _raw_zipfile:
with zipfile.ZipFile(_raw_zipfile, 'r') as _archive:
_placeholder = random.choice(_archive.infolist())
Expand Down
2 changes: 1 addition & 1 deletion game/options.rpy
Expand Up @@ -23,7 +23,7 @@ define gui.show_name = True

## Версия игры.

define config.version = "1.3.5"
define config.version = "1.3.6"


## Текст, помещённый в экран "Об игре". Поместите текст между тройными скобками.
Expand Down
8 changes: 8 additions & 0 deletions game/tl/english/WhatPlayingScripts/_imports.rpy
Expand Up @@ -10,3 +10,11 @@ translate english strings:
old "Передан не текст."
new "Wrong type. Text expected."

# TODO: Translation updated at 2020-08-13 00:12

translate english strings:

# game/WhatPlayingScripts/_imports.rpy:143
old "Переданный тип не 'im.ImageBase'."
new "Wrong type. 'im.ImageBase' expected."

0 comments on commit 2ecf430

Please sign in to comment.