-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from renomureza/fix-tafsir
perbaikan tafsir kemenag & typo key revelation
- Loading branch information
Showing
13 changed files
with
130 additions
and
12,614 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const fs = require("fs/promises"); | ||
const { default: axios } = require("axios"); | ||
const { | ||
delay, | ||
logSuccess, | ||
logError, | ||
logInfo, | ||
pathToData, | ||
} = require("../../utils/utility"); | ||
|
||
const getListSurah = () => { | ||
return axios | ||
.get("https://quran.kemenag.go.id/api/v1/surat/0/114") | ||
.then((res) => res.data.data); | ||
}; | ||
|
||
const getAyahs = async (numberSurah) => { | ||
try { | ||
await delay(1); | ||
const verse = await axios.get( | ||
`https://quran.kemenag.go.id/api/v1/ayatweb/${numberSurah}/0/0/10000/` | ||
); | ||
logSuccess(`AYAHS: surah ${numberSurah} SUCCESS!`); | ||
return verse.data.data; | ||
} catch (error) { | ||
logError(`AYAHS: surah ${numberSurah} FAIL!`); | ||
logInfo(`AYAHS: surah ${numberSurah} RE-CRAWL!`); | ||
await delay(2); | ||
return await getAyahs(numberSurah); | ||
} | ||
}; | ||
|
||
const main = async () => { | ||
const surahs = await getListSurah(); | ||
|
||
for (const surah of surahs) { | ||
const ayahs = await getAyahs(surah.id); | ||
surahs[surah.id - 1].ayahs = ayahs; | ||
} | ||
|
||
await fs.writeFile( | ||
pathToData("tmp", "kemenag", "surah.json"), | ||
JSON.stringify(surahs) | ||
); | ||
logSuccess("Everything is DONE!"); | ||
}; | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const fs = require("fs/promises"); | ||
const { default: axios } = require("axios"); | ||
const { | ||
logSuccess, | ||
logInfo, | ||
logError, | ||
delay, | ||
pathToData, | ||
} = require("../../utils/utility"); | ||
|
||
const getTafsir = async (numberAyah) => { | ||
try { | ||
await delay(2); | ||
const tafsir = await axios.get( | ||
`https://quran.kemenag.go.id/api/v1/tafsirbyayat/${numberAyah}` | ||
); | ||
logSuccess(`TAFSIR: ayah ${numberAyah} SUCCESS!`); | ||
return { short: tafsir.data.tafsir[0], long: tafsir.data.tafsir[1] }; | ||
} catch (error) { | ||
logError(`TAFSIR: ayah ${numberAyah} FAIL!`); | ||
logInfo(`TAFSIR: ayah ${numberAyah} RE-CRAWL!`); | ||
await delay(2); | ||
return await getTafsir(numberAyah); | ||
} | ||
}; | ||
|
||
const main = async () => { | ||
const tafsirs = []; | ||
|
||
for (let i = 1; i <= 6236; i++) { | ||
const tafsir = await getTafsir(i); | ||
tafsirs.push(tafsir); | ||
} | ||
|
||
await fs.writeFile( | ||
pathToData("tmp", "kemenag", "tafsir.json"), | ||
JSON.stringify(tafsirs) | ||
); | ||
}; | ||
|
||
main(); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.
13ba86d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: