raineorshine / memrise-export

Export all words from a Memrise course to a CSV file
7 stars 3 forks source link

Idea: use preview API to fetch words #15

Open baroxyton opened 2 years ago

baroxyton commented 2 years ago

as the original api has been removed the preview API could be used instead

here's a minimal demo:

token = document.cookie.split(" ").find(cookie=>cookie.includes("csrftoken")).split(/[=;]/g)[1];
response = await(await fetch("https://app.memrise.com/v1.18/learning_sessions/preview/", {
    "headers":{"Accept":"*/*","Content-Type":"Application/json","X-CSRFToken":token},
    "body": "{\"session_source_id\":2156672,\"session_source_type\":\"course_id_and_level_index\",\"session_source_sub_index\":1}",
    "method": "POST"
})).json();
console.log(response.learnables.map(learnable=>`${learnable.learning_element},${learnable.definition_element}`).join("\n"))
raineorshine commented 2 years ago

It works!!! Good find. Maybe I can find some time to resurrect the extension.

raineorshine commented 2 years ago

I played around with this some more, and it appears to only return words from in progress learning sessions. The extension needs to be able to fetch the words from an arbitrary course (i.e. the current course page, regardless if it has been studied yet or not).

chickendude commented 1 year ago

https://app.memrise.com/v1.18/learning_sessions/learn/?session_source_id={course_id}&session_source_sub_index={level_index}&session_source_type=course_id_and_level_index (replace {course_id} with the course's id and {level_index} with the level you want to see) This is what i've been using, however i just realized it seems to be limited to 10 words per level.

baroxyton commented 1 year ago

This repository is an implementation of the api https://github.com/Eltaurus-Lt/CourseDump2022