netbrain / zwift

Easily zwift on linux
The Unlicense
265 stars 28 forks source link

[SOLVED] Add support for uploading ZWO files #29

Closed jonathanglima closed 1 year ago

jonathanglima commented 1 year ago

I'm not able to sync Zwift with Training Peaks due to issues that are non related to this repo (mainly communication between servers, it seems). So I'd love to import custom workouts to Zwift using .zwo files.

It seems that Zwift is able to read those files under a Documents folder: https://support.zwift.com/en_us/custom-workouts-ryGOTVEPs#Importing_Custom_Workouts_Today's_Plan_or_TrainingPeaks

Is there any way to bind that folder to the current docker execution so we could import .zwo files?

PS: Congrats on the repo. It's awesome and it saved me a bunch of time! Cheers!

netbrain commented 1 year ago

You have the option to either copy the zwo files into the named volume (docker cp)

Or, you can use a host volume mount instead and copy the zwo files there. We used to do it this way, but people had a lot of issues with file permissions so we went with a named volume instead.

On Mon, Oct 9, 2023, 04:12 Jonathan Garcia Lima @.***> wrote:

I'm not able to sync Zwift with Training Peaks due to issues that are non related to this repo (mainly communication between servers, it seems). So I'd love to import custom workouts to Zwift using .zwo files.

It seems that Zwift is able to read those files under a Documents folder: https://support.zwift.com/en_us/custom-workouts-ryGOTVEPs#Importing_Custom_Workouts_Today's_Plan_or_TrainingPeaks

Is there any way to bind that folder to the current docker execution so we could import .zwo files?

PS: Congrats on the repo. It's awesome and it saved me a bunch of time! Cheers!

— Reply to this email directly, view it on GitHub https://github.com/netbrain/zwift/issues/29, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACTNC4R2H5Z2MXPTPZOPOLX6NMP7AVCNFSM6AAAAAA5YDXR7CVHI2DSMVQWIX3LMV43ASLTON2WKOZRHEZTEMJZGE4TKMI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

netbrain commented 1 year ago

See here for a copy example https://github.com/netbrain/zwift/blob/master/README.md#how-can-i-persist-my-login-information-so-i-dont-need-to-login-on-every-startup

jonathanglima commented 1 year ago

Sounds reasonable. I'll have to find the corresponding folder at the same volume.

Maybe running bash inside busybox to explore files will be enough.

I will try this and I will get back if everything works. It might be helpful additional information for the docs.

netbrain commented 1 year ago

Feel free to add a "How to add zwo files" section to the readme. 🤞☺️

On Mon, Oct 9, 2023, 18:38 Jonathan Garcia Lima @.***> wrote:

Sounds reasonable. I'll have to find the corresponding folder at the same volume.

Maybe running bash inside busybox to explore files will be enough.

I will try this and I will get back if everything works. It might be helpful additional information for the docs.

— Reply to this email directly, view it on GitHub https://github.com/netbrain/zwift/issues/29#issuecomment-1753331737, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACTNC6SSBV3QIOYLIVHDMLX6QSADAVCNFSM6AAAAAA5YDXR7CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJTGMZTCNZTG4 . You are receiving this because you commented.Message ID: @.***>

jonathanglima commented 1 year ago

Found the path. I'll redact the id because this might be PII information, but copying a .zwo file to /data/Workouts/ works!

The thing is, is there a way to find that ID dynamically? I went through the files trying to get that ID but got no luck.

Maybe using a wildcard to copy the file to all IDs inside the Workouts folder? What do you think? Any suggestions?

netbrain commented 1 year ago

So what your saying is that there is a dynamically named folder like /some/path/xyz/Workouts where xyz is this ID you mention?

Something like this would probably work I guess? not tested though.

docker run -v zwift-$USER:/data --name zwift-copy-op busybox true
docker exec zwift-copy-op ls /some/path/* | xargs -I{} docker cp my-workouts-file.zwo zwift-copy-op:/some/path/{}/Workouts
docker rm zwift-copy-op

The docker exec command should lists all files and folders in /some/path/ inside the running container/named volume, and then copies a file named my-workouts-file.zwo into a Workouts folder within each of those listed directories in/some/path.

jonathanglima commented 1 year ago

The logic is correct but I guess that docker run -v zwift-$USER:/data --name zwift-copy-op busybox true would start busybox and exit it right afterwards. So the exec command after run, such as you've mentioned, returns this error:

Error response from daemon: Container <hash here> is not running

So I tried the following, to catch the folder name right at startup and it worked:

docker run -v zwift-$USER:/data --name zwift-copy-op busybox ls /data/Workouts | xargs -I {} docker cp my-workouts-file.zwo zwift-copy-op:/data/Workouts/{}
docker rm zwift-copy-op

I guess that's enough to open a pull request and add it to the Readme. I'm not sure how to do it with podman since I've never used it. I will open the pull request for the Readme with docker info, still.

Thanks!