Hey this used to work and now it doesn't. did something possibly change in a recent version?


#1

So this used to work in my script. though I haven’t used it in quite awhile. as I was focusing on a script to organize my music for google music. but trying it now… it gives me the error:
Wrong number of arguments for $Matchedtracks: Expected 1 - 1, got 0 at position 26 line 18. Everything else in my complete script seems to work great. but this…

i’m basically trying to determine if the album is complete or not. if it has less than 5 tracks I want it to go into a [Misc] Folder. and if it has more than 5 tracks I want it to go into a [Incomplete] folder. Otherwise my albums goto the correct folder. [Studio albums] [EPs] [Live Albums], etc.

$if($gte($matchedtracks(),$div(%totaltracks%,2)),$set(_miscorincomplete,Incomplete),$set(_miscorincomplete,Misc))
$if($gte($matchedtracks(),%totaltracks%),$unset(_miscorincomplete) $unset(_misctype))
$if($lte($sub(%totaltracks%,$matchedtracks()),1),$set(_numberofmissingtracks,$sub(%totaltracks%,$matchedtracks())$unset(_pluaralmissingtracks)))
$if($gt($sub(%totaltracks%,$matchedtracks()),1),$set(_numberofmissingtracks,$sub(%totaltracks%,$matchedtracks())$set(_pluaralmissingtracks,s)))

Thanks,
Dev


#2

I don’t know why you’d be getting that error unless perhaps they were non-album tracks and there was no release to check against? That sounds like it may be a bug, and should be reported in Jira. Perhaps you can use the $is_complete() function instead, although it might also yield an error in that situation.

$is_complete()

  • Returns 1 if every track in the album is matched to a single file and 0 otherwise.
  • Only works in File Naming scripts.

#3

$matchedtracks currently has a bug that makes it require an argument, even if it does neither need nor use it. Anything will work, even a space. So use something like $matchedtracks( ) or $matchedtracks(_). See also PICARD-637.

Also it is important to note that this only works in file naming scripts (just like $is_complete()). This is kind of logical if you know that the scripts are executed when the data is loaded from MusicBrainz and the file naming script is executed when saving files, and only in the second case the files are attached to tracks.


#4

I was not aware of that bug. Thank you. that seems to have fixed it. guess that’s what I get for not using my crazy awesome script for a couple years. as I had just been focusing on the one I’ve made for my google music specific tracks. Thank you for your help. Now I just need to find a way to force a Grouping and Genre tag based on the artist. so artists don’t have multiple genres. like the last.fm plugin likes to add.


#5

That $is_complete could come in handy as well. thank you.


#6

Yes, it is a bit special. At some point in the past Picard did not support functions without arguments at all, and $matchedtracks got a dummy argument as a workaround. But for some reason it never got fixed later :frowning: Anyway, we will merge a fix now and this will work as expected in the next release.