Skip to content

Commit

Permalink
Changed total time to moving time
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik committed Feb 7, 2012
1 parent 0deb934 commit 5838662
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions code/python/fusionrunner/fusionrunner.py 100644 → 100755
Expand Up @@ -105,7 +105,7 @@


distance_km = re.search(r'Total distance: (.*?) km', desc).group(1) distance_km = re.search(r'Total distance: (.*?) km', desc).group(1)


total_time = re.search(r'Total time: (.*?)<br>', desc).group(1) total_time = re.search(r'Moving time: (.*?)<br>', desc).group(1)
m = re.match(r'(\d+):(\d+):(\d+)|(\d+):(\d+)', total_time) m = re.match(r'(\d+):(\d+):(\d+)|(\d+):(\d+)', total_time)
groups = [x for x in m.groups() if x != None] groups = [x for x in m.groups() if x != None]
if len(groups) == 2: if len(groups) == 2:
Expand All @@ -115,6 +115,7 @@
total_time = int(total_time.total_seconds() * 1000) total_time = int(total_time.total_seconds() * 1000)


activity = re.search(r'Activity type: (\w+)', desc).group(1) activity = re.search(r'Activity type: (\w+)', desc).group(1)
tagid = None
if activity == 'walking': if activity == 'walking':
activity = 'Walk' activity = 'Walk'
tagid = 2 tagid = 2
Expand All @@ -131,12 +132,13 @@
if smashrun_response['status'] == "200": if smashrun_response['status'] == "200":
print "Success" print "Success"


print "Tagging Run from %s..." % (start_date_time), if tagid != None:
match = re.search(r'"runId":(\d+)', smashrun_content) print "Tagging Run from %s..." % (start_date_time),
runid = int(match.group(1)) match = re.search(r'"runId":(\d+)', smashrun_content)
smashrun_url = "http://smashrun.com/services/running-jsonservice.asmx/SaveRunTag" runid = int(match.group(1))
smashrun_body = '{"runId":%d,"tagId":%d,"text":"%s",untag:false}' % (runid, tagid, activity) smashrun_url = "http://smashrun.com/services/running-jsonservice.asmx/SaveRunTag"
smashrun_response, smashrun_content = smashrun_http.request(smashrun_url, 'POST', smashrun_body = '{"runId":%d,"tagId":%d,"text":"%s",untag:false}' % (runid, tagid, activity)
headers=smashrun_headers, body=smashrun_body) smashrun_response, smashrun_content = smashrun_http.request(smashrun_url, 'POST',
if smashrun_response['status'] == "200": headers=smashrun_headers, body=smashrun_body)
print "Success" if smashrun_response['status'] == "200":
print "Success"

0 comments on commit 5838662

Please sign in to comment.