iTunes Plugin

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
User avatar
jitterjames
Experienced User
Posts: 677
Joined: Thu Aug 13, 2009 4:36 pm
Location: Quebec, Canada
Contact:

Re: iTunes Plugin

Post by jitterjames » Thu Jan 05, 2012 5:47 pm

Calliope99 wrote:MediaPortal Version: 1.2.1
MediaPortal Skin: StreamedMP 1.7.2
Windows Version: Seven Home Edition with SP1
CPU Type: Atom
HDD: 250Gb + 1 Tb
Memory: 2 Gb
1. TV Card: Terratec H7
1. TV Card Type: USB
TV: Panasonic 42"
TV - HTPC Connection: HDMI

Hello,
while MediaPortal is excellent in all other areas I don't like its music section and, moreover, I already have all my music well organized with iTunes so I woud like to launch iTunes from within MP to play my music or (much better, but I understand also much more difficult to implement) to use MP as an iTunes remote.
That's why I have tried more than once to configure and use the iTunes plugin, but to no avail.
I have added my iTunes Music folder to the MP music library, enabled the iTunes plugin using the MP configuration utility and set the mp3, m4a, m4p, aac extensions in its options panel ... and now what?
First of all it's not clear to me what this plugin should do: should I browse my music library with MP and then iTunes would be launched when I click "play" on a music track or should iTunes be launched when I enter the music section from the MP home screen?
Secondly it looks like the plugin is not working at all because, despite my efforts outlined above, nothing of what I have described (or anything else different-than-the-usual) happens when I click play on a music track: MP just starts playing the song as usual while iTunes stays quiet.
Any help would be much appreciated.
this plugin has nothing to do with MediaPortal

kbrown.1407
Posts: 2
Joined: Sat Jan 11, 2014 3:10 pm

Re: iTunes Plugin

Post by kbrown.1407 » Sat Jan 11, 2014 3:17 pm

A few quick (hopefully) questions. I am trying to use the iTunes plugin in conjunction with the AutoRemote plugin. The AR plugin yields results in the variable "eg.event.payload.arcomm" I would like to use these results with the iTunes plugin for the search and play and playlist by name actions. I am new to EG and python so I haven't figured out how to do so. Anyone able to provide me with some guidance? I tried saving the AR results to a global variable and then calling it but had no luck.

Also, I would like to take the results from the iTunes plugin "get information" actions and push those results through AR to display on my phone. I can't seem to find where/how these results are stored or how I can call them.

Thanks in advance and sorry for what I expect to be "noob" questions.

User avatar
jitterjames
Experienced User
Posts: 677
Joined: Thu Aug 13, 2009 4:36 pm
Location: Quebec, Canada
Contact:

Re: iTunes Plugin

Post by jitterjames » Sat Jan 11, 2014 4:52 pm

I can't help you with autoremote but I can give you a script that will hopefully help. I tested it with the broadcast plugin.

This macro will do an Itunes "Search N Play" using the payload from any event that triggers it. You can paste it directly into your EG configuration Tree.

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1572">
    <Macro Name="Search n Play" Expanded="True">
        <Event Name="Broadcast.test" />
        <Action>
            EventGhost.PythonScript(u'#test = "The Beatles"\ntest = eg.event.payload\n\neg.plugins.iTunes.SearchAndPlay(\'All\', test, True, u\'eventghostTemp\')\n ')
        </Action>
    </Macro>
</EventGhost>
To explain the script a little in case you need to adapt it:

Code: Select all

#test = "The Beatles"
test = eg.event.payload

eg.plugins.iTunes.SearchAndPlay('All', test, True, u'eventghostTemp')
Here we set a variable named test with the string we want to use in our "Search N Play".
The first line is commented out but you can see how to manually set the string for testing.
The second line shows how to set the string to the payload of the event which is triggering the macro.

To use something else like a global variable, or the event suffix etc. please take the time to read the following extremely useful page: http://www.eventghost.org/docs/scripting.html

kbrown.1407
Posts: 2
Joined: Sat Jan 11, 2014 3:10 pm

Re: iTunes Plugin

Post by kbrown.1407 » Wed Jan 15, 2014 3:12 am

Thank you! The scripting webpage gave me the info I needed to get it completed. Thanks for a point in the right direction and for the work on the plugin!

JasonLA
Posts: 2
Joined: Sun Sep 13, 2015 1:36 pm

Re: iTunes Plugin

Post by JasonLA » Fri Oct 23, 2015 5:01 pm

It seems that this plugin doesn't work anymore:

Code: Select all

18:46:54   Plugin: iTunes
18:47:14      Stack trace (most recent call last) (1694):
18:47:14        File "threading.pyc", line 504, in __bootstrap
18:47:14        File "threading.pyc", line 532, in __bootstrap_inner
18:47:14        File "threading.pyc", line 484, in run
18:47:14        File "C:\Program Files (x86)\EventGhost\eg\Classes\ThreadWorker.py", line 354, in __MainLoop
18:47:14          self.__DoOneEvent()
18:47:14        File "C:\Program Files (x86)\EventGhost\eg\Classes\ThreadWorker.py", line 326, in __DoOneEvent
18:47:14          self.HandleAction(action)
18:47:14        File "C:\Program Files (x86)\EventGhost\eg\Classes\ActionThread.py", line 87, in HandleAction
18:47:14          action()
18:47:14        File "C:\Program Files (x86)\EventGhost\eg\Classes\ThreadWorker.py", line 62, in __call__
18:47:14          self.returnValue = self.func(*self.args, **self.kwargs)
18:47:14        File "C:\Program Files (x86)\EventGhost\eg\Classes\PluginItem.py", line 100, in Execute
18:47:14          self.info.Start()
18:47:14        File "C:\Program Files (x86)\EventGhost\eg\Classes\PluginInstanceInfo.py", line 177, in Start
18:47:14          self.instance.__start__(*self.args)
18:47:14        File "C:\Program Files (x86)\EventGhost\plugins\Itunes\__init__.py", line 765, in __start__
18:47:14          self.ComActive()
18:47:14        File "C:\Program Files (x86)\EventGhost\plugins\Itunes\__init__.py", line 756, in ComActive
18:47:14          self.StartThread()
18:47:14        File "C:\Program Files (x86)\EventGhost\plugins\Itunes\__init__.py", line 748, in StartThread
18:47:14          self.workerThread.Start(20)
18:47:14        File "C:\Program Files (x86)\EventGhost\eg\Classes\ThreadWorker.py", line 125, in Start
18:47:14          self.Func(self.__setupFunc, timeout)()
18:47:14        File "C:\Program Files (x86)\EventGhost\eg\Classes\ThreadWorker.py", line 213, in Wrapper
18:47:14          eg.PrintStack()
18:47:14      Fehler beim Start des Plugins: iTunes
18:47:14      Error starting iTunes worker thread
I'm using the xbmc/kodi plugin and this works great

User avatar
jitterjames
Experienced User
Posts: 677
Joined: Thu Aug 13, 2009 4:36 pm
Location: Quebec, Canada
Contact:

Re: iTunes Plugin

Post by jitterjames » Sat Oct 24, 2015 1:15 pm

It seems that it is not working on your system but it is working for me.

I just tested using iTunes 12.3.1.23 and EventGhost 0.4.1.r1700 on Win7 x64

Unfortunately I don't see anything obvious from that error to know what the problem might be.

juanalei
Posts: 18
Joined: Fri Jul 22, 2011 8:32 am
Location: España

Re: iTunes Plugin

Post by juanalei » Wed Jun 14, 2017 6:51 pm

scottbakertemp wrote:Would it be possible to enable or disable airplay devices? It would be awesome if I could use this to start a playlist and then switch which airport expresses are playing.

thanks for all the work,
-Scott
Did you finally get it?

User avatar
Boolean263
Plugin Developer
Posts: 81
Joined: Sat Aug 12, 2017 7:52 pm
Location: Ottawa, Canada
Contact:

Re: iTunes Plugin

Post by Boolean263 » Sat Aug 19, 2017 2:05 am

I found this plugin a few days ago, and I'm glad to say it still works. The fact that its last release was a few years ago worried me a bit, so I decided to copy it to github and play with it. The result is attached.

The changes are mostly minor, but they're things I thought were missing from the plugin:
  • Add more info to the TrackChanged event: media kind, composer, comment, and genre
  • Added a StreamTrackChanged event, that gets triggered when a web radio stream changes the song title
  • Added a Stopped event when the user stops iTunes
  • Play/Pause toggle (this was really trivial)
  • A bit of refactoring
I've put my work up for all to see on Boolean263/EventGhost-iTunes on github. It's seeded from the last release cfull1 made. If cfull1, jitterjames, and/or stottle have an official home for the plugin code, let me know and I'll link to it, and cease my fork in favour of contributing to it.
juanalei wrote:Did you finally get it?
So far I haven't found any API calls about AirPlay. I can keep looking, though.
Attachments
iTunes-0.1.12.egplugin
(12.84 KiB) Downloaded 92 times
Windows 10 Home, version 1703, build 15063.540 · EventGhost 0.5.0-rc4 · wxPython 3.0.2.0
Python programmer for fun and profit. Dabbler in EventGhost plugin writing. Wiki gardener. General geek.

GUILTIE
Posts: 2
Joined: Sun Aug 20, 2017 8:58 pm

Re: iTunes Plugin

Post by GUILTIE » Mon Aug 21, 2017 4:17 pm

I am not a programmer so can anyone help me understand this error?
Error in Action: "iTunes: Load Playlist: Loved Songs"
Traceback (most recent call last) (1722):
File "C:\Program Files (x86)\EventGhost\eg\Classes\ActionBase.py", line 170, in CallWrapper
return self(*args)
File "C:\ProgramData\EventGhost\plugins\iTunes3\__init__.py", line 281, in __call__
return self.plugin.CallThread(partial(self.plugin.workerThread.doLoadPlaylist,plname,self.value))
AttributeError: 'NoneType' object has no attribute 'doLoadPlaylist'

User avatar
Boolean263
Plugin Developer
Posts: 81
Joined: Sat Aug 12, 2017 7:52 pm
Location: Ottawa, Canada
Contact:

Re: iTunes Plugin

Post by Boolean263 » Tue Aug 22, 2017 2:45 pm

GUILTIE wrote:I am not a programmer so can anyone help me understand this error?
Well, without getting too technical, the plugin is trying to ask its worker thread to load the playlist, but the worker thread doesn't exist.

Can you list the steps you took that led to this error appearing? It'll help me track it down and try to fix it. Include things like whether iTunes is already open or not when you do the thing.

Edit: Never mind, I've been able to recreate that issue myself. Looks like I got too clever in my refactoring. :| I'll try to fix it. In the meantime, the last release before I started ruining it should get you going again.
Windows 10 Home, version 1703, build 15063.540 · EventGhost 0.5.0-rc4 · wxPython 3.0.2.0
Python programmer for fun and profit. Dabbler in EventGhost plugin writing. Wiki gardener. General geek.

User avatar
Boolean263
Plugin Developer
Posts: 81
Joined: Sat Aug 12, 2017 7:52 pm
Location: Ottawa, Canada
Contact:

Re: iTunes Plugin

Post by Boolean263 » Tue Aug 22, 2017 4:56 pm

There, this version should fix it. Let me know!

I've also added a notice when the playlist actions are called with a playlist name that can't be found in iTunes.
Attachments
iTunes-0.1.13.egplugin
(29.4 KiB) Downloaded 84 times
Windows 10 Home, version 1703, build 15063.540 · EventGhost 0.5.0-rc4 · wxPython 3.0.2.0
Python programmer for fun and profit. Dabbler in EventGhost plugin writing. Wiki gardener. General geek.

GUILTIE
Posts: 2
Joined: Sun Aug 20, 2017 8:58 pm

Re: iTunes Plugin

Post by GUILTIE » Sun Aug 27, 2017 7:26 pm

Works brilliantly now, thank you!! I am glad you were able to fix it; I could not have told you the steps I took to cause the problem before. It worked fine... then just started giving me that error even after restarting iTunes, EventGhost, and the PC.

User avatar
yokel22
Experienced User
Posts: 265
Joined: Thu Feb 05, 2015 5:56 pm
Location: U.S. - Kansas city

Re: iTunes Plugin

Post by yokel22 » Mon Aug 28, 2017 3:37 pm

Boolean263, i added a bunch of stuff to this plugin a while back but never officially posted it in this thread. I don't recall everything i added, but i think everything you did plus some other functions that were useful for writing the web App here. viewtopic.php?f=13&t=9487.

Forum uploads seem to be broken at the moment. So this is a dropbox link to it. https://www.dropbox.com/s/s6x34likja81w ... __.py?dl=1

Just to comment on the airplay question. The comm library that this plugin uses is really out of date & apple won't likely be releasing an updated windows sdk anytime soon. There are no commands for controlling airplay zones, last update was 2007, pre airplay. Believe me, i'd love to have these controls too. The only way i see it happening is to write a bonjour client or pigiback off of other airplay software. Alternatively i've been using mouse/keyboard emulation for a while to toggle airplay zones. This works fine, as long as your airplay clients don't change position in the iTunes drop down list

User avatar
Boolean263
Plugin Developer
Posts: 81
Joined: Sat Aug 12, 2017 7:52 pm
Location: Ottawa, Canada
Contact:

Re: iTunes Plugin

Post by Boolean263 » Mon Aug 28, 2017 4:45 pm

yokel22 wrote:Boolean263, i added a bunch of stuff to this plugin a while back but never officially posted it in this thread. I don't recall everything i added, but i think everything you did plus some other functions that were useful for writing the web App here. [...]
yokel22, that's awesome! Those are some great changes, thank you so much for sharing them! I've added them to "my" version above. I'll post it as a .egplugin once the forum's fixed (edit: looks like it's working now), but for now you can see it on the github page. (Here's the commit if you want to make sure I did it right!)

I may try to make the rating selection dialog a bit prettier, if that's okay with you. (:
yokel22 wrote:Just to comment on the airplay question. The comm library that this plugin uses is really out of date & apple won't likely be releasing an updated windows sdk anytime soon. There are no commands for controlling airplay zones, last update was 2007, pre airplay. Believe me, i'd love to have these controls too. The only way i see it happening is to write a bonjour client or pigiback off of other airplay software. Alternatively i've been using mouse/keyboard emulation for a while to toggle airplay zones. This works fine, as long as your airplay clients don't change position in the iTunes drop down list
Good to know, thank you for the update. I'm sure people would appreciate a tutorial on the mouse/keyboard emulation you've set up, possibly in the Tutorials & Guides section.
Attachments
iTunes-0.1.15.egplugin
(13.98 KiB) Downloaded 80 times
Last edited by Boolean263 on Tue Aug 29, 2017 1:11 am, edited 1 time in total.
Windows 10 Home, version 1703, build 15063.540 · EventGhost 0.5.0-rc4 · wxPython 3.0.2.0
Python programmer for fun and profit. Dabbler in EventGhost plugin writing. Wiki gardener. General geek.

User avatar
yokel22
Experienced User
Posts: 265
Joined: Thu Feb 05, 2015 5:56 pm
Location: U.S. - Kansas city

Re: iTunes Plugin

Post by yokel22 » Mon Aug 28, 2017 5:30 pm

Feel free to change any of it. I was just trying to save you some time. As it looked like you were planning on adding some other stuff.

Post Reply