Fixes server list retrieval

This commit is contained in:
Alberto Sottile 2018-04-25 15:43:48 +02:00
parent 111976faf9
commit ff08eecf02

View File

@ -371,14 +371,15 @@ def open_system_file_browser(path):
def getListOfPublicServers(): def getListOfPublicServers():
try: try:
import urllib.request, urllib.parse, urllib.error, syncplay, sys, messages, json import urllib.request, urllib.parse, urllib.error, syncplay, sys, json
params = urllib.parse.urlencode({'version': syncplay.version, 'milestone': syncplay.milestone, 'release_number': syncplay.release_number, params = urllib.parse.urlencode({'version': syncplay.version, 'milestone': syncplay.milestone, 'release_number': syncplay.release_number,
'language': messages.messages["CURRENT"]}) 'language': syncplay.messages.messages["CURRENT"]})
f = urllib.request.urlopen(constants.SYNCPLAY_PUBLIC_SERVER_LIST_URL.format(params)) f = urllib.request.urlopen(constants.SYNCPLAY_PUBLIC_SERVER_LIST_URL.format(params))
response = f.read() response = f.read()
response = response.decode('utf-8')
response = response.replace("<p>","").replace("</p>","").replace("<br />","").replace("&#8220;","'").replace("&#8221;","'").replace(":&#8217;","'").replace("&#8217;","'").replace("&#8242;","'").replace("\n","").replace("\r","") # Fix Wordpress response = response.replace("<p>","").replace("</p>","").replace("<br />","").replace("&#8220;","'").replace("&#8221;","'").replace(":&#8217;","'").replace("&#8217;","'").replace("&#8242;","'").replace("\n","").replace("\r","") # Fix Wordpress
response = ast.literal_eval(response) response = ast.literal_eval(response)
if response: if response:
return response return response
else: else: