mirror of
https://github.com/zoffline/zwift-offline.git
synced 2026-08-02 08:57:57 -07:00
Encode activity name for urlopen (#70)
* Encode activity name * Unquote activity name
This commit is contained in:
+3
-1
@@ -11,9 +11,11 @@ from datetime import datetime
|
||||
if sys.version_info[0] > 2:
|
||||
import socketserver
|
||||
from http.server import SimpleHTTPRequestHandler
|
||||
from urllib.parse import unquote
|
||||
else:
|
||||
import SocketServer as socketserver
|
||||
from SimpleHTTPServer import SimpleHTTPRequestHandler
|
||||
from urllib2 import unquote
|
||||
|
||||
import zwift_offline
|
||||
import protobuf.udp_node_msgs_pb2 as udp_node_msgs_pb2
|
||||
@@ -65,7 +67,7 @@ def saveGhost(player_id, name):
|
||||
os.makedirs(load)
|
||||
except:
|
||||
return
|
||||
f = '%s/%s-%s.bin' % (folder, time.strftime("%Y-%m-%d-%H-%M-%S"), name.replace('%20', ' '))
|
||||
f = '%s/%s-%s.bin' % (folder, time.strftime("%Y-%m-%d-%H-%M-%S"), unquote(name))
|
||||
with open(f, 'wb') as fd:
|
||||
fd.write(rec.SerializeToString())
|
||||
|
||||
|
||||
+4
-3
@@ -16,9 +16,10 @@ from io import BytesIO
|
||||
from shutil import copyfile
|
||||
|
||||
if sys.version_info[0] > 2:
|
||||
import urllib.request as urllib2
|
||||
from urllib.parse import quote
|
||||
from urllib.request import urlopen
|
||||
else:
|
||||
import urllib2
|
||||
from urllib2 import quote, urlopen
|
||||
|
||||
from flask import Flask, request, jsonify, g, redirect, render_template
|
||||
from google.protobuf.descriptor import FieldDescriptor
|
||||
@@ -400,7 +401,7 @@ def api_profiles_activities_id(player_id, activity_id):
|
||||
if request.args.get('upload-to-strava') != 'true':
|
||||
return response, 200
|
||||
if os.path.exists(ENABLEGHOSTS_FILE):
|
||||
urllib2.urlopen("http://cdn.zwift.com/saveghost?%s" % activity.name)
|
||||
urlopen("http://cdn.zwift.com/saveghost?%s" % quote(activity.name))
|
||||
# Unconditionally *try* and upload to strava and garmin since profile may
|
||||
# not be properly linked to strava/garmin (i.e. no 'upload-to-strava' call
|
||||
# will occur with these profiles).
|
||||
|
||||
Reference in New Issue
Block a user