Multiple '_' fix.
authorRoman Bazalevskiy <rvb@rvb.name>
Tue, 4 May 2021 12:58:27 +0000 (15:58 +0300)
committerRoman Bazalevskiy <rvb@rvb.name>
Tue, 4 May 2021 12:58:27 +0000 (15:58 +0300)
pyrungps/pyrungps_sync.py

index 420994b8d54f6054e718babc3e40dcb6c0692790..18c2235c34ac667f1dec830e22980745a9ee2ea6 100644 (file)
@@ -15,6 +15,7 @@ from datetime import date,datetime
 from dateutil.parser import isoparse
 from pyrungps.parsegpx import write_parsed_to_db,check_db_for_training
 from pyrungps.pygpx import GPX
 from dateutil.parser import isoparse
 from pyrungps.parsegpx import write_parsed_to_db,check_db_for_training
 from pyrungps.pygpx import GPX
+from io import BytesIO
 
 from tempfile import NamedTemporaryFile
 
 
 from tempfile import NamedTemporaryFile
 
@@ -36,7 +37,8 @@ def get_page(uname,year,month):
     if attribute == "href":
       if link.startswith("/trainings/"):
         dummy, dummy, link = link.split('/')
     if attribute == "href":
       if link.startswith("/trainings/"):
         dummy, dummy, link = link.split('/')
-        name, id, *_ = link.split('_')
+        name, *ids = link.split('_')
+        id = ids[-1]
         trainings.append([ unquote(name), id ])
       
   return trainings      
         trainings.append([ unquote(name), id ])
       
   return trainings      
@@ -46,6 +48,7 @@ def get_gpx_track(trid,name):
   print("trid=",trid)
 
   req = requests.get("http://www.gps-sport.net/services/trainingGPX.jsp?trainingID=%s&tz=-180" % (trid), verify=False)
   print("trid=",trid)
 
   req = requests.get("http://www.gps-sport.net/services/trainingGPX.jsp?trainingID=%s&tz=-180" % (trid), verify=False)
+  
   xml = etree.fromstring(req.text.encode('utf-8'))
 
   return xml
   xml = etree.fromstring(req.text.encode('utf-8'))
 
   return xml