mirror of
https://github.com/skidoodle/erettsegi-browser.git
synced 2025-02-15 05:39:15 +01:00
Add download for it subjects
This commit is contained in:
parent
b097b0e5a4
commit
b0a3587df6
2 changed files with 76 additions and 21 deletions
src/pages/api
|
@ -1,18 +1,10 @@
|
|||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
|
||||
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
const { ev, szint, vizsgatargy, evszak, tipus } = req.query
|
||||
const baseUrl = 'https://dload-oktatas.educatio.hu/erettsegi/feladatok_'
|
||||
|
||||
const vizsgatargyak = {
|
||||
k_magyir: 'e_magyir',
|
||||
k_mat: 'e_mat',
|
||||
k_tort: 'e_tort',
|
||||
k_angol: 'e_angol',
|
||||
k_nemet: 'e_nemet',
|
||||
k_inf: 'e_inf',
|
||||
k_infoism: 'e_infoism',
|
||||
}
|
||||
const { ev, szint, vizsgatargy, evszak, tipus, file } = req.query
|
||||
const pdfBaseUrl = 'https://dload-oktatas.educatio.hu/erettsegi/feladatok_'
|
||||
const zipBaseUrl =
|
||||
'https://www.oktatas.hu/bin/content/dload/erettsegi/feladatok_'
|
||||
|
||||
const missingParams = []
|
||||
if (!ev) missingParams.push('ev')
|
||||
|
@ -43,14 +35,32 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||
prefix = `k_${vizsgatargy}`
|
||||
}
|
||||
|
||||
let pdfUrl
|
||||
if (tipus === 'fl' || tipus === 'ut') {
|
||||
pdfUrl = `${baseUrl}${ev}${evszak}_${szint}/${prefix}_${ev!.slice(
|
||||
let pdfUrl, zipUrl
|
||||
if (vizsgatargy === 'inf' || vizsgatargy === 'infoism') {
|
||||
if (file === 'forras' && tipus === 'fl') {
|
||||
zipUrl = `${zipBaseUrl}${ev}${evszak}_${szint}/${prefix}for_${ev!.slice(
|
||||
-2
|
||||
)}${honap}_${tipus}.zip`
|
||||
} else if (file === 'megoldas' && tipus === 'ut') {
|
||||
zipUrl = `${zipBaseUrl}${ev}${evszak}_${szint}/${prefix}meg_${ev!.slice(
|
||||
-2
|
||||
)}${honap}_${tipus}.zip`
|
||||
} else if (file === 'megoldas' && tipus === 'fl') {
|
||||
zipUrl = `${zipBaseUrl}${ev}${evszak}_${szint}/${prefix}meg_${ev!.slice(
|
||||
-2
|
||||
)}${honap}_ut.zip`
|
||||
} else if (file === 'forras' && tipus === 'ut') {
|
||||
zipUrl = `${zipBaseUrl}${ev}${evszak}_${szint}/${prefix}for_${ev!.slice(
|
||||
-2
|
||||
)}${honap}_fl.zip`
|
||||
} else {
|
||||
return res.status(400).json({ error: 'Érvénytelen fájltípus' })
|
||||
}
|
||||
} else {
|
||||
pdfUrl = `${pdfBaseUrl}${ev}${evszak}_${szint}/${prefix}_${ev!.slice(
|
||||
-2
|
||||
)}${honap}_${tipus}.pdf`
|
||||
} else {
|
||||
return res.status(400).json({ error: 'Érvénytelen típus' })
|
||||
}
|
||||
|
||||
res.status(200).json({ pdfUrl })
|
||||
res.status(200).json({ pdfUrl, zipUrl })
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue