python - Getting current playing song from itunes and auto inputing into a TeamSpeak chat -


basically title says. have computer play itunes songs using vac teamspeak, type song name , artist, , possibly album, chat there in teamspeak. on windows, windows 7. if done in python prefer seeing how pretty language know. if has been done/can done in other language open whatever.

edit: when run code abarnert gave, error.

traceback (most recent call last): file "c:\users\grant\documents\allderprogramming\itunesstuffz.py", line 2, in <module> itunes = win32com.client.dispatch("itunes") file "c:\python33\lib\site-packages\win32com\client\__init__.py", line 95, in dispatch dispatch, username = dynamic._getgooddispatchandusername(dispatch,username,clsctx) file "c:\python33\lib\site-packages\win32com\client\dynamic.py", line 114, in _getgooddispatchandusername return (_getgooddispatch(idispatch, clsctx), username) file "c:\python33\lib\site-packages\win32com\client\dynamic.py", line 91, in _getgooddispatch idispatch = pythoncom.cocreateinstance(idispatch, none, clsctx, pythoncom.iid_idispatch) pywintypes.com_error: (-2147221005, 'invalid class string', none, none) 

this may not want do, if vac doesn't have way access information, don't have other choice, so:

you can now-playing information out of itunes using com interface.

first, have install sdk, may require (free) developer.apple.com membership.

next, need way talk com service python. easiest possibilities (a) use com bindings/binding generators in python windows extensions, or (b) use ironpython instead of cpython, can com interop same way other .net language.

finally, need write code information want com interface.

you can find sample code if google around, , figure out specifics want out of itunes reading documentation (in file named "itunes com interface.chm" comes sdk). pseudocode should this:

itunes = win32com.client.dispatch("itunes") track = itunes.currenttrack() return track.name(), track.artist(), track.album() 

i have no idea how input teamspeak chat, @ point, you've got 3 strings, , assume know them.


if want happen automatically whenever itunes starts new song, instead of triggering manually, @ _iitunesevents.onplayerplayevent. when fires, gives iittrack object calling currenttrack. hard part registering com events python, pywin32 has tutorials for. (if chose go ironpython/.net… i think it's easier, don't know specifics.)


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -