Private
Public Access
1
0

not really importing the steps correctly

This commit is contained in:
2024-12-15 17:04:17 +01:00
parent b34a415961
commit 8c5dd6bb91
3 changed files with 42 additions and 35 deletions

View File

@@ -322,30 +322,23 @@ class IntervalsIntegration(SyncIntegration):
}
# first get the folders - we need the folder id for the next call
url = self.oauth_data['base_url'] + 'athlete/0/folders'
url = self.oauth_data['base_url'] + 'athlete/0/events?category=WORKOUT'
response = requests.get(url, headers=headers)
if response.status_code != 200:
return []
data = response.json()
# get all elements in the list where start_date_local is not None
folders = [x for x in data if x['start_date_local']]
for plan in folders:
plan_start_date = arrow.get(plan['start_date_local']).datetime
for session in plan["children"]:
session["date"] = (plan_start_date+timedelta(days=session["day"])).date()
return folders
return data
def get_plannedsession(self, id, *args, **kwargs):
_ = self.open()
r = self.rower
url = self.oauth_data['base_url'] + 'athlete/0/workouts/' + str(id)
url = self.oauth_data['base_url'] + 'athlete/0/events/' + str(id)
headers = {
'Authorization': 'Bearer ' + r.intervals_token,
}
response = requests.get(url, headers=headers)
if response.status_code != 200:
@@ -354,6 +347,19 @@ class IntervalsIntegration(SyncIntegration):
data = response.json()
# get file from athlete/0/events/{id}/downloadfit
url = self.oauth_data['base_url'] + 'athlete/0/events/' + str(id) + '/downloadfit'
response = requests.get(url, headers=headers)
if response.status_code != 200:
dologging('intervals.icu.log', response.text)
return 0
filename = 'media/planned_' + str(id) + '.fit'
with open(filename, 'wb') as f:
f.write(response.content)
data['fitfile'] = filename
return data