Trying to write my 1st script - Help Pls
#1
I'm, trying to write my 1st script and would like some help to get it started. I have been a programmer for over 10 years. So once I'm started I'm sure the rest should come easily. If somone could provide me with a script that when run will just simply open the movie library, or even better if you can open a playlist let say its called mylist.xsp I would be very thankfull

Reply
#2
Oddly, those are two entirely different things. When you say "open" a playlist, do you mean show the items in the playlist on screen, or start playing the playlist?

If you could tell us what the end goal of your addon is, we can probably do a better job of pointing you in the right direction
Reply
#3
My end goal and i know people have talked about this is I'm trying to write an addon or script that when run from the home screen will Prompt the user for a password and if it is correct will show the movies that match a smart playlist

Thanks for your reply
Reply
#4
This is actually pretty short, but you can spruce it up with browsing and maybe setting the password in settings and etc.
PHP Code:
import xbmc

if __name__ == '__main__':
    
kb xbmc.Keyboard()
    
entry ''
    
kb.doModal()
    if 
kb.isConfirmed():
        
entry kb.getText()
    if 
not (entry == 'Pa$$w0rd'): return
    
xbmc.ActivateWindow(VideoLibrary,special://videoplaylists/mylist.xsp,return) 

Not tested, but stick that in a basic addon and you should be in business. Keep in mind that looking inside the file would reveal the password and defeat the purpose.
Reply
#5
I have made some small chnages to try to get it to work and what I have now is below, I removed the password code because I was getting the error,
SyntaxError: ("'return' outside function", ('/storage/.xbmc/addons/script.xbmcbackup2/default.py', 9, None, "if not (entry == 'Pa$$w0rd'): return\n"))
I also changed the ActiveWindow code, to get pas the error,
SyntaxError: ('invalid syntax', ('/storage/.xbmc/addons/script.xbmcbackup2/default.py', 10, 45, ' xbmc.ActivateWindow(VideoLibrary,special://videoplaylists/mylist.xsp,return)\n'))
Its pulling up for keyboard input now, but getting the error,
File "/storage/.xbmc/addons/script.xbmcbackup2/default.py", line 11, in <module>
xbmc.ActivateWindow(Videos,MovieTitles)
AttributeError: 'module' object has no attribute 'ActivateWindow


Code:
import xbmc

if __name__ == '__main__':
    kb = xbmc.Keyboard()
    entry = ''
    kb.doModal()
    if kb.isConfirmed():
        entry = kb.getText()
#    if not (entry == 'Pa$$w0rd'):
#        return
    xbmc.ActivateWindow(Videos,MovieTitles)
Reply
#6
Got the ActivateWindow working, needed to use "xbmc.executebuiltin('xbmc.activatewindow(VideoLibrary,special://videoplaylists/kids.xsp,return)')"

Reply
#7
One of these days I'll learn to test stuff lol

No Idea why it would thing return is outside the function unless the spacing is off. I used 4 spaces in the example, so if you copy and pasted and used tab to indent something else, that might do it. Maybe bring return back up to the same line as the "if not" statement?
Reply

Logout Mark Read Team Forum Stats Members Help
Trying to write my 1st script - Help Pls0