• 1
  • 11
  • 12
  • 13(current)
  • 14
  • 15
  • 23
[RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...)
I tried this script and it does work as advertised thank you.

I have a suggestion however for the launch at start up, or maybe it is already possible some other way.....

Is there any way one can delay the availability (not launch) of xbmc/kodi until the start up script has completed? If not can this be implemented into this script? I am using this to sync files from a web server and need to delay the availability of using xbmc until the script has completed. I have to prevent add ons from being run till this is done
Reply
(2014-12-25, 18:53)tekno Wrote: I tried this script and it does work as advertised thank you.

I have a suggestion however for the launch at start up, or maybe it is already possible some other way.....

Is there any way one can delay the availability (not launch) of xbmc/kodi until the start up script has completed? If not can this be implemented into this script? I am using this to sync files from a web server and need to delay the availability of using xbmc until the script has completed. I have to prevent add ons from being run till this is done

This addon cannot do that since it is the python interpreter within Kodi that runs the scripts.
You might want to write a script in an appropriate language for your OS to perform your tasks and wait for them to complete prior to starting Kodi and then launch Kodi using that script.
Reply
(2014-12-25, 18:53)tekno Wrote: I tried this script and it does work as advertised thank you.

I have a suggestion however for the launch at start up, or maybe it is already possible some other way.....

Is there any way one can delay the availability (not launch) of xbmc/kodi until the start up script has completed? If not can this be implemented into this script? I am using this to sync files from a web server and need to delay the availability of using xbmc until the script has completed. I have to prevent add ons from being run till this is done

On ubuntu you could use Upstart to start Kodi. I think you can use the starton to look for a file existing before starting.

Read here, http://upstart.ubuntu.com/cookbook/#envi...-variables
Reply
Actually, I ended up doing this somewhat differently than I wanted to and thought I would post that result here.

Instead of making xbmc "unavailable" like muting video or something of the like I used xbmc callbacks and my script now includes a message to xbmc-eventclients that says "Please Wait, Downloading..." then after the script is run it sends "Download complete, Ready."

Works quite well however I wish that the kodi devs would finally reduce the volume of alerts or the recordings they play back The sounds are quite sharp and loud compared to average Movie or TV volume. I have seen these alerts complained about before. yes I have lowered the volume in the recordings before but they get overwritten on an upgrade

Thanks
Reply
Can someone help please with the following .sh script:

Code:
#!/bin/bash

/usr/bin/osascript <<-EOF

      tell application "System Events"
    if process "iTunes" exists then
        set okflag to true --iTunes is running
    else
        set okflag to false
    end if
end tell

if okflag is true then
    
    tell application "iTunes"
        
        set currentvolume to the sound volume
        if player state is playing then
            repeat
                --Fade down    
                repeat with i from currentvolume to 0 by -1 --try by -4 on slower Macs
                    set the sound volume to i
                    delay 0.01 -- Adjust this to change fadeout duration (delete this line on slower Macs)
                end repeat
                pause
                --Restore original volume
                set the sound volume to currentvolume
                exit repeat
            end repeat
        else -- if player state is paused then
            
            set the sound volume to 0 --2007-03-20 script update to fix startup glitch
            play
            
            -- tell application "System Events" to set visible of process "iTunes" to false
            
            -- reveal current track
            
            repeat with j from 0 to currentvolume by 1 --try by 4 on slower Macs
                set the sound volume to j
                delay 0.01 -- Adjust this to change fadeout duration (delete this line on slower Macs)    
            end repeat
        end if
    end tell
end if

EOF

This one worked with the original callbacks 0.5 but not with callbacks2. I get the following errors:

Image
Image
Reply
Nevermind. Found a way to execute the applescript within Python.

Any chance there'll be a "Kodi Quit/Exit" option instead of shutdown?
Reply
I saw this service addon script and it gave me a great idea. It works well triggering the starts of video and stops, which is what I wanted.
I'm running Gotham 13.2 on a win 8.1 system with nextpvr doing my recording for me.

I am trying to make viewing videos similar to my REPLAY TV (some people may remember these and my wife is still using one of ours). With Replay TV, when a video ends or you stop it, it gives you 3 options, "Resume playback", "Delete the video", or "Play another Video". By default I have the "Play another video" working as that would be where Kodi would return anyway, and I don't think I will have any problem with the delete. That is ordinary stuff.

I am of course using Python to try to do these things, and while not a Python expert, I am getting better with it. I've already made a couple of handy little tools for Kodi.

But... the resume is another story for me and maybe someone could point me in the right direction as my searches on this forum and elsewhere have not found a solution. When I "START" a video (I'm watching in file mode so I can skip the commercials via COMSKIP), the trigger records all the pertinent info available with the addon (file name, the trigger, etc, etc) and writes that to a file for later use. I then use that file when "STOP" is triggered as the addon does not provide the filename there. But when I execute a xbmc.player.play(), it always starts at the beginning of the video, not in the place it left off. I do have XBMC video settings set to "Resume" and that works fine when playing or resuming a video normally.

I am assuming Kodi has a bookmark someplace saying where the video left off as it knows when you start a video. So I need to know where that is and how to get it so I could use it in my Python script. There does not seem to be a player.resume() function to execute and I'd like to build one for my function. I know the player.play() function has a field indicating where to start. So if I could retrieve that info from "who knows where" I should be able to plug it in and do exactly what I want. I'd also like to find where the "WATCHED" or "UNWATCHED" field is as ideally I'd only like to trigger my delete function when the show is watched.

I'm doing all my development on my desktop PC so Kodi remains stable and usable for my normal needs.

Anyone have any ideas? I would greatly appreciate it. It might help me finally get my wife to give up her ReplayTVs.

Thanks in advance for any assistance that may be given.

------- OK, I found a fix
jsonrpc. From there I can send a play "resume".

{"jsonrpc": "2.0",
"id": 1,
"method": "Player.Open",
"params": {"item": {"file":my_file},
"options": {"resume": True

I wanted to use the "executejsonrpc" from within the XBMC Python transport. Never could get it to work. After much research, trial and error, and frustration I went to the HTTP jsonrpc transport, and got it to work. Not a lot of examples out on the web to help, but the ones I did find, finally gave me enough help to make it work.

So now when a show stops (set it up to only do my thing if a TV Show) I have the 3 options mentioned above. And when I select "delete" it deletes the show file along with the other edl and txt files created by COMSKIP. If the directory is now empty, it deletes the directory too.

Maybe someone else will be helped by this.
Reply
Can anyone help me with a modification to this script?

I'd like to call a URL rather than run a script when a video starts. The script sets certain features of my receiver based on the time of time, status of certain doors etc. Because I am using Windows, running a batch script pops up the command line, which is annoying. I know there are modificaitons that can be done, but I thought I'd try to modify the script. I know Python, but I am not that familiar with kodi add-ons.

Here is the function:
Code:
def onPlayBackStarted(self):
    log('player starts')
    # Chris's rewrite
    global script_player_starts
    if script_player_starts:
      log('Going to use urllib2 to set listening mode')
      #log('Going to execute script = "' + script_player_starts + '"')
      try:
          #subprocess.call([script_player_starts,self.playing_type()])
          response = urllib2.urlopen('http://raspberrypi/set_listening_mode.php')
          response = 'Response from server = ' + response
          log(response)
      except:
          log('ERROR executing script when player starts')

The error I get is from the exception. If I had to guess its because its not importing urllib2, but before I install it, I was wondering if anyone knew what the issue was for sure.

Thanks.
Reply
(2015-03-03, 16:50)milhouse34521 Wrote: Can anyone help me with a modification to this script?

I'd like to call a URL rather than run a script when a video starts. The script sets certain features of my receiver based on the time of time, status of certain doors etc. Because I am using Windows, running a batch script pops up the command line, which is annoying. I know there are modificaitons that can be done, but I thought I'd try to modify the script. I know Python, but I am not that familiar with kodi add-ons.

Here is the function:
Code:
def onPlayBackStarted(self):
    log('player starts')
    # Chris's rewrite
    global script_player_starts
    if script_player_starts:
      log('Going to use urllib2 to set listening mode')
      #log('Going to execute script = "' + script_player_starts + '"')
      try:
          #subprocess.call([script_player_starts,self.playing_type()])
          response = urllib2.urlopen('http://raspberrypi/set_listening_mode.php')
          response = 'Response from server = ' + response
          log(response)
      except:
          log('ERROR executing script when player starts')

The error I get is from the exception. If I had to guess its because its not importing urllib2, but before I install it, I was wondering if anyone knew what the issue was for sure.

Thanks.

Can you change the code to show you the contents of the exception

Code:
except Exception, e:
    log(str(e))

But yes, if you're not importing urllib2 then attempting to use it will error
Reply
(2015-03-03, 19:33)spoyser Wrote: Can you change the code to show you the contents of the exception

But yes, if you're not importing urllib2 then attempting to use it will error

Thanks - the problem was because I didn't have anything in the config xml file for start. Once I added BLANK it worked.
Reply
I didn't know if anyone saw this post from another thread. It is about using kodi to control Wemo leds. In particular please review the last post for this thread. It is from the developer of some Android apps that control the wemo leds. I was the one that contacted him to see he would be able to contribute anything to this idea since his apps work very good.

The wemo led app also has scene widgets that you program based on a particular situation. So for instance I have a scene for my living room lights that is named Movie Time. When I press the widget for that scene it tells the lights to start dimming over the next 30 seconds to a level of 20% I have another scene programed and named Roll Credits. This one tells the wamo leds to turn back up over 30 seconds to 100%. So we would not really need this function built into the automation controller in KODI but instead just need a send intent to an android device that already has the app and preconfigured scenes so they trigger with the movie. I am reposting the thread link below because the one it was posted on appears to have been dead since Jan.

Please if anyone has the coding experience needed to do something like this, contact the app developer he would be interested in working on this. Here is the link to the thread, it is the last post: http://forum.kodi.tv/showthread.php?tid=...light=wemo
Reply
(2015-03-15, 00:05)kojak40 Wrote: I didn't know if anyone saw this post from another thread. It is about using kodi to control Wemo leds. In particular please review the last post for this thread. It is from the developer of some Android apps that control the wemo leds. I was the one that contacted him to see he would be able to contribute anything to this idea since his apps work very good.

The wemo led app also has scene widgets that you program based on a particular situation. So for instance I have a scene for my living room lights that is named Movie Time. When I press the widget for that scene it tells the lights to start dimming over the next 30 seconds to a level of 20% I have another scene programed and named Roll Credits. This one tells the wamo leds to turn back up over 30 seconds to 100%. So we would not really need this function built into the automation controller in KODI but instead just need a send intent to an android device that already has the app and preconfigured scenes so they trigger with the movie. I am reposting the thread link below because the one it was posted on appears to have been dead since Jan.

Please if anyone has the coding experience needed to do something like this, contact the app developer he would be interested in working on this. Here is the link to the thread, it is the last post: http://forum.kodi.tv/showthread.php?tid=...light=wemo

I'm not sure how much help I could be if I don't have a WeMo setup. If he doesn't want to code in python in XBMC himself, he could possibly using this plugin as is and I could help troubleshoot.
Reply
Is there any plans to add on delete movie action?

I would like to automatically remove torrent file with movie from Deluge when I delete appropriate movie in Kodi via context menu.
I know how to delete torrent with deluge-console if I have filename. How to get filename of selected movie and pass it to my batch script is the second question but I think it is not for this thread Smile
Reply
This looks like it could be perfect for my implementation of XBMC.MyLibrary, however I can't get it to activate correctly quite yet.

Is there any way to get this to run from the C:\? I think that's why it's not finding the JAR file that my script points to - and I freely admit that I'm pretty inexperienced when it comes to the command line.

This happens both when using .5 and 2.
Reply
(2015-03-16, 17:11)Booch Wrote: Is there any plans to add on delete movie action?

I would like to automatically remove torrent file with movie from Deluge when I delete appropriate movie in Kodi via context menu.
I know how to delete torrent with deluge-console if I have filename. How to get filename of selected movie and pass it to my batch script is the second question but I think it is not for this thread Smile

In short, no. Unless there are multiple user requests for a function or I need it myself, the only actions you can expect to see implemented are the one's made available through Kodi's Monitor class: http://mirrors.xbmc.org/docs/python-docs...ml#Monitor

(2015-03-19, 17:24)wickemu Wrote: This looks like it could be perfect for my implementation of XBMC.MyLibrary, however I can't get it to activate correctly quite yet.

Is there any way to get this to run from the C:\? I think that's why it's not finding the JAR file that my script points to - and I freely admit that I'm pretty inexperienced when it comes to the command line.

This happens both when using .5 and 2.

Since this runs through Kodi's own included python interpreter and requires the import of multiple modules only provided through a running Kodi instance, this script cannot run on it's own outside of Kodi.
Reply
  • 1
  • 11
  • 12
  • 13(current)
  • 14
  • 15
  • 23

Logout Mark Read Team Forum Stats Members Help
[RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...)4