View Full Version : Running python-scrips from "My Videos"
hi, i would like to be able to run my python scripts (especially those which stream in media) from the my videos section of xbmc. i put in a bookmark link to a special folder containing various scripts (such as cnn and ooba) and added .py to the list of supported file extensions that videos can access. however, when i select a script xbmc freezes, how would i enable this feature? is this something i can reconfigure? the main basis is that i don't like having my media in different places, i often go from switching between streaming media and locally stored media and would not like to have to go searching all over the media centre to find it. any help would be greatly appriceated as this has been bugging me for quite some time. thanks!
this is normally impossible but i do have a guess you could hack up something with an httpapi command going to the webserver (embed the command in the url) to run the script and then put the url into a .strm file. when the xbox tries to open the url for streaming it tricks the webserver into launching the script.
im not sure it will work though... i doubt the player would be happy.
glad you are using the cnn script :)
solexalex
2006-01-23, 00:08
hi
i found the asteron idea interesting ! so i tryed to write the http command that launch a script :
http://192.168.0.3/xbmccmds/xbmchttp?command=execbuiltin¶meter=xbmc.runscript(q:\scripts\cnn\cnn.py)
this http command work from my pc (it launchs the script on xbox)
then i tried to write this url into a .strm file but it hangs xbmc when i try to launch the strm file.
maybe is there a way to call xbmc http server from itself by replacing the xbox ip by a substitue ip adress meaning the xbox itself (like for windows 127.0.0.1 but it does not work)
hey ! another idea (simpliest in fact !!)
try to write the builtin command as your bookmark in your video section :
xbmc.runscript(q:\scripts\meteo\france-meteo07.py)
but i did not tryed this trick (my girlfriend starts to hit myself with the remote control... :( )
try it, and tell us !
nb: most of scripts use the os.getcwd() function to get the current path (for relative file paths). i don't really know how these scripts will run if they are not launched from the folder where they stand... so, once again, you should try it
i asked for this as a feature request for v2.0 of the skinning engine. please ask jm for this. i really want this too!
solexalex
2006-01-23, 19:01
did somebody tried my trick ?
xbmc.runscript(q:\scripts\meteo\france-meteo07.py)
nb: most of scripts use the os.getcwd() function to get the current path (for relative file paths). i don't really know how these scripts will run if they are not launched from the folder where they stand... so, once again, you should try it
all the scripts that get launched from dialogsubmenu.xml are launched with the builtin command. should be fine.
to answer the original question:
hi, i would like to be able to run my python scripts (especially those which stream in media) from the my videos section of xbmc. i put in a bookmark link to a special folder containing various scripts (such as cnn and ooba) and added .py to the list of supported file extensions that videos can access. however, when i select a script xbmc freezes, how would i enable this feature? is this something i can reconfigure? the main basis is that i don't like having my media in different places, i often go from switching between streaming media and locally stored media and would not like to have to go searching all over the media centre to find it. any help would be greatly appriceated as this has been bugging me for quite some time. thanks!
you can add a button to all windows in the skin, or just map a remote button in keymap.xml to do this:
xbmc.activatewindow(scripts)
i'll add that to a feature suggestion. it's easy to just map a button to scripts and push it, what i am more looking for is the ability to say view the xm radio py from within my music section and the say cnn.py from within the my videos section. the thought of adding python scripts is great, but most of these scripts just add functionality to an already existing feature set. why go to different places in the program to access the same features. pictures videos and music, streaming or not, should still in my opinion be accessed from the same area. it seems to me that if you took the same code that executes the py script and just pasted that into the code that plays the video it just might work.
interesting idea about the windows like local ip address (127.0.0.1). i think this would be useful for several things. ie i would like ot have a rss crawl appear on my main screen weather or not i am connected to the internet. a local rss file with random information even if it is not grabbed from the internet would still be fun.... or is this already possible?
the ability to run a .py script from within the 'my videos', 'my music' and other sections would be very useful. i find it rather a pain that when i am watching local media on my xbmc i go to the my videos section and click my media, however when i want to watch streaming media i then have to go back to the scripts menu and select from there. it would be much easier to just have a bookmark, like a channels section, that is in the same area but allows py scriupts to run. so i can go from watching a music video locally on my hard drive to watching one off launch.com with ease.
you can already add buttons which launch scripts from anywhere in the gui.
first off, you can add a button to launch any script, anywhere in the gui.
second, you may be able to run a local rss if the the internal webserver is enabled. i've never tried, but i suspect it's possible.
jmarshall
2006-01-24, 02:14
as was mentioned earlier, you can do this with a button, but you cannot do it within the list. the only place it would make sense in the list anyway would be in the root bookmarks listing, and so you mayaswell just make a button that does it.
use:
<execute>runscript(name_of_script)</execute>
to run a script from a button.
i understand i can make a button to do this, however what i was looking for was say just add a bookmark of a folder containing py scripts, open that folder (just like a folder of say music videos) and it has the icons for the different scripts, and you can click on the py from there.
jmarshall
2006-01-24, 03:56
while ofcourse this is possible, it defeats the purpose of having separated items.
it would involve adding .py as a video extension and any video-specific launching code would need to be altered to suit. any non-video related .py files would show up as well.
feel free to do it yourself and submit a patch.
the addition of the base media window may make this rather trivial actually. and instead of just adding .py to the extensions lists, i'd kind of prefer it as a settings option ("show python scripts"?), seperate for each media window like the "allow file operations" option.
what about just adding a <script> tag to button controls... this way he gets his request and i also get mine.
we can launch a script along with any standard control.
take it this way, i have added .py to the list of extensions that my videos can 'see'. i created a folder in my f:/videos/ folder called scripts and in it i placed the cnn script and all its associated files. now when i try to select the cnn script the box crashes, however i can still select this from within its correct section. this way, if i want to watch a music video i click on music videos folder and a video from within my videos section, if i want to watch streaming media from cnn i would simply click on the scripts folder and then cnn. same area of the media center for both streaming and local files, the xbox shouldnt care where it is coming from, it's still using the same codec to play it. now correct me if i am wrong (and i usually am) but couldnt you just add the code needed to execute the py files from the scripts menu and place that same functionality into the my videos or my music code. it seems to me that all the media is linked together anyways, and adding the ability to execute a py script from anywhere wouldnt be that hard... correct? either way, xbmc is by far the greatest media application availible today commercially or not. and if this is the worst part to me, you're doing a excellent job. javascript:emoticon(':bowdown:')
:bowdown:
the difference is that when you click a .py file in "my scripts" xbmc is smart enough to open it with the python engine. when you click on anything in "my video" xbmc will try to open it in the video player. videos that are started from within cnn use the same player though.
ahhh... i dont like the idea of 3rd party scripts running from within media windows. gets all a bit messy if you ask me. scripts are scripts and when they break i'm sure 99% of you will be removing that new button quicker than you put it there. :)
ahhh... i dont like the idea of 3rd party scripts running from within media windows. gets all a bit messy if you ask me. scripts are scripts and when they break i'm sure 99% of you will be removing that new button quicker than you put it there. :)
rule of thumb... if you don't know what you are doing, leave it alone or be willing to work through it if it breaks.
no different then anything else in xbmc.
i'm not sure why xbmc does not act like an os... filetypes run appropriately no matter where they are "located" or launched from.
i really want the abilityto run scripts from anywhere... i want to trigger them when i'm doing other things.
examples:
start movie --> trigger py to dim lights
start music --> trigger py to show music news
... etc
i'd think this would be an easy thing for a dev to add (i'm not a dev) since there is not much new code, only a bit of logic to get the code running.
am i the only one who see a use for this feature. i myself am annoyed that there are 2 different places to find media. explaining this to new users of xbmc can be tough, think of it this way... you wanna listen to music go to my music and select the album or go to the main menu, click the arrow button find for instance, the xm py file, open that folder then click on the .py, run that and select the station. to me, it would be easier if say you wanted to listen to music, streaming or not, you go to my music. theres a bookmark in my music for listening to shoucast streams, if i select the http item i get a text list of availible stations, if i go to the shoucast script however, i am presented with a nice gui and a sorted list of stations and genres. why shouldnt i be able to access this script from my music... it is music the players uses the same codecs in the end to run them. most py files themselves just act as a gui interface that then streams in media of different types (video, music or pictures). it seems like a logical step to allow scripts to be sorted in thier respective catagories. the xbmc player is using the same functions. allowing py scripts to execute from any screen, not just the scripts menu or file browser, doesnt seem like it would require much more coding....
Hi,
If you're using the MC360 skin, I have found a quick way of accessing the scripts.
see: http://forums.xbox-scene.com/lofiversion/index.php/t524821.html
am i the only one who see a use for this feature. i myself am annoyed that there are 2 different places to find media. explaining this to new users of xbmc can be tough, think of it this way... you wanna listen to music go to my music and select the album or go to the main menu, click the arrow button find for instance, the xm py file, open that folder then click on the .py, run that and select the station. to me, it would be easier if say you wanted to listen to music, streaming or not, you go to my music. theres a bookmark in my music for listening to shoucast streams, if i select the http item i get a text list of availible stations, if i go to the shoucast script however, i am presented with a nice gui and a sorted list of stations and genres. why shouldnt i be able to access this script from my music... it is music the players uses the same codecs in the end to run them. most py files themselves just act as a gui interface that then streams in media of different types (video, music or pictures). it seems like a logical step to allow scripts to be sorted in thier respective catagories. the xbmc player is using the same functions. allowing py scripts to execute from any screen, not just the scripts menu or file browser, doesnt seem like it would require much more coding....
I also see the use of this and like to *BUMP* this thread.. Perhaps changing the sources file will do but I actually perfer doing it in a simular way in which we can edit that dialogmenu tingy (the blue icon in the main screen) with a script already.
This GUI allows (new) users to easily edit their favorite media scripts to the section it belongs to. And when you enter the Videos/Music section there will be that list followed by the sources.xml specified list. I think this has potential.. allowing users to use the appletrailer script for instance within the movies section is a more logical choice (people can actually find these scripts).
Add to that a small modification on the xbmcscripts.com site (I know it has no direct relation with XBMC) to define wheter a script belongs to the music/video section. Even weekly updates can be possible.. man there is a whole new world out there to explore!
Cheers,
San