Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add media library operator. #3115

Merged
merged 49 commits into from
Jun 12, 2023
Merged

Add media library operator. #3115

merged 49 commits into from
Jun 12, 2023

Conversation

smimram
Copy link
Member

@smimram smimram commented May 31, 2023

We are able to do something like

m = medialib(["~/Music/"])
output(playlist.list(m.find(artist_contains="Sting")))

Before I complete it further, any comments on useablity / design?

We should be able to store the db persistently (using json) and update only new files...

@smimram smimram requested a review from toots May 31, 2023 20:33
@toots
Copy link
Member

toots commented May 31, 2023

I think that it's a great idea. What do you think of making this a separate liquidsoap-medialibrary package? Ideally, this would become a module once we have it and, perhaps, integrate with opam to have proper liquidsoap packages!

@smimram smimram changed the title Mockup for a media library. Add media library operator. Jun 1, 2023
@smimram smimram marked this pull request as ready for review June 1, 2023 21:09
Copy link
Member

@toots toots left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this an awesome idea and a tool that will be very useful to our users.

I mostly made some generic comments. I really think that this should be on its own independent opam package. Couple of reasons I can think is:

  • Visibility: the tool existence would be more obvious to the user
  • Maintainability: once people start using it, more likely than not there will be requests for improvements, bug fixes etc. Having it separate would allow for point releases without having to wait for a main release. We also try to stick to stable bugfixes on minor liquidsoap relesse. A separate package would allow to decouple development effort on this module from the main release cycles.
  • Load: we already know the standard library is too big. In fact, I think we should consider having a liquidsoap-libs-extra package for the next release.

If the scope is too limited to a separate package, we could bundle it up with other tools and make it a liquidsoap-libs-mediatools package.

doc/content/cookbook.md Outdated Show resolved Hide resolved
doc/content/cookbook.md Outdated Show resolved Hide resolved
doc/content/cookbook.md Show resolved Hide resolved
doc/dune.inc Outdated Show resolved Hide resolved
Lang.float_t
(fun p ->
let fname = List.assoc "" p |> Lang.to_string in
try Lang.float (Unix.stat fname).st_mtime with _ -> Lang.float 0.)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we return the whole stat record? Do we need user-friendly human readable attributes on the result?

let file = List.assoc "" p |> Lang.to_string in
let m = try Metadata.parse_file file with _ -> [] in
let m = List.map (fun (k, v) -> (String.lowercase_ascii k, v)) m in
Lang.metadata (Frame.metadata_of_list m))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the decoder is registered as a mresolvers plugin, this should already be declared here: https://github.com/savonet/liquidsoap/blob/main/src/core/builtins/builtins_files.ml#L473

# @method refresh Update metadatas and look for new files.
# @method add_directory Add a new directory which should be scanned.
# @method clear Remove all known metadata.
def medialib(~id=null(), ~persistency=null(), ~refresh=null(), ~standardize=fun(m)->m, ~initial_progress=true, ~directories=[], dir=null())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need tests?

src/libs/medialib.liq Show resolved Hide resolved
src/libs/medialib.liq Outdated Show resolved Hide resolved
src/libs/medialib.liq Outdated Show resolved Hide resolved
smimram and others added 5 commits June 12, 2023 13:09
Co-authored-by: Romain Beauxis <toots@rastageeks.org>
Co-authored-by: Romain Beauxis <toots@rastageeks.org>
@smimram smimram enabled auto-merge June 12, 2023 11:54
@smimram smimram disabled auto-merge June 12, 2023 11:55
@smimram smimram merged commit 5d1f151 into main Jun 12, 2023
@smimram smimram deleted the medialib branch June 12, 2023 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants