mp3 support

This commit is contained in:
skidoodle 2024-05-21 23:27:19 +02:00
parent 64292c2e26
commit bd838c7b3f
8 changed files with 5003 additions and 4022 deletions

View file

@ -1,5 +1,3 @@
import million from 'million/compiler'
const securityHeaders = [
{
key: 'X-DNS-Prefetch-Control',
@ -49,8 +47,4 @@ const nextConfig = {
swcMinify: true,
}
const millionConfig = {
auto: true,
}
export default million.next(nextConfig, millionConfig)
export default nextConfig

View file

@ -11,31 +11,30 @@
"lint": "next lint"
},
"dependencies": {
"@nextui-org/react": "^2.2.9",
"@vercel/analytics": "^1.1.1",
"eslint-config-next": "14.0.4",
"framer-motion": "^10.16.16",
"million": "^2.6.4",
"next": "14.0.4",
"next-themes": "^0.2.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-icons": "^4.12.0"
"@nextui-org/react": "^2.3.6",
"@vercel/analytics": "^1.2.2",
"eslint-config-next": "14.2.3",
"framer-motion": "^11.2.5",
"next": "14.2.3",
"next-themes": "^0.3.0",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-icons": "^5.2.1"
},
"devDependencies": {
"@next/eslint-plugin-next": "^14.0.4",
"@types/eslint": "^8.44.8",
"@types/node": "20.10.4",
"@types/react": "18.2.43",
"@types/react-dom": "18.2.17",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"autoprefixer": "10.4.16",
"eslint": "8.55.0",
"postcss": "8.4.32",
"prettier": "^3.1.1",
"prettier-plugin-tailwindcss": "^0.5.9",
"tailwindcss": "3.3.6",
"typescript": "5.3.3"
"@next/eslint-plugin-next": "^14.2.3",
"@types/eslint": "^8.56.10",
"@types/node": "20.12.12",
"@types/react": "18.3.2",
"@types/react-dom": "18.3.0",
"@typescript-eslint/eslint-plugin": "^7.10.0",
"@typescript-eslint/parser": "^7.10.0",
"autoprefixer": "10.4.19",
"eslint": "9.3.0",
"postcss": "8.4.38",
"prettier": "^3.2.5",
"prettier-plugin-tailwindcss": "^0.5.14",
"tailwindcss": "3.4.3",
"typescript": "5.4.5"
}
}

8933
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff

View file

@ -67,3 +67,7 @@ export const PdfButton: React.FC<ButtonProps> = React.memo(
export const ZipButton: React.FC<ButtonProps> = React.memo(
({ label, link }) => <CustomButton label={label} link={link} />
)
export const Mp3Button: React.FC<ButtonProps> = React.memo(
({ label, link }) => <CustomButton label={label} link={link} />
)

View file

@ -6,6 +6,7 @@ export const useAppState = () => {
const [utPdfLink, setutPdfLink] = useState<string>('')
const [flZipLink, setflZipLink] = useState<string>('')
const [utZipLink, setutZipLink] = useState<string>('')
const [flMp3Link, setflMp3Link] = useState<string>('')
const [selectedSubject, setSelectedSubject] = useState<string>('')
const [selectedYear, setSelectedYear] = useState<string>('')
const [selectedPeriod, setSelectedPeriod] = useState<string>('')
@ -23,6 +24,8 @@ export const useAppState = () => {
setflZipLink,
utZipLink,
setutZipLink,
flMp3Link,
setflMp3Link,
selectedSubject,
setSelectedSubject,
selectedYear,

View file

@ -70,7 +70,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
const megoldas = 'meg'
const shortev = ev.slice(-2)
let flPdfUrl, utPdfUrl, flZipUrl, utZipUrl
let flPdfUrl, utPdfUrl, flZipUrl, utZipUrl, flMp3Url
switch (vizsgatargy) {
case 'inf':
case 'infoism':
@ -80,6 +80,12 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
utZipUrl = `${baseUrl}${prefix}${megoldas}_${shortev}${honap}_${utmutato}.zip`
utPdfUrl = `${proxiedUrl}${prefix}_${shortev}${honap}_${utmutato}.pdf`
break
case 'angol':
case 'nemet':
flPdfUrl = `${proxiedUrl}${prefix}_${shortev}${honap}_${feladat}.pdf`
utPdfUrl = `${proxiedUrl}${prefix}_${shortev}${honap}_${utmutato}.pdf`
flMp3Url = `${baseUrl}${prefix}_${shortev}${honap}_${feladat}.mp3`
break
default:
flPdfUrl = `${proxiedUrl}${prefix}_${shortev}${honap}_${feladat}.pdf`
utPdfUrl = `${proxiedUrl}${prefix}_${shortev}${honap}_${utmutato}.pdf`
@ -87,7 +93,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
}
res.setHeader('Cache-Control', 's-maxage=31536000')
res.status(200).json({ flPdfUrl, utPdfUrl, flZipUrl, utZipUrl })
res.status(200).json({ flPdfUrl, utPdfUrl, flZipUrl, utZipUrl, flMp3Url })
} catch (error) {
res.status(500).json({ error: 'Internal Server Error', message: error })
}

View file

@ -1,6 +1,6 @@
import React, { useEffect } from 'react'
import { ButtonGroup, Divider } from '@nextui-org/react'
import { PdfButton, ZipButton } from '@/components/Buttons'
import { PdfButton, ZipButton, Mp3Button } from '@/components/Buttons'
import { Footer } from '@/components/Footer'
import { fetchData } from '@/utils/fetch'
import useYears from '@/hooks/useYears'
@ -23,6 +23,8 @@ export default function Home() {
setflZipLink,
utZipLink,
setutZipLink,
flMp3Link,
setflMp3Link,
selectedSubject,
setSelectedSubject,
selectedYear,
@ -47,7 +49,8 @@ export default function Home() {
setflZipLink,
setutZipLink,
setflPdfLink,
setutPdfLink
setutPdfLink,
setflMp3Link,
)
}
}, [selectedLevel, selectedPeriod, selectedSubject, selectedYear])
@ -102,6 +105,11 @@ export default function Home() {
</ButtonGroup>
</div>
)}
{['angol', 'nemet'].includes(selectedSubject) && (
<div className='space-x-3'>
<Mp3Button label='Hang' link={flMp3Link} />
</div>
)}
</div>
</div>
</div>

View file

@ -6,7 +6,8 @@ export const fetchData = async (
setflZipLink: (link: string) => void,
setutZipLink: (link: string) => void,
setflPdfLink: (link: string) => void,
setutPdfLink: (link: string) => void
setutPdfLink: (link: string) => void,
setflMp3Link: (link: string) => void
) => {
try {
const url = `/api/erettsegi?vizsgatargy=${selectedSubject}&ev=${selectedYear}&idoszak=${selectedPeriod}&szint=${selectedLevel}`
@ -19,6 +20,7 @@ export const fetchData = async (
utZipUrl: string
flPdfUrl: string
utPdfUrl: string
flMp3Url: string
}
if (data.utZipUrl && data.flZipUrl) {
@ -30,6 +32,10 @@ export const fetchData = async (
setflPdfLink(data.flPdfUrl)
setutPdfLink(data.utPdfUrl)
}
if (data.flMp3Url) {
setflMp3Link(data.flMp3Url)
}
} else {
console.error('Hiba történt az API hívás során.')
}