File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,4 +2,5 @@ SONARR_URL=
22RADARR_URL =
33SONARR_API_KEY =
44RADARR_API_KEY =
5- BASE_PATH =
5+ BASE_PATH =
6+ PAGE_PASSWORD =
Original file line number Diff line number Diff line change 1+ import { NextResponse } from 'next/server' ;
2+
3+ export async function POST ( req : Request ) {
4+ try {
5+ const { password } = await req . json ( ) ;
6+
7+ if ( ! password || password !== process . env . PAGE_PASSWORD ) {
8+ return NextResponse . json (
9+ { error : 'Password is required' } ,
10+ { status : 400 }
11+ ) ;
12+ }
13+
14+ const response = NextResponse . json (
15+ { success : true } ,
16+ { status : 200 }
17+ ) ;
18+
19+ response . cookies . set ( {
20+ name : 'password' ,
21+ value : password ,
22+ httpOnly : true ,
23+ secure : process . env . NODE_ENV === 'production' ,
24+ sameSite : 'strict' ,
25+ path : '/' ,
26+ maxAge : 60 * 60 * 24 * 10000
27+ } ) ;
28+
29+ return response ;
30+ } catch {
31+ return NextResponse . json (
32+ { error : 'Invalid JSON' } ,
33+ { status : 400 }
34+ ) ;
35+ }
36+ }
Original file line number Diff line number Diff line change 11import { NextResponse } from 'next/server' ;
22import { DownloadType } from '@/types/Download' ;
3- import { RadarrQueue } from '@/types/RadarrQueue ' ;
3+ import { RadarrQueue } from '@/types/Radarr ' ;
44
55export async function GET ( ) {
66 const response = await fetch ( `${ process . env . RADARR_URL } /api/v3/queue?apikey=${ process . env . RADARR_API_KEY } ` ) ;
@@ -21,7 +21,7 @@ export async function GET() {
2121 const movieName = movieData . title ;
2222 const progress = Math . round ( 100 - ( record . sizeleft / record . size * 100 ) ) ;
2323 const size = `${ ( record . size / 1024 / 1024 / 1024 ) . toFixed ( 1 ) } GB` ;
24-
24+
2525 const downloadedSize = record . size - record . sizeleft ;
2626 const addedTime = new Date ( record . added ) . getTime ( ) ; // convert added time to milliseconds
2727 const currentTime = Date . now ( ) ; // current time in milliseconds
Original file line number Diff line number Diff line change 1+ import { NextResponse } from 'next/server' ;
2+ import { SonarrHealthItem } from '@/types/Sonarr' ;
3+
4+ const PAGE_SIZE = 1000 ;
5+
6+ export async function GET ( ) {
7+ const radarrResponse = await fetch ( `${ process . env . RADARR_URL } /api/v3/health?apikey=${ process . env . RADARR_API_KEY } &pageSize=${ PAGE_SIZE } &includeSeries=true` ) ;
8+ const radarrHealthData : SonarrHealthItem [ ] = await radarrResponse . json ( ) ;
9+
10+ console . log ( "Radarr Health Data:" , radarrHealthData ) ;
11+
12+ if ( ! radarrHealthData . length ) {
13+ return NextResponse . json ( [ ] , { status : 200 } ) ;
14+ }
15+
16+ return NextResponse . json ( radarrHealthData , { status : 200 } ) ;
17+ }
Original file line number Diff line number Diff line change 1+ import { NextResponse } from 'next/server' ;
2+ import { RadarrWantedType } from '@/types/Radarr' ;
3+ import { RadarrQueue } from '@/types/Radarr' ;
4+
5+ export async function GET ( ) {
6+ const response = await fetch ( `${ process . env . RADARR_URL } /api/v3/wanted/missing?apikey=${ process . env . RADARR_API_KEY } ` ) ;
7+ const radarrData : RadarrQueue = await response . json ( ) ;
8+
9+ if ( ! radarrData . records ) {
10+ return NextResponse . json ( [ ] , { status : 200 } ) ;
11+ }
12+
13+ const responseObject : RadarrWantedType [ ] = radarrData . records . map ( ( record ) => {
14+ return {
15+ id : record . id ,
16+ title : record . title ,
17+ airDate : record . digitalRelease ,
18+ releaseDate : record . releaseDate
19+ } ;
20+ } ) ;
21+
22+ return NextResponse . json ( responseObject , { status : 200 } ) ;
23+ }
Original file line number Diff line number Diff line change 11import { NextResponse } from 'next/server' ;
22import { DownloadType } from '@/types/Download' ;
3- import { SonarrQueue } from '@/types/SonarrQueue ' ;
3+ import { SonarrQueue } from '@/types/Sonarr ' ;
44
55export async function GET ( ) {
66 const response = await fetch ( `${ process . env . SONARR_URL } /api/v3/queue?apikey=${ process . env . SONARR_API_KEY } ` ) ;
@@ -24,7 +24,7 @@ export async function GET() {
2424 const fqTitle = `${ seriesName } - S${ seasonNumber } E${ episodeNumber } ` ;
2525 const progress = Math . round ( 100 - ( record . sizeleft / record . size * 100 ) ) ;
2626 const size = `${ ( record . size / 1024 / 1024 / 1024 ) . toFixed ( 1 ) } GB` ;
27-
27+
2828 const downloadedSize = record . size - record . sizeleft ;
2929 const addedTime = new Date ( record . added ) . getTime ( ) ; // convert added time to milliseconds
3030 const currentTime = Date . now ( ) ; // current time in milliseconds
Original file line number Diff line number Diff line change 1+ import { NextResponse } from 'next/server' ;
2+ import { SonarrHealthItem } from '@/types/Sonarr' ;
3+
4+ const PAGE_SIZE = 1000 ;
5+
6+ export async function GET ( ) {
7+ const sonarrResponse = await fetch ( `${ process . env . SONARR_URL } /api/v3/health?apikey=${ process . env . SONARR_API_KEY } &pageSize=${ PAGE_SIZE } &includeSeries=true` ) ;
8+ const sonarrHealthData : SonarrHealthItem [ ] = await sonarrResponse . json ( ) ;
9+
10+ if ( ! sonarrHealthData . length ) {
11+ return NextResponse . json ( [ ] , { status : 200 } ) ;
12+ }
13+
14+ return NextResponse . json ( sonarrHealthData , { status : 200 } ) ;
15+ }
Original file line number Diff line number Diff line change 1+ import { NextResponse } from 'next/server' ;
2+ import { SonarrQueue } from '@/types/Sonarr' ;
3+
4+ const PAGE_SIZE = 1000 ;
5+
6+ export async function GET ( ) {
7+ const sonarrResponse = await fetch ( `${ process . env . SONARR_URL } /api/v3/wanted/missing?apikey=${ process . env . SONARR_API_KEY } &pageSize=${ PAGE_SIZE } &includeSeries=true` ) ;
8+ const sonarrData : SonarrQueue = await sonarrResponse . json ( ) ;
9+
10+ if ( ! sonarrData . records ) {
11+ return NextResponse . json ( [ ] , { status : 200 } ) ;
12+ }
13+
14+ const response = sonarrData . records . map ( record => ( {
15+ id : record . id ,
16+ title : `${ record . series . title } - S${ record . seasonNumber } E${ record . episodeNumber } ` ,
17+ seriesTitle : record . series . title ,
18+ releaseDate : record . airDate ,
19+ seriesId : record . seriesId
20+ } ) )
21+
22+ return NextResponse . json ( response , { status : 200 } ) ;
23+ }
You can’t perform that action at this time.
0 commit comments