Skip to content

Commit

Permalink
feat: add number of lessons input
Browse files Browse the repository at this point in the history
  • Loading branch information
rfoel committed May 15, 2023
1 parent e7b4878 commit 20e89d1
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 72 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/study.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
name: Do a Duolingo lesson

on: [workflow_dispatch]
on:
workflow_dispatch:
inputs:
lessons:
default: 1
description: 'Number of lessons to be done'
required: false
type: number

env:
DUOLINGO_JWT: ${{ secrets.DUOLINGO_JWT }}
Expand All @@ -16,3 +23,5 @@ jobs:
node-version: 18

- run: node index.js
env:
LESSONS: ${{ inputs.lessons }}
144 changes: 73 additions & 71 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,78 +16,80 @@ const { fromLanguage, learningLanguage, xpGains } = await fetch(
},
).then(response => response.json())

const session = await fetch('https://www.duolingo.com/2017-06-30/sessions', {
body: JSON.stringify({
challengeTypes: [
'assist',
'characterIntro',
'characterMatch',
'characterPuzzle',
'characterSelect',
'characterTrace',
'completeReverseTranslation',
'definition',
'dialogue',
'form',
'freeResponse',
'gapFill',
'judge',
'listen',
'listenComplete',
'listenMatch',
'match',
'name',
'listenComprehension',
'listenIsolation',
'listenTap',
'partialListen',
'partialReverseTranslate',
'readComprehension',
'select',
'selectPronunciation',
'selectTranscription',
'syllableTap',
'syllableListenTap',
'speak',
'tapCloze',
'tapClozeTable',
'tapComplete',
'tapCompleteTable',
'tapDescribe',
'translate',
'typeCloze',
'typeClozeTable',
'typeCompleteTable',
],
fromLanguage,
isFinalLevel: false,
isV2: true,
juicy: true,
learningLanguage,
skillId: xpGains.find(xpGain => xpGain.skillId).skillId,
smartTipsVersion: 2,
type: 'SPEAKING_PRACTICE',
}),
headers,
method: 'POST',
}).then(response => response.json())

const response = await fetch(
`https://www.duolingo.com/2017-06-30/sessions/${session.id}`,
{
for (let i = 0; i < process.env.LESSONS; i++) {
const session = await fetch('https://www.duolingo.com/2017-06-30/sessions', {
body: JSON.stringify({
...session,
heartsLeft: 0,
startTime: (+new Date() - 60000) / 1000,
enableBonusPoints: false,
endTime: +new Date() / 1000,
failed: false,
maxInLessonStreak: 9,
shouldLearnThings: true,
challengeTypes: [
'assist',
'characterIntro',
'characterMatch',
'characterPuzzle',
'characterSelect',
'characterTrace',
'completeReverseTranslation',
'definition',
'dialogue',
'form',
'freeResponse',
'gapFill',
'judge',
'listen',
'listenComplete',
'listenMatch',
'match',
'name',
'listenComprehension',
'listenIsolation',
'listenTap',
'partialListen',
'partialReverseTranslate',
'readComprehension',
'select',
'selectPronunciation',
'selectTranscription',
'syllableTap',
'syllableListenTap',
'speak',
'tapCloze',
'tapClozeTable',
'tapComplete',
'tapCompleteTable',
'tapDescribe',
'translate',
'typeCloze',
'typeClozeTable',
'typeCompleteTable',
],
fromLanguage,
isFinalLevel: false,
isV2: true,
juicy: true,
learningLanguage,
skillId: xpGains.find(xpGain => xpGain.skillId).skillId,
smartTipsVersion: 2,
type: 'SPEAKING_PRACTICE',
}),
headers,
method: 'PUT',
},
).then(response => response.json())
method: 'POST',
}).then(response => response.json())

const response = await fetch(
`https://www.duolingo.com/2017-06-30/sessions/${session.id}`,
{
body: JSON.stringify({
...session,
heartsLeft: 0,
startTime: (+new Date() - 60000) / 1000,
enableBonusPoints: false,
endTime: +new Date() / 1000,
failed: false,
maxInLessonStreak: 9,
shouldLearnThings: true,
}),
headers,
method: 'PUT',
},
).then(response => response.json())

console.log({ xp: response.xpGain })
console.log({ xp: response.xpGain })
}

0 comments on commit 20e89d1

Please sign in to comment.