about summary refs log tree commit diff
path: root/users
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2024-08-24T12·15+0200
committerProfpatsch <mail@profpatsch.de>2024-09-13T11·13+0000
commit861b7caa0669cf0f3a2b2295640d31c0735fdf67 (patch)
tree89e70ce836d67bb74dbc925708ea5ed42f6c4fae /users
parent95640e7be49cc533bef2e182b80a1f8d1a5dcb35 (diff)
feat(users/Profpatsch/whatcd-resolver): add format to table r/8679
Change-Id: I6ca18ad9f73a8e75e4bfb77156d19604ab27b284
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12331
Tested-by: BuildkiteCI
Reviewed-by: Profpatsch <mail@profpatsch.de>
Diffstat (limited to 'users')
-rw-r--r--users/Profpatsch/whatcd-resolver/src/Redacted.hs17
-rw-r--r--users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs3
2 files changed, 15 insertions, 5 deletions
diff --git a/users/Profpatsch/whatcd-resolver/src/Redacted.hs b/users/Profpatsch/whatcd-resolver/src/Redacted.hs
index 692a1a359a7f..fda577d2a044 100644
--- a/users/Profpatsch/whatcd-resolver/src/Redacted.hs
+++ b/users/Profpatsch/whatcd-resolver/src/Redacted.hs
@@ -365,7 +365,8 @@ data TorrentData transmissionInfo = TorrentData
     seedingWeight :: Int,
     artists :: [T2 "artistId" Int "artistName" Text],
     torrentGroupJson :: TorrentGroupJson,
-    torrentStatus :: TorrentStatus transmissionInfo
+    torrentStatus :: TorrentStatus transmissionInfo,
+    torrentFormat :: Text
   }
 
 data TorrentGroupJson = TorrentGroupJson
@@ -427,7 +428,8 @@ getBestTorrents opts = do
         tg.full_json_result->>'groupName' AS group_name,
         tg.full_json_result->>'groupYear' AS group_year,
         t.torrent_file IS NOT NULL AS has_torrent_file,
-        t.transmission_torrent_hash
+        t.transmission_torrent_hash,
+        t.full_json_result->>'encoding' AS torrent_format
       FROM filtered_torrents f
       JOIN redacted.torrents t ON t.id = f.id
       JOIN redacted.torrent_groups tg ON tg.id = t.torrent_group
@@ -456,8 +458,8 @@ getBestTorrents opts = do
           groupYear <- Dec.textParse Field.decimalNatural
           pure $ TorrentGroupJson {..}
         hasTorrentFile <- Dec.fromField @Bool
-        transmissionTorrentHash <-
-          Dec.fromField @(Maybe Text)
+        transmissionTorrentHash <- Dec.fromField @(Maybe Text)
+        torrentFormat <- Dec.text
         pure $
           TorrentData
             { torrentStatus =
@@ -467,6 +469,13 @@ getBestTorrents opts = do
                   | Just hash <- transmissionTorrentHash ->
                       InTransmission $
                         T2 (label @"torrentHash" hash) (label @"transmissionInfo" ()),
+              torrentFormat = case torrentFormat of
+                "Lossless" -> "flac"
+                "V0 (VBR)" -> "V0"
+                "V2 (VBR)" -> "V2"
+                "320" -> "320"
+                "256" -> "256"
+                o -> o,
               ..
             }
     )
diff --git a/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs b/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs
index 49ac03693917..04c34c7859d6 100644
--- a/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs
+++ b/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs
@@ -630,6 +630,7 @@ mkBestTorrentsTable fresh = do
                   </td>
                   <td>{Html.toHtml @Natural b.torrentGroupJson.groupYear}</td>
                   <td>{Html.toHtml @Int b.seedingWeight}</td>
+                  <td>{Html.toHtml @Text b.torrentFormat}</td>
                   <td><details hx-trigger="toggle once" hx-post="snips/redacted/torrentDataJson" hx-vals={Enc.encToBytesUtf8 $ Enc.object [("torrent-id", Enc.int b.torrentId)]}></details></td>
                   </tr>
                 |]
@@ -644,8 +645,8 @@ mkBestTorrentsTable fresh = do
               <th>Name</th>
               <th>Year</th>
               <th>Weight</th>
+              <th>Format</th>
               <th>Torrent</th>
-              <th>Torrent Group</th>
             </tr>
           </thead>
           <tbody>