@@ -343,26 +343,31 @@ async fn ntf_watchlist_force(
343
343
let json_data = r#"{"enabled": true,"libraries": [],"identifier": "tv.plex.notification.library.new"}"# ;
344
344
let client = reqwest:: Client :: new ( ) ;
345
345
346
- println ! ( "Bootstrao for request: {} platform: {} product: {} device name: {}" ,
346
+ dbg ! ( "Bootstrao for request: {} platform: {} product: {} device name: {}" ,
347
347
params. clone( ) . username. unwrap_or_default( ) ,
348
348
params. clone( ) . platform,
349
349
params. clone( ) . product. unwrap_or_default( ) ,
350
350
params. clone( ) . device_name. unwrap_or_default( )
351
351
) ;
352
352
353
353
let client_base = "https://clients.plex.tv" ;
354
- let user : PlexUser = client
354
+ let res = client
355
355
. get ( format ! ( "{}/api/v2/user" , client_base) )
356
356
. header ( "Accept" , "application/json" )
357
357
. header ( "X-Plex-Token" , & token)
358
358
. header ( "X-Plex-Client-Identifier" , & client_id)
359
359
. send ( )
360
360
. await
361
- . unwrap ( )
362
- . json ( )
363
- . await
364
361
. unwrap ( ) ;
362
+
363
+ if !res. status ( ) . is_success ( ) {
364
+ dbg ! ( "cannot get user" ) ;
365
+ return ;
366
+ }
367
+
368
+ let user: PlexUser = res. json ( ) . await . unwrap ( ) ;
365
369
dbg ! ( & user) ;
370
+
366
371
let response = client
367
372
. post ( url)
368
373
. header ( "Content-Type" , "application/json" )
@@ -395,7 +400,7 @@ async fn ntf_watchlist_force(
395
400
. await
396
401
. unwrap ( ) ;
397
402
398
- println ! ( "Set opt out status: {}" ,
403
+ dbg ! ( "Set opt out status: {}" ,
399
404
& response. status( )
400
405
) ;
401
406
0 commit comments