package shakuhachi
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
A music collection manager
Install
dune-project
Dependency
Authors
Maintainers
Sources
0.2.0.tar.gz
sha256=966fc8667c2aa9830e64950d2de74bd564a65d60e1f50cfd3dc1e99ef106dc47
sha512=6423ce04d784ba521a7f49fabdafbe036e2dd80cd08ca999fdc6767262d7f12aa4e5002d65efd4c568b343eaabf4d680191c88334d629e1ca0156084531e9e0b
doc/src/shakuhachi.query/field.ml.html
Source file field.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256(*****************************************************************************) (* *) (* Copyright (C) 2026 Yves Ndiaye *) (* *) (* This Source Code Form is subject to the terms of the Mozilla Public *) (* License, v. 2.0. If a copy of the MPL was not distributed with this *) (* file, You can obtain one at https://mozilla.org/MPL/2.0/. *) (* *) (*****************************************************************************) let sformat regex insensible key value = let key = match insensible with true -> key | false -> "%" ^ key in let colon = match regex with true -> "::" | false -> ":" in Printf.sprintf "%s%s%s" key colon value let format = Printf.sprintf "%s:%s" module String = struct type field = | Title of string | SortName of string | Artist of string | Album of string | AlbumArtist of string | Composer of string | Genre of string | Path of string | FileExtension of string type t = { regex : bool; insensible : bool; field : field } let title regex insensible s = { regex; insensible; field = Title s } let sort_name regex insensible s = { regex; insensible; field = SortName s } let artist regex insensible s = { regex; insensible; field = Artist s } let album regex insensible s = { regex; insensible; field = Album s } let album_artist regex insensible s = { regex; insensible; field = AlbumArtist s } let composer regex insensible s = { regex; insensible; field = Composer s } let genre regex insensible s = { regex; insensible; field = Genre s } let path regex insensible s = { regex; insensible; field = Path s } let extension regex insensible s = { regex; insensible; field = FileExtension s } let to_string s = let { regex; insensible; field } = s in let key, value = match field with | Title s -> (Keys.title, s) | SortName s -> (Keys.sort_name, s) | Artist s -> (Keys.artist, s) | Album s -> (Keys.album, s) | AlbumArtist s -> (Keys.album_artist, s) | Composer s -> (Keys.composer, s) | Genre s -> (Keys.genre, s) | Path s -> (Keys.path, s) | FileExtension s -> (Keys.extension, s) in sformat regex insensible key value let to_sexp s = let { regex; insensible; field } = s in let key, value = match field with | Title s -> (Keys.title, s) | SortName s -> (Keys.sort_name, s) | Artist s -> (Keys.artist, s) | Album s -> (Keys.album, s) | AlbumArtist s -> (Keys.album_artist, s) | Composer s -> (Keys.composer, s) | Genre s -> (Keys.genre, s) | Path s -> (Keys.path, s) | FileExtension s -> (Keys.extension, s) in sformat regex insensible key (Util.quote value) let regex s = s.regex let insensible s = s.insensible let field s = s.field end module Bool = struct type t = Art of bool | Flag of bool let art b = Art b let flag b = Flag b let to_string s = let key, value = match s with Art b -> (Keys.art, b) | Flag b -> (Keys.flag, b) in format key (Bool.to_string value) let to_sexp = to_string end module Int = struct type t = | Id of int64 Range.t | Size of int64 Range.t | Track of int Range.t | Year of int Range.t | Disc of int Range.t | Plays of int Range.t | Length of int Range.t (* in secondes *) | Rating of int Range.t | AlbumCount of int Range.t let id r = Id r let size r = Size r let track r = Track r let year r = Year r let disc r = Disc r let plays r = Plays r let length r = Length r let rating r = Rating r let album_count r = AlbumCount r let to_string = function | Id r -> format Keys.id (Range.to_string Int64.to_string r) | Size r -> format Keys.size (Range.to_string Int64.to_string r) | Track r -> format Keys.track (Range.to_string Int.to_string r) | Year r -> format Keys.year (Range.to_string Int.to_string r) | Disc r -> format Keys.disc (Range.to_string Int.to_string r) | Plays r -> format Keys.plays (Range.to_string Int.to_string r) | Length r -> format Keys.length (Range.to_string Int.to_string r) | Rating r -> format Keys.rating (Range.to_string Int.to_string r) | AlbumCount r -> format Keys.album_count (Range.to_string Int.to_string r) let to_sexp = to_string end module Float = struct type t = | AvgDuration of float Range.t | AvgRating of float Range.t | AvgSize of float Range.t let avg_duration r = AvgDuration r let avg_rating r = AvgRating r let avg_size r = AvgSize r let to_string f = let variable, range = match f with | AvgDuration f -> (Keys.avg_duration, f) | AvgRating f -> (Keys.avg_rating, f) | AvgSize f -> (Keys.avg_size, f) in format variable (Range.to_string Float.to_string range) let to_sexp = to_string end type t = | FString of String.t | FBool of Bool.t | FInt of Int.t | FFloat of Float.t let string s = FString s let bool b = FBool b let int i = FInt i let float f = FFloat f (* String *) let title regex insensible s = string (String.title regex insensible s) let sort_name regex insensible s = string (String.sort_name regex insensible s) let artist regex insensible s = string (String.artist regex insensible s) let album regex insensible s = string (String.album regex insensible s) let album_artist regex insensible s = string (String.album_artist regex insensible s) let composer regex insensible s = string (String.composer regex insensible s) let genre regex insensible s = string (String.genre regex insensible s) let path regex insensible s = string (String.path regex insensible s) let extension regex insensible s = string (String.extension regex insensible s) (* Bool *) let art r = bool (Bool.art r) let flag r = bool (Bool.flag r) (* Int *) let id i = int (Int.id i) let track r = int (Int.track r) let year r = int (Int.year r) let disc r = int (Int.disc r) let length r = int (Int.length r) let plays r = int (Int.plays r) let size r = int (Int.size r) let rating r = int (Int.rating r) let album_count r = int (Int.album_count r) (* Float *) let avg_duration r = float (Float.avg_duration r) let avg_rating r = float (Float.avg_rating r) let avg_size r = float (Float.avg_size r) let to_string = function | FString s -> String.to_string s | FBool b -> Bool.to_string b | FInt i -> Int.to_string i | FFloat f -> Float.to_string f let to_sexp = function | FString s -> String.to_sexp s | FBool b -> Bool.to_string b | FInt i -> Int.to_string i | FFloat f -> Float.to_string f let is_string = function | FString _ -> true | FBool _ | FInt _ | FFloat _ -> false
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>