feat(users/Profpatsch/whatcd-resolver): display all artists

apparently the `torrent_group` json only contains one artist, while
the torrent itself contains a list of them.

This is important, because we need the artist id and the
`torrent_group` does not provide it, only the torrent one.

Change-Id: I3db45f454f14e89ea8c8dafba2065ecd55f5bcda
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11670
Autosubmit: Profpatsch <mail@profpatsch.de>
Tested-by: BuildkiteCI
Reviewed-by: Profpatsch <mail@profpatsch.de>
This commit is contained in:
Profpatsch 2024-05-14 20:42:13 +02:00 committed by clbot
parent 7197d28098
commit c1598cd2d2
2 changed files with 29 additions and 8 deletions

View file

@ -360,8 +360,9 @@ data TorrentData transmissionInfo = TorrentData
{ groupId :: Int,
torrentId :: Int,
seedingWeight :: Int,
artists :: [T2 "artistId" Int "artistName" Text],
torrentJson :: Json.Value,
torrentGroupJson :: T3 "artist" Text "groupName" Text "groupYear" Int,
torrentGroupJson :: T2 "groupName" Text "groupYear" Int,
torrentStatus :: TorrentStatus transmissionInfo
}
@ -409,13 +410,18 @@ getBestTorrents opts = do
groupId <- Dec.fromField @Int
torrentId <- Dec.fromField @Int
seedingWeight <- Dec.fromField @Int
torrentJson <- Dec.json Json.asValue
(torrentJson, artists) <- Dec.json $ do
val <- Json.asValue
artists <- Json.keyOrDefault "artists" [] $ Json.eachInArray $ do
id_ <- Json.keyLabel @"artistId" "id" (Json.asIntegral @_ @Int)
name <- Json.keyLabel @"artistName" "name" Json.asText
pure $ T2 id_ name
pure (val, artists)
torrentGroupJson <-
( Dec.json $ do
artist <- Json.keyLabel @"artist" "artist" Json.asText
groupName <- Json.keyLabel @"groupName" "groupName" Json.asText
groupYear <- Json.keyLabel @"groupYear" "groupYear" (Json.asIntegral @_ @Int)
pure $ T3 artist groupName groupYear
pure $ T2 groupName groupYear
)
hasTorrentFile <- Dec.fromField @Bool
transmissionTorrentHash <-