Batch-adding excersises #1621
-
I have a Finnlo BioForce workout device and I want to add all the exercises for it to my wger instance. I have extracted the needed information out of instruction PDFs, created a database with relevant categories, equipment and pictures. `INSERT INTO exercises_equipment VALUES ( '12', 'Fußschlaufen'); START: Stehen Sie mit sicherem Stand zum Gerät hin. Halten Sie die unteren Handgriffe auf Schulterhöhe. BEWEGUNG: In die Knie gehen, bis Oberschenkel parallel zum Boden sind. Anspannung kurz halten und zur Ausgangsposition zurückkehren. TIPPS: Knie auf gleicher Höhe mit den Füßen halten. Gewicht auf den ganzen Fuß verteilen, nicht nur auf Zehen oder Fersen. Oberkörper während der kompletten Übung gerade halten. Schwierigkeit: Anfänger ', 'KNIEBEUGEN ', '2023-07-30', '1', 2, 'ae83749b-273b-ff12-7814-56fea441efe3', '3001', '2023-07-30 19:07:52.205965+0200', '', '', '', '' );INSERT INTO exercises_exerciseimage VALUES (400, 'HAMMER SPORT AG', 'exercise-images/renamed_images/44-1.gif', 't', '3001', 2, '5c43079b-13e2-4744-593b-d172758fa803', 4 , '', '', '', ''); INSERT INTO exercises_exerciseimage VALUES (401, 'HAMMER SPORT AG', 'exercise-images/renamed_images/44-1-pulleys.png', 'f', '3001', 2, '9affbec5-e651-fdaf-5729-cba0b73c8bb9', 4 , '', '', '', ''); INSERT INTO exercises_exerciseimage VALUES (402, 'HAMMER SPORT AG', 'exercise-images/renamed_images/44-1-1.png', 'f', '3001', 2, '42389e22-547b-8797-4612-ce9d5168cdb5', 4 , '', '', '', ''); INSERT INTO exercises_exerciseimage VALUES (403, 'HAMMER SPORT AG', 'exercise-images/renamed_images/44-1-2.png', 'f', '3001', 2, 'f66a37fd-a774-c1b7-86b1-32a5760cb9e2', 4 , '', '', '', ''); INSERT INTO exercises_exercisebase_equipment VALUES ('500', '3001', '11' ); INSERT INTO exercises_exercisebase_equipment VALUES ('501', '3001', '13' ); INSERT INTO exercises_exercisebase_muscles VALUES ('600', '3001', '10' ); INSERT INTO exercises_exercisebase_muscles VALUES ('601', '3001', '8' ); INSERT INTO exercises_exercisebase_muscles VALUES ('602', '3001', '7' ); INSERT INTO exercises_exercise VALUES (3002, 'HAMMER SPORT AG', ' START: Stand facing frame. Feet hip width apart on base. Grip handles at shoulders. Motion: Flex knees, hips and ankles. Lower until thighs are parallel to floor or slightly higher. Press up to starting position. TIPS: Keep knees in line with toes. Center weight over arches, not toes or heels. Lift chest and keep back straight as hips lower. Keep head lifted and in line with spine. Contract abdominals to stabilize back. DIFFICULTY: Beginner ', 'SQUAT ', '2023-07-30', 2, 2, 'f9f74dec-9ae5-7b55-69ed-e7977657baa4', '3001', '2023-07-30 19:07:52.205965+0200', '', '', '', '' );`It works in the web interface (I can't add or remove pictures though), but not in the android app: the overview page for such an exercise is grey. If I create same exercise manually, then the overview page works in android as well. How do I add a bunch of exercises to Wger? Is it possible via REST API? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 1 reply
-
I try to add an exercise with REST API via the Swagger interface. I post to exercise-base the following: So far so good, 1025 is the id I get. I go to /api/v2/exercisebaseinfo/1025/, see 200 OK and the relevant data. If I search /api/v2/exercisebaseinfo/ for relevant category and equipment, the 1025 is in the results. But the /api/v2/exercise-base/1025/ returns 404 and searching exercise-base does not return 1025 as a result. Why? |
Beta Was this translation helpful? Give feedback.
-
Hi! Did you also add one translation over the API? There might be some caching involved, but if exercisebaseinfo returns something, exercise-base should do as well. What do you get when you run |
Beta Was this translation helpful? Give feedback.
-
But yeah, adding an exercise consists of adding a base with the necessary categories etc and then adding a translation to it, nothing more, so I'm unsure why it doesn't work for you |
Beta Was this translation helpful? Give feedback.
-
Ok, did not know about the translation, thought I could GET the exercise straight after adding the base. After I've added it, I can see the exersice. Still, the android app yields gray screen when I start the workout with it. Need to look further. This is an example translation POST: |
Beta Was this translation helpful? Give feedback.
-
try doing a |
Beta Was this translation helpful? Give feedback.
-
Thanks for the hint! The SQL batch method is still grey, so I'll go with API instead. Is there a documented way to add an image? I tried ` with open(image_1, 'rb') as image_file:
But get an error How do I submit an image via API? The documentation says only "string", but in which format? |
Beta Was this translation helpful? Give feedback.
Figured it out, you need to use "file" headers (of course), e.g.
files = { 'license': (None, ''), 'license_derivative_source_url': (None, ''), 'license_author': (None, ''), 'license_object_url': (None, ''), 'is_main': (None, 'true'), 'style': (None, '1'), 'exercise_base': (None, '1252'), 'license_author_url': (None, ''), 'license_title': (None, ''), 'image': ('44-1-1.png', open(image_2, 'rb'), 'image/png'), }