|
1 |
| -import { NextResponse } from 'next/server'; |
2 | 1 | import { Feed } from 'feed';
|
3 | 2 |
|
4 | 3 | const YOUTUBE_API_KEY = process.env.YOUTUBE_API_KEY as string;
|
@@ -71,21 +70,28 @@ export async function GET() {
|
71 | 70 | data.items.forEach(item => {
|
72 | 71 | feed.addItem({
|
73 | 72 | title: item.snippet.title,
|
74 |
| - id: item.snippet.resourceId.videoId, |
| 73 | + content: item.snippet.description || '', |
75 | 74 | link: `https://www.youtube.com/watch?v=${item.snippet.resourceId.videoId}`,
|
76 | 75 | description: item.snippet.description,
|
77 |
| - date: new Date(item.snippet.publishedAt), |
78 | 76 | image: `https://img.youtube.com/vi/${item.snippet.resourceId.videoId}/maxresdefault.jpg`,
|
| 77 | + date: new Date(item.snippet.publishedAt), |
| 78 | + id: item.snippet.resourceId.videoId, |
79 | 79 | });
|
80 | 80 | });
|
81 | 81 |
|
82 | 82 | pageToken = data.nextPageToken;
|
83 | 83 | } while (pageToken);
|
84 | 84 | }
|
85 | 85 |
|
86 |
| - return NextResponse.json(JSON.parse(feed.json1())); |
| 86 | + return new Response(feed.rss2(), { |
| 87 | + headers: { |
| 88 | + "content-type": "text/xml", |
| 89 | + "cache-control": "max-age=0, s-maxage=3600", |
| 90 | + }, |
| 91 | + }); |
| 92 | + |
87 | 93 | } catch (error) {
|
88 | 94 | console.error('Error generating podcast feed:', error);
|
89 |
| - return NextResponse.json({ error: 'Error generating podcast feed' }, { status: 500 }); |
| 95 | + return Response.json({ error: 'Error generating podcast feed' }, { status: 500 }); |
90 | 96 | }
|
91 | 97 | }
|
0 commit comments