Skip to content

Commit

Permalink
api: ParentId can be absent or null
Browse files Browse the repository at this point in the history
  • Loading branch information
voodoos committed Apr 18, 2024
1 parent fcc5091 commit 3fa5fab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lib/data_source/jellyfin_api.ml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,10 @@ module Item = struct
id : string; [@key "Id"]
path : string option; [@yojson.option] [@key "Path"]
album_id : string option; [@yojson.option] [@key "AlbumId"]
parent_id : string option; [@yojson.option] [@key "ParentId"]
parent_id : string option option;
(* [ParentId] might absent, [null], or a string *)
[@yojson.option]
[@key "ParentId"]
server_id : string; [@key "ServerId"]
image_blur_hashes : image_blur_hashes; [@key "ImageBlurHashes"]
type_ : type_str; [@key "Type"]
Expand Down Expand Up @@ -345,7 +348,6 @@ let request (type pp p r) ?base_url ?token ?headers
let yojson = Yojson.Safe.from_string (Jstr.to_string json) in
try Q.response_of_yojson yojson
with e ->
Console.log
[ "An error occured while decoding the following response: "; yojson ];
Console.log [ "An error occured while decoding response: "; json ];
Console.log [ e ];
raise e
4 changes: 3 additions & 1 deletion lib/db/sync.ml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ let deduce_virtual_folders_from_views source (views : Views.response) =
in
List.fold_left ~init:String.Set.empty res.items
~f:(fun set { Item.parent_id; _ } ->
match parent_id with None -> set | Some pid -> String.Set.add pid set)
match parent_id with
| None | Some None -> set
| Some (Some pid) -> String.Set.add pid set)
in
let paths_of_parents parents =
let+ res =
Expand Down

0 comments on commit 3fa5fab

Please sign in to comment.