Re: get lyrics from Music app
Re: get lyrics from Music app
- Subject: Re: get lyrics from Music app
- From: Jim Weisbin via AppleScript-Users <email@hidden>
- Date: Mon, 7 Nov 2022 09:14:38 -0500
However, with this script I can only read the lyrics if I “own” the track and
it’s on my hard drive. If it’s a track that I have access to via a subscription
to Apple Music, then the properties list does not return any lyrics, even
though you can see them in “get info”.
> On Nov 6, 2022, at 10:01 PM, Jim Weisbin <email@hidden> wrote
>
> This was an easy fix.
>
>> set results to (every file track whose name contains theName)
> Changed that to
> set results to (every file track whose name is theName)
> and
>> set results to (every file track whose id contains myID)
> changed to
> set results to (every file track whose id is myID)
>
> Now it?s fast
>
> Thanks all.
>
>
>> Begin forwarded message:
>>
>> On November 6, 2022 at 5:21:46 PM EST, Jim Weisbin <email@hidden>
>> wrote
>>
>> So this actually works, but it?s slow. The reason is, I have to first get a
>> list of tracks that match the user?s input, then have the user choose from
>> that list of names and ID's. I have to somehow tie the ID to the name the
>> user chooses, but I can?t just have the user choose from the ?results?
>> array, because no names in there. So I make a separate array of names and
>> ID?s and then have the user choose one, and then I have to search for that
>> ID, which is the slow part. If anyone knows a better way please let me know.
>>
>> set theName to the text returned of (display dialog "What is the track
>> name?" default answer "")
>> -- display dialog theName
>> tell application "Music"
>> activate
>> set myTrackList to {}
>> set myNameList to {}
>> try
>> set results to (every file track whose name is theName)
>> on error
>> beep
>> display dialog "nothing found"
>> return
>> end try
>> repeat with i in results
>> set my_track to i
>> set myProperties to get properties of i
>> set myName to get name of myProperties
>> set myTrackID to get id of myProperties
>> set myRecord to myName & "::" & myTrackID
>> copy myRecord to the end of myNameList
>> end repeat
>> set theArray to {}
>> set myID to {}
>> if myNameList is equal to {} then
>> beep
>> display dialog "nothing found"
>> return
>> end if
>> set myNameChoice to choose from list myNameList
>> set oldDelimiters to AppleScript's text item delimiters
>> set AppleScript's text item delimiters to "::"
>> set theArray to every text item of myNameChoice as string
>> set myID to last text item of theArray
>> --display dialog myID
>> set AppleScript's text item delimiters to oldDelimiters
>> set results to (every file track whose id is myID)
>> set my_track to first item of results
>> set myProperties to get properties of my_track
>> set myLyrics to get lyrics of myProperties
>> if myLyrics is equal to "" then
>> beep
>> display dialog "no lyrics found"
>> else
>> set the clipboard to myLyrics
>> tell application "System Events" to tell process "Finder"
>> set frontmost to true
>> click menu item "show Clipboard" of menu "Edit" of menu
>> bar 1
>> end tell
>> end if
>> end tell
>
Jim Weisbin | C.T.O. | Human | Post Human | 27 West 20th Street | Suite 801 |
New York, NY | 10011 | (917) 375-2272 | 2046 Broadway | Santa Monica, CA |
90404
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden