-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
38 lines (32 loc) · 1.16 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import argparse
import os
from src.gpx_merger import GpxMerger
from config.paths import WORKOUT_ROUTES
from src.strava_gpx_uploader import StravaGpxUploader
from src.export_xml_parser import ExportXmlParser
from src.sport_type_getter import get_sport_type
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument(
"--upload-to-strava",
dest="upload_to_strava",
action="store_true",
help="get all keep data to gpx and download",
)
options = parser.parse_args()
files = os.listdir(WORKOUT_ROUTES)
workout_type = get_sport_type(files)
for i, gpx_file in enumerate(files):
# if i == 2:
# break # upload a few for test
# custom your desired time
year, month, day = int(gpx_file[6:10]), int(gpx_file[11:13]), int(gpx_file[14:16])
if year > 2019:
break
print(f'Now processing {gpx_file}')
new_gpx = GpxMerger(gpx_file)
new_gpx.merge_points()
new_gpx.save_gpx()
if options.upload_to_strava:
Uploader = StravaGpxUploader(new_gpx.new_file_path, workout_type[gpx_file])
Uploader.upload_gpx()