Skip to content

Commit

Permalink
Wikipedia plugin: decode page content to string (#888)
Browse files Browse the repository at this point in the history
Wikipedia plugin: 
* decode page content to string if it is not a string
* use webkit2 API 4.1 if available
  • Loading branch information
luzip665 committed Jul 29, 2023
1 parent e422162 commit 8f15585
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion plugins/wikipedia/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@

import gi

gi.require_version('WebKit2', '4.0')
try:
gi.require_version('WebKit2', '4.1')
except:
gi.require_version('WebKit2', '4.0')
from gi.repository import WebKit2


Expand Down Expand Up @@ -125,6 +128,8 @@ def load_wikipedia_page(self, track):

try:
html = common.get_url_contents(url, self.__user_agent)
if not isinstance(html, str):
html = html.decode("utf-8")
except urllib.error.URLError as e:
log.error(e)
log.error(
Expand Down

0 comments on commit 8f15585

Please sign in to comment.