Genius Playlist Plugin
#1
Ok so I have an idea for a plugin I want to develop and an idea of how it might work, but am a little fuzzy on the details, whether its posisble and whether there would be an easier way of doing this.

What i really want to do is be able to press 'c' and one of the options is generate a genius playlist

this fires off a python script that sends the selected file to an applescript

the applescript finds that file in the itunes library, selects it and generates a genius playlist

the applescript then get the contents of the playlists and sends it back to the python script

the python script then builds the playlist and takes the user to it in the library.

I know this is specifically a mac feature but I thought I saw somewhere there is a windows equivalent to applescript, maybe I am mistaken?

Or maybe it doesn't need that layer and the python can interact directly with itunes?

What do you think?
Reply
#2
so after doing some research i found appscript a python module that is a
Quote:user-friendly Apple event bridge that allows you to control scriptable Mac OS X applications using ordinary Python scripts

Is there any chance this could become a feature of xbmc for osx python scripting (is it already?)

It has potential beyond this idea and would much more easily allow scripts that interact with osx
Reply
#3
msaspence Wrote:so after doing some research i found appscript a python module that is a

Is there any chance this could become a feature of xbmc for osx python scripting (is it already?)

It has potential beyond this idea and would much more easily allow scripts that interact with osx

totally possible, just get access to the module and include it in your xbmc distro directly, or if possible include the module in the python scripts directory. of course it would probably work only for mac but im sure thats what you are looking for. from my understanding, python for xbmc is just like regular python in all respects, so anything you can do in python you can do in xbmc

good luck
Reply
#4
PyApplescript is just a python module. If you look at the example page (http://appscript.sourceforge.net/py-apps...mples.html), all you need to do is import it. Of course it needs to be installed. You may also need to set the python path to be sure it's looking in the right place. Once that's done you're good to go.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#5
so it doesnt need to be compiled as part of xbmc
it just needs to be installed on the system running it?
Reply
#6
As far as I can tell that's correct. I haven't actually tested though. Let me know if you have any problems and I can help you work through them.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#7
so ive got appscript working as in the example you linked to
but put that in a script and ran it on xbmc but nothing
so must need the path setting or something? like you suggested
can you point me in the right direction here? (am new to python)
Reply
#8
http://www.johnny-lin.com/cdat_tips/tips.../path.html

You may also want to insert some debug logging to make sure you're getting what you expect. For instance, check the path when you run outside of xbmc, and then check it again when you run inside xbmc. append the appropriate path to PyApplescript.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#9
thanks but still nothing
basically trying:

Code:
import sys

sys.path.append("/opt/local/var/macports/sources/rsync.macports.org/release/ports/python/py-appscript")

from appscript import *

app('TextEdit').documents.end.make(
    new=k.document,
    with_properties={k.text: 'Hello World!\n'}
    )

I am probably doing something stupid wrong as its getting late here and im getting hazy eyed
will try again tomorrow

would be possible to have appscript installed as part of xbmc osx so people could write scripts to interact with the os?
Reply
#10
you're going to have to show me your xbmc.log as well the path you get when you run in python without xbmc. i don't think we'll be including this in our distribution by default since it's easy enough to set up outside of it.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#11
call me a noob but need a bit more direction

for outside xbmc i just do
Code:
python
then
Code:
from appscript import *
then
Code:
app('TextEdit').documents.end.make(
    new=k.document,
    with_properties={k.text: 'Hello World!\n'}
    )


in the terminal. no path here? just automatic

where can i find xbmc.log, is it will it automatically log any probs or do i need to turn it on or add a log function?
Reply
#12
in the terminal if you type:
Code:
import sys
print sys.path
it will give you the path.

you can do the same by putting those lines in the xbmc script. to see the output hit 'i' in xbmc.

search the forums/wiki for the location of xbmc.log. I think it's in the sticky at the top of one of the forums in a post about submitting bugs.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#13
right the log entries for the script are

Code:
10:10:46 T:2692108192 M:2557558784    INFO: initializing python engine.
10:10:46 T:2692108192 M:2557558784   DEBUG: Loading: /Library/Application Support/XBMC/system/python/python24-osx.so
10:10:48 T:2692108192 M:2557243392   DEBUG: new python thread created. id=5
10:10:48 T:2961874944 M:2557235200   DEBUG: Running thread 2961874944
10:10:48 T:2961874944 M:2557235200   DEBUG: thread start, auto delete: 0
10:10:48 T:2961874944 M:2557235200   DEBUG: Python thread: start processing
10:10:48 T:2692108192 M:2557698048   DEBUG: CGUIMediaWindow::GetDirectory (/Users/matthewspence/Library/Application Support/XBMC/scripts/My Scripts/)
10:10:48 T:2692108192 M:2557698048   DEBUG:   ParentPath = [/Users/matthewspence/Library/Application Support/XBMC/scripts/My Scripts/]
10:10:48 T:2692108192 M:2557693952   DEBUG: Sort, sorting took 0 millis
10:10:48 T:2692108192 M:2557587456   DEBUG: Load /Library/Application Support/XBMC/skin/Project Mayhem III/media/defaultFolderBackBig.png: 2.8ms
10:10:48 T:2692108192 M:2557337600   DEBUG: Load /Library/Application Support/XBMC/skin/Project Mayhem III/media/list-focus.png: 2.4ms
10:10:48 T:2692108192 M:2557087744   DEBUG: Load /Library/Application Support/XBMC/skin/Project Mayhem III/media/DefaultScriptBig.png: 3.3ms
10:10:48 T:2961874944 M:2556997632    INFO: -->Python Interpreter Initialized<--
10:10:48 T:2961874944 M:2557014016    INFO:
10:10:48 T:2961874944 M:2557014016    INFO: Traceback (most recent call last):
10:10:48 T:2961874944 M:2557014016    INFO:   File "/Users/matthewspence/Library/Application Support/XBMC/scripts/My Scripts/mytest.py", line 5, in ?
10:10:48 T:2961874944 M:2557014016    INFO:
10:10:48 T:2961874944 M:2557014016    INFO: from appscript import *
10:10:48 T:2961874944 M:2557014016    INFO: ImportError
10:10:48 T:2961874944 M:2557014016    INFO: :
10:10:48 T:2961874944 M:2557014016    INFO: No module named appscript
10:10:48 T:2961874944 M:2557014016    INFO:
10:10:48 T:2961874944 M:2557014016   ERROR: Scriptresult: Error
10:10:48 T:2692108192 M:2556997632   DEBUG: Load /Library/Application Support/XBMC/skin/Project Mayhem III/media/button-focus.png: 2.3ms
10:10:48 T:2692108192 M:2556985344   DEBUG: Load /Library/Application Support/XBMC/skin/Project Mayhem III/media/button-focus.png: 2.3ms
10:10:48 T:2961874944 M:2558672896    INFO: Python script stopped
10:10:48 T:2961874944 M:2558672896   DEBUG: staticThread, deleting thread graphic context
10:10:48 T:2961874944 M:2558672896   DEBUG: Thread 2961874944 terminating
10:10:48 T:2692108192 M:2558672896   DEBUG: python thread 5 destructed
10:10:48 T:2692108192 M:2558701568    INFO: Python, unloading python24.dll cause no scripts are running anymore
10:10:48 T:2692108192 M:2558701568   DEBUG: UnloadExtensionLibs, clearing python extension libraries
10:10:48 T:2692108192 M:2558701568   DEBUG: Unloading: python24-osx.so
10:10:48 T:2692108192 M:2559377408   DEBUG: CGUIMediaWindow::GetDirectory (/Users/matthewspence/Library/Application Support/XBMC/scripts/My Scripts/)
10:10:48 T:2692108192 M:2559377408   DEBUG:   ParentPath = [/Users/matthewspence/Library/Application Support/XBMC/scripts/My Scripts/]
10:10:48 T:2692108192 M:2559377408   DEBUG: Sort, sorting took 0 millis
10:10:48 T:2692108192 M:2559311872   DEBUG: Load /Library/Application Support/XBMC/skin/Project Mayhem III/media/defaultFolderBackBig.png: 2.6ms
10:10:48 T:2692108192 M:2559111168   DEBUG: Load /Library/Application Support/XBMC/skin/Project Mayhem III/media/list-focus.png: 2.5ms
10:10:48 T:2692108192 M:2558910464   DEBUG: Load /Library/Application Support/XBMC/skin/Project Mayhem III/media/DefaultScriptBig.png: 2.9ms
10:10:49 T:2692108192 M:2563059712   DEBUG: SDLKeyboard found something unknown (unicode <> printable ASCII): scancode: 0, sym: 306, unicode: 0, modifier: 0

path outside xbmc is

Code:
['', '/Library/Python/2.5/site-packages/appscript-0.18.1-py2.5-macosx-10.5-i386.egg', '/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python25.zip', '/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5', '/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-dynload', '/Library/Python/2.5/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/PyObjC']

and path inside xbmc before the sys.path.append is

Code:
['Users/matthewspence/Library/Application SUpport/XBMC/scripts/My Scripts','/Library/Application Support/XBMC/system/python/python24.zip','/Library/Application Support/XBMC/system/python/lib-osx']

and path inside xbmc after the sys.path.append is

Code:
['Users/matthewspence/Library/Application Support/XBMC/scripts/My Scripts','/Library/Application Support/XBMC/system/python/python24.zip','/Library/Application Support/XBMC/system/python/lib-osx','/opt/local/var/macports/sources/rsync.macports.org/release/ports/python/py-appscript']
Reply
#14
It looks like you need to append '/Library/Python/2.5/site-packages/appscript-0.18.1-py2.5-macosx-10.5-i386.egg'
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#15
Thumbs Down 
ok so i tried that and i got

Code:
10:56:15 T:2959896576 M:2368774144    INFO: No module named pkg_resources

so i installed setup tools and amended it to sys.path

and got


Code:
10:58:57 T:2959896576 M:2369888256    INFO:
10:58:57 T:2959896576 M:2369888256    INFO: raise DistutilsPlatformError(my_msg)
10:58:57 T:2959896576 M:2369896448    INFO: distutils.errors
10:58:57 T:2959896576 M:2369896448    INFO: .
10:58:57 T:2959896576 M:2369896448    INFO: DistutilsPlatformError
10:58:57 T:2959896576 M:2369896448    INFO: :
10:58:57 T:2959896576 M:2369896448    INFO: invalid Python installation: unable to open /Library/Application Support/XBMC/system/python/lib/python2.4/config/Makefile (No such file or directory)
10:58:57 T:2959896576 M:2369896448    INFO:
10:58:57 T:2959896576 M:2369896448   ERROR: Scriptresult: Error
10:58:58 T:2959896576 M:2374914048    INFO: Python script stopped
10:58:58 T:2959896576 M:2374914048   DEBUG: staticThread, deleting thread graphic context

so then i tried it with the 2.4 version of setup tools and got the same thing
Reply

Logout Mark Read Team Forum Stats Members Help
Genius Playlist Plugin0