Print lessons in different formats

Hello,
Is there an option to print lessons in a format other than pdf? E.g. txt or srt with time stamps would be really nice.
All the best,
Sam

1 Like

This is an option in Master LingQ under Download Lesson ZIP although its not a free extension. (SRT/VTT/TXT in dual and single line, audio fragments of each sentence, all word data and all stored translations)

To output a lesson as SRT for free you could paste this into your browser console. You just need to change the language and lesson id variables.

Generate SRT from Lesson Data
const language = 'fi';
const lessonId = '29330718';

const lessonDetails = await fetchLessonDetails(language, lessonId);

// Extract sentences, timestamps, and translations
const sentencesWithTimestamps = lessonDetails.tokenizedText.flat(); // Flatten the array structure

const srtContent = createSrtContent(sentencesWithTimestamps);

console.log(srtContent);

function createSrtContent(sentences) {
return sentences.map((sentence, index) => {
    const startTime = formatTimecode(sentence.timestamp[0]);
    const endTime = formatTimecode(sentence.timestamp[1]);
    return `${index + 1}\n${startTime} --> ${endTime}\n${sentence.text}\n`;
}).join('\n');
}

function formatTimecode(seconds) {
  const date = new Date(0);
  date.setSeconds(seconds);
  return date.toISOString().substr(11, 12).replace('.', ',');
}

async function fetchLessonDetails(language, lessonId) {
  const lessonDetailsUrl = `https://www.lingq.com/api/v3/${language}/lessons/${lessonId}/simple`;
  try {
      const response = await fetch(lessonDetailsUrl);
      const json = await response.json();
      return json;
  } catch (error) {
      console.error('Error fetching lesson details:', error);
      return null;
  }
}

3 Likes

Thank you so much! This worked perfectly. For those wondering, simply do the following:

  1. Press Ctrl+Shift+I in your lesson;
  2. Copy paste the above code in the “Console” tab;
  3. Modify “const language = ‘fi’;” to e.g. “const language = ‘de’;” for German;
  4. Modify your lesson ID, i.e. “const lessonId = ‘29330718’;”. This is in your URL, e.g. typically something like https://www.lingq.com/en/learn/de/web/reader/######## where ######## is the ID;
  5. Press the Enter key to execute the code and copy paste the content from the window into an empty file of your choice (with the .srt extension at the end of the name).
    Cheers!
1 Like