Using JavaScript I’m trying to filter music tracks by mediaKind. Using AppleScript: “set musicVideos to every track whose media kind is music video” in a tell statement returns a list of the music videos. Using what I believe is equivalent JavaScript code: “var musicVideos = Application (“Music”).tracks.whose({“mediaKind”: {_equals: “music video”}});” returns an empty array. Using the choice of “song” as media kind (JavaScript mediaKind) also produces a populated list using AppleScript and an empty array using JavaScript. I don’t seem to have any difficulty filtering music tracks by other track properties using JavaScript.
Using JavaScript I’m trying to filter music tracks by mediaKind. Using AppleScript: “set musicVideos to every track whose media kind is music video” in a tell statement returns a list of the music videos. Using what I believe is equivalent JavaScript code: “var musicVideos = Application (“Music”).tracks.whose({“mediaKind”: {_equals: “music video”}});” returns an empty array. Using the choice of “song” as media kind (JavaScript mediaKind) also produces a populated list using AppleScript and an empty array using JavaScript. I don’t seem to have any difficulty filtering music tracks by other track properties using JavaScript.
Device: Mac Running Catalina
App: Music
—–
Dana Stevens
Not sure why whose doesn't work for you there, but you can just bypass it easily enough.
This will give you an array with the names of all music videos. Remove the .name() and you get track references instead, and you can loop through them and do things with them.
Perfect. Thanks Gary!