This is something I deal with fairly often. When I have to import TV shows with 100+ episodes using subtitles from text files there is no way to do so other than manually creating each one. It would be great if there was a way to select multiple files at once and create a lesson for each one under an existing course.
I tried looking for any open APIs that Lingq might have as I can write code but no luck there.
How does everyone else deal with this at the moment?
for coding, you can use something like Selenium to automate a user using a web browser. I have a use case of importing videos from YouTube right away (without waiting) and made a script where I just need to paste in the YouTube link and then the script opens a browser and does all the manual steps I usually would do to import a lesson.
That looks like a great solution! Just to confirm, the tool needs each lesson to be in its own folder right?
I normally have all files in one folder but I could just write a script to create a folder for each one
Also I uploaded about 100 lessons at once though they were uploaded in “random” order. Is there a way to force it to follow alphabetical order?
That’s right. Will support further inclusions. e.g pics/description/inline images?
The order of upload is actually determined by the sorting options on your pc.
here is the relevant code
async function processFolder(files) {
let courseTitle = null;
let lessons = [];
for (let file of files) {
const filePath = file.webkitRelativePath.split("/");
if (!courseTitle) {
courseTitle = filePath[0]; // Set the course title using the main folder name
}
if (filePath.length === 3) { // Indicates a file inside a lesson folder
const lessonFolderName = filePath[1];
const fileName = filePath[2];
let lesson = lessons.find(l => l.folderName === lessonFolderName);
if (!lesson) {
lesson = { folderName: lessonFolderName, text: null, audio: null, title: null };
lessons.push(lesson);
}
if (fileName.endsWith(".txt")) {
const content = await file.text();
lesson.title = content.split("\n")[0];
lesson.text = content;
} else if (fileName.endsWith(".mp3")) {
lesson.audio = file;
}
}
}
// Now you have the course title and an array of lessons with their title, text, and audio.
// You can proceed to create the course and its lessons on LingQ.
createCourseOnLingQ(courseTitle, "Course Description")
.then(courseResponse => {
// Using the course response (which should contain the course ID), create each lesson
for (let lesson of lessons) {
createLessonOnLingQ(
lesson.title,
"Lesson Description",
lesson.text,
courseResponse.id, // Assuming the course response contains the course ID
lesson.audio
);
}
});
}