Lost in iTunes

Posted on
Wed Sep 27, 2017 9:34 am
Different Computers offline
User avatar
Posts: 2578
Joined: Jan 02, 2016
Location: East Coast

Lost in iTunes

Hey all,

I just tried to start understanding viewtopic.php?f=107&t=13889&start=15 and, well, I failed. Is it even the right direction to go in order to duplicate this typical functionality?

Code: Select all
tell application "iTunes"
   if player state = playing then
      --copy (get rating of current track) to trackRating
      -- repeat with theTrack in (get selection)
      set the rating of current track to ((rating of current track) - 20)
      set trackRating to (rating of current track)
      tell application "IndigoServer"
         set value of variable "iTunesStars" to trackRating / 20
      end tell
      -- end repeat
   end if
end tell


Short version of that code: It's an example of one of several things about iTunes that the iTunes integration doesn't cover. So now I'm wondering how to get and manipulate these values with Python. I get that it's the last "tell" that is the part that has to move to Python. But can I do it all in Python?

Sonoma on a Mac Mini M1 running Airfoil Pro, Bond Home, Camect, Roku Network Remote, Hue Lights, DomoPad, Adapters, Home Assistant Agent, HomeKitLinkSiri, EPS Smart Dimmer, Fantastic Weather, Nanoleaf, LED Simple Effects, Grafana. UnifiAP

Posted on
Wed Sep 27, 2017 11:00 am
jay (support) offline
Site Admin
User avatar
Posts: 18246
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Lost in iTunes

If you install the py-applescript module (which will ship with Indigo 7.1) as described in the AppleScript blog post, then this script will get the rating of the current track and insert it into a variable:

Code: Select all
import applescript
script_source = '''
tell application "iTunes"
    rating of current track
end tell
'''
compiled_script = applescript.AppleScript(source=script_source)
reply = compiled_script.run()
indigo.variable.updateValue(VARIDHERE, value=str(reply))


The value inserted in the variable will be whatever is returned by "rating of current track".

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Sep 27, 2017 1:48 pm
norcoscia offline
User avatar
Posts: 1208
Joined: Sep 09, 2015

Re: Lost in iTunes

Is it possible to locate any items that contain any AppleScript w/o manually opening and looking in the 5 million places I might have cut and pasted some of it into - pls say yes, pls say there will be a zippy dippy AppleScript locater thingy in Indigo 7.1

_______
Norm

Posted on
Wed Sep 27, 2017 2:56 pm
jay (support) offline
Site Admin
User avatar
Posts: 18246
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Lost in iTunes

We're looking in to it. It may not be part of the 7.1.0 release, but we'll look at doing something in the 7.1.x releases or potentially a separate script that just runs against an Indigo database file. But we'll figure something out.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Sep 27, 2017 3:39 pm
norcoscia offline
User avatar
Posts: 1208
Joined: Sep 09, 2015

Re: Lost in iTunes

Wow, cool - thx so much!

_______
Norm

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests