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

2.3.0 - check_next doesn't read metadata #3864

Closed
gAlleb opened this issue Apr 8, 2024 · 7 comments
Closed

2.3.0 - check_next doesn't read metadata #3864

gAlleb opened this issue Apr 8, 2024 · 7 comments
Labels

Comments

@gAlleb
Copy link
Contributor

gAlleb commented Apr 8, 2024

I'm trying to make check_next work in 2.3.0. It works ok with default filename (with no extra parameters specified). But if I want to reject tracks by title/artist/etc... - it starts looping because metadata always returns empty. Log:

  [
  "",
  1712487606.54
]

In 2.2.5 - All is good.

Reproduction (every 2.3.0 version - packages and opam):

def hash_artist(m)
      metadata.artist(m)
end

l = playlog(persistency="check.log", duration=10000., hash=hash_artist)
def check(r)
      m = request.metadata(r)
  if l.last(m) < 7000. then
      log(level=3,"#{m['artist']} has played #{l.last(m)}s ago. Rejecting...")
      false
  else
      l.add(m)
      true
  end
end
@gAlleb gAlleb added the usage label Apr 8, 2024
@vitoyucepi
Copy link
Collaborator

Hi @gAlleb,
I'd like to point out that check_next is called before the request is resolved. So there will be no metadata until the request is resolved.
Ref: #3625.
I don't remember exactly why I created this issue, but it seems I have a lot of garbage in the music directory and want to discard files before decoding.

@gAlleb
Copy link
Contributor Author

gAlleb commented Apr 8, 2024

Hi, @vitoyucepi!

Hm. So many questions then. Why it works ok in 2.2.u-name-it? Why (when using autocue2 e.g. with 2.2.u-name-it) autocue nevertheless processes files and then track gets rejected if it's not due to play?

What should be done to make it work in 2.3.0?

@vitoyucepi
Copy link
Collaborator

Why it works ok in 2.2.u-name-it?

The behavior in 2.2.x hasn't been changed.

What should be done to make it work in 2.3.0?

Try request.resolve(r) in your function, before request.metadata(r). Remember to handle the result of the resolve properly.

@gAlleb
Copy link
Contributor Author

gAlleb commented Apr 8, 2024

I've tried something like this (and a bunch of different iterations) but result is the same.

def check(r)
        request.uri(r) 
        log.critical(label="request.uri","#{request.uri(r)}")
	if request.resolve(r) then
        log.critical(label="request.resolve","#{request.resolve(r)}")
	m = request.metadata(r)
        log.critical(label="request.metadata","#{request.metadata(r)}")
        if l.last(m) < 7000. then
	   log(level=3,"Rejecting")
	   false
        else
	  l.add(m)
	  true
        end
  else
  false
  end

end
2024/04/08 20:30:21 [request.uri:1] /Users/(2018) - Reiki Gold 2 [320]/04. Reiki Stillness and Rest.mp3
2024/04/08 20:30:21 [request.resolve:1] true
2024/04/08 20:30:21 [request.metadata:1] [("filename", "/Users/(2018) - Reiki Gold 2 [320]/04. Reiki Stillness and Rest.mp3"), ("initial_uri", "/Users/(2018) - Reiki Gold 2 [320]/04. Reiki Stillness and Rest.mp3"), ("rid", "11532"), ("status", "ready"), ("temporary", "false")]
2024/04/08 20:30:21 [lang:3] Rejecting

What am I doing wrong?

@toots
Copy link
Member

toots commented Apr 8, 2024

Could be another regression. I'll have a look shortly, thanks for reporting.

@vitoyucepi
Copy link
Collaborator

Ref: 28cceec, 03f65e8, 25e7189, #3874, d2a38cf

@gAlleb
Copy link
Contributor Author

gAlleb commented Apr 17, 2024

Many thanks!

@gAlleb gAlleb closed this as completed Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants