From 15632047d4fb59cc40ef98dcb4a94438ba16f9d4 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sat, 18 Nov 2023 19:47:22 +0300 Subject: [PATCH] Fix(robots): Store charset --- Robots/bkmk_rforking.py | 2 +- Robots/bkmk_robot_base.py | 4 ++++ check_url.py | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Robots/bkmk_rforking.py b/Robots/bkmk_rforking.py index 117bf31..7b458df 100644 --- a/Robots/bkmk_rforking.py +++ b/Robots/bkmk_rforking.py @@ -86,7 +86,7 @@ class robot_forking(Robot): "error", "no_error", "moved", "size", "md5", "real_title", "last_tested", "last_modified", "test_time", - "icon", "icon_href", + "icon", "icon_href", "charset", ): if hasattr(new_b, attr): setattr(bookmark, attr, getattr(new_b, attr)) diff --git a/Robots/bkmk_robot_base.py b/Robots/bkmk_robot_base.py index 52d6b56..ad0f6d2 100644 --- a/Robots/bkmk_robot_base.py +++ b/Robots/bkmk_robot_base.py @@ -152,6 +152,10 @@ class robot_base(Robot): content_stripped = content.strip() if content_stripped and is_html: parser = parse_html(content_stripped, charset, self.log) + if charset: + bookmark.charset = charset + elif parser and parser.meta_charset: + bookmark.charset = parser.meta_charset if parser: bookmark.real_title = parser.title icon = parser.icon diff --git a/check_url.py b/check_url.py index 697d677..1c51481 100755 --- a/check_url.py +++ b/check_url.py @@ -59,10 +59,11 @@ def run(): LastModified: %s IconURI: %s Icon: %s + Charset: %s """ % ( bookmark.href, getattr(bookmark, 'real_title', ''), strftime(bookmark.last_modified), bookmark.icon_href, - bookmark.icon)) + bookmark.icon, bookmark.charset)) robot.stop() log.close() -- 2.39.5