petergardfjall / garminexport

Garmin Connect activity exporter and backup tool
Apache License 2.0
507 stars 83 forks source link

new options, and make incremental_backup.py more intelligent about finding activities #1

Closed dlenski closed 9 years ago

dlenski commented 9 years ago

Great utility! I added a few features which others may find useful too.

  1. New options for garminexport and incremental_backup:
    • -E to ignore errors in backing up individual activities (I'm getting sporadic 500 Server Error for some reason)
    • -f to limit exported formats to a subset (e.g. -f tcx -f json_summary)
  2. Since incremental_backup can export only a subset of formats, it needs to be more intellligent about figuring out which activities need to be re-fetched. For example, with -f tcx -f json_summary it should check that both of those exist for a given activity. In order to make this work, I modified list_activity_ids (renamed to list_activities) to return both the starting timestamp and the activity ID in order to determine the expected filenames for each activity.
petergardfjall commented 9 years ago

Glad you find it useful Dan, and thanks for the improvements! Great contributions and the code looks solid. I'll merge your pull request. The only issue that I can see, is that there are cases, such as when you've created an activity manually, where it isn't possible to export the .FIT file for the activity (since it doesn't have one). In such cases, the incremental backup will try to back up all those activities with missing .FIT files again, which, in my case, were quite a few. Maybe that could be solved just by writing some empty placeholder file for missing .FIT files.

Anyhow.. Thanks a bunch for the contributions! I'm merging them in!

petergardfjall commented 9 years ago

Oh, and by the way, I'm considering dropping the garminexport.py script altogether, since incremental_backup.py practically does the same thing, with some additional cleverness.

I guess you wouldn't mind that?

dlenski commented 9 years ago

Thanks!

The only issue that I can see, is that there are cases, such as when you've created an activity manually, where it isn't possible to export the .FIT file for the activity (since it doesn't have one). In such cases, the incremental backup will try to back up all those activities with missing .FIT files again, which, in my case, were quite a few. Maybe that could be solved just by writing some empty placeholder file for missing .FIT files.

Good point, I hadn't thought of this. When you do the activity search, you're actually getting the whole activitySummary structure (I think) so it should be possible to pre-identify activities which were manually created and won't ever generate certain file types.

I can work on a patch for that...

dlenski commented 9 years ago

I'm considering dropping the garminexport.py script altogether, since incremental_backup.py practically does the same thing, with some additional cleverness I guess you wouldn't mind that?

Not at all. Makes sense to consolidate them in this way.