• 1
  • 13
  • 14
  • 15(current)
  • 16
  • 17
  • 23
[RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...)
(2015-05-15, 14:05)masinad Wrote: Is there some way to detect if kodi is in Kiosk mode? Like to disable automatic shutdown when chrome launcher is started.

I do not see any way of doing this as you mention. Kiosk mode is not directly discoverable via the Kodi api (see the pydocs) or via JSON, as far as I can tell.

You would need to hack the code of the chrome launcher itself.
Reply
(2015-05-10, 17:44)tekno Wrote: I agree with tomrey. SHutdown script is needed. I want to use the shutdown script so a user can select a different remote.
Hi tekno,
the following construction is now working for me. I found it through a similar solution for VLC.
It's a shell script completely outside Kodi:
Code:
#!/bin/sh
#kodi.sh
curl "http://192.168.1.90/cgi/control.cgi?login=p:**:****&p=1uuu"
kodi --standalone
curl "http://192.168.1.90/cgi/control.cgi?login=p:**:****&p=0uuu"
It's easy - as a newbee to linux I didn't know, that the script stops after starting Kodi and goes on working after Kodi is finished.
So instead of my curl statements you could call any other script and you have a "run before and run after" solution.
Should help with your remote selection challenge...
Regards
Reply
Also, I'm confused about the 'need' for a shutdown script...
Is this not working for you?

Image
Reply
(2015-05-16, 14:22)KenV99 Wrote: Also, I'm confused about the 'need' for a shutdown script...
Is this not working for you?

Image
Thanks Ken, you are absolutely right. I should have installed your script before asking.
I had read further up this thread, that there was no stop-action.
Working perfectly calling an independent script.
In my case a simple http call would be enough but this option does not work here as the http-command-line is not editableHuh
What am I doing wrong or is that function not yet enabled?
Regards
Reply
It's editable for me. Just choose http then a line appears for you to enter the text:

Image
Reply
Not for me, if I klick to the http-field a new window opens:
hmm I cannot add the screenshot here...
it is the standard-kodi window screen-keyboard but without any letters in the fields and the http-field cannot be accessed...
Reply
(2015-05-16, 18:06)tomrey Wrote: Not for me, if I klick to the http-field a new window opens:
hmm I cannot add the screenshot here...
it is the standard-kodi window screen-keyboard but without any letters in the fields and the http-field cannot be accessed...

That sounds like a skin issue. Can you try setting it up in Confluence and then switching back.
On Kodi 14.2 on windows 7 x64 and Confluence a keyboard opens properly.
Reply
(2015-01-23, 04:20)ReplayHarry Wrote: 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.

Maybe someone can see what is going on here. My original post tells what I am doing but I have a strange thing with 1 particular show (Good Day, a morning news show that is on at 4:30am, 6am, and 7am). I'm running Win 8.1 with Nextpvr 3.3.8 and Kodi 13.2.
With this one show, it never triggers the "onPlaybackStarted" function and my Python script (StartPlay.py) unless the show is still recording or at least still busy by virtue of using Comskip in a postprocessing.bat file. On the start, I record the info about the file and save it to disk so that I can read that info back when "onPlaybackStopped" is triggered. The stop function is triggered fine, but since the original info was never saved, it does nothing.
Here is a portion of the long and I see some kind of error that appears to be in the callback2 addon.
------------------------------------
06:17:26 T:2632 NOTICE: -->Python Interpreter Initialized<--
06:17:30 T:4888 NOTICE: DVDPlayer: Opening: D:\Recorded TV\News\Good Day\Good Day_20150522_06000700.ts
06:17:30 T:4888 WARNING: CDVDMessageQueue(player):Tongueut MSGQ_NOT_INITIALIZED
06:17:30 T:4428 NOTICE: Thread DVDPlayer start, auto delete: false
06:17:30 T:4428 NOTICE: Creating InputStream
06:17:30 T:4428 NOTICE: Creating Demuxer
06:17:30 T:4428 NOTICE: Opening video stream: 0 source: 256
06:17:30 T:4428 NOTICE: Creating video codec with codec id: 2
06:17:30 T:4428 NOTICE: CDVDVideoCodecFFmpeg::Open() Using codec: MPEG-2 video
06:17:30 T:4428 NOTICE: Creating video thread
06:17:30 T:4428 NOTICE: Opening audio stream: 1 source: 256
06:17:30 T:4428 NOTICE: Finding audio codec for: 86019
06:17:30 T:4428 NOTICE: Creating audio thread
06:17:30 T:1948 NOTICE: Thread DVDPlayerVideo start, auto delete: false
06:17:30 T:1948 NOTICE: running thread: video_thread
06:17:30 T:5100 NOTICE: Thread DVDPlayerAudio start, auto delete: false
06:17:30 T:5100 NOTICE: running thread: CDVDPlayerAudio:Tonguerocess()
06:17:30 T:5100 NOTICE: Creating audio stream (codec id: 86019, channels: 2, sample rate: 48000, pass-through)
06:17:30 T:1948 NOTICE: fps: 29.970030, pwidth: 1920, pheight: 1080, dwidth: 1920, dheight: 1080
06:17:30 T:1948 NOTICE: Display resolution ADJUST : 1920x1080@ 59.94 - Full Screen (16) (weight: 0.000)
06:17:30 T:800 NOTICE: 1Channel: Service: Playback started
06:17:31 T:4984 NOTICE: $$$ [xbmc.callbacks2] - Executing command: [C:\Python27\StartPlay.py] for event: onPlaybackStarted
06:17:31 T:4984 NOTICE: $$$ [xbmc.callbacks2] - Command for onPlaybackStarted executed successfully
06:17:31 T:3880 NOTICE: Thread LanguageInvoker start, auto delete: false
06:17:31 T:3880 NOTICE: -->Python Interpreter Initialized<--
06:17:34 T:4888 NOTICE: CDVDPlayer::CloseFile()
06:17:34 T:4888 NOTICE: DVDPlayer: waiting for threads to exit
06:17:34 T:4428 NOTICE: CDVDPlayer::OnExit()
06:17:34 T:4428 NOTICE: DVDPlayer: closing audio stream
06:17:34 T:4428 NOTICE: Closing audio stream
06:17:34 T:4428 NOTICE: Waiting for audio thread to exit
06:17:34 T:5100 NOTICE: thread end: CDVDPlayerAudio::OnExit()
06:17:34 T:4428 NOTICE: Closing audio device
06:17:34 T:4428 NOTICE: Deleting audio codec
06:17:34 T:4428 NOTICE: DVDPlayer: closing video stream
06:17:34 T:4428 NOTICE: Closing video stream
06:17:34 T:4428 NOTICE: waiting for video thread to exit
06:17:34 T:1948 NOTICE: thread end: video_thread
06:17:34 T:4428 NOTICE: deleting video codec
06:17:34 T:4428 NOTICE: CDVDPlayer::OnExit() deleting demuxer
06:17:34 T:4428 NOTICE: CDVDPlayer::OnExit() deleting input stream
06:17:34 T:4888 NOTICE: DVDPlayer: finished waiting
06:17:34 T:800 NOTICE: 1Channel: Service: Playback Stopped
06:17:34 T:800 NOTICE: 1Channel: Service: Resetting...
06:17:34 T:4984 NOTICE: $$$ [xbmc.callbacks2] - Executing command: [C:\Python27\StartPlay.py] for event: onPlaybackStopped
06:17:34 T:4984 NOTICE: $$$ [xbmc.callbacks2] - Command for onPlaybackStopped executed successfully
06:17:34 T:3076 NOTICE: Thread BackgroundLoader start, auto delete: false
06:17:34 T:4888 NOTICE: CDVDPlayer::CloseFile()
06:17:34 T:4888 NOTICE: DVDPlayer: waiting for threads to exit
06:17:34 T:4888 NOTICE: DVDPlayer: finished waiting
06:17:34 T:4888 NOTICE: CDVDPlayer::CloseFile()
06:17:34 T:4888 NOTICE: DVDPlayer: waiting for threads to exit
06:17:34 T:4888 NOTICE: DVDPlayer: finished waiting
06:17:34 T:3300 NOTICE: Thread LanguageInvoker start, auto delete: false
06:17:35 T:3300 NOTICE: -->Python Interpreter Initialized<--
06:17:35 T:3300 NOTICE: {'Show dir': 'D:\\Recorded TV\\News\\Good Day\n', 'Title': 'Good Day\n', 'XBMC Event': 'onPlaybackStarted\n', 'XBMC Type': 'TV Show\n', 'Filename': 'D:\\Recorded TV\\News\\Good Day\\Good Day_20150522_06000700.ts\n', 'Date & Time': '05\\22\\2015 0600\n', 'Directory': 'Recorded TV\n'}
06:17:42 T:4888 NOTICE: DVDPlayer: Opening: D:\Recorded TV\News\Good Day\Good Day_20150522_05000600.ts
06:17:42 T:4888 WARNING: CDVDMessageQueue(player):Tongueut MSGQ_NOT_INITIALIZED
06:17:42 T:3780 NOTICE: Thread DVDPlayer start, auto delete: false
06:17:42 T:3780 NOTICE: Creating InputStream
06:17:42 T:3780 NOTICE: Creating Demuxer
06:17:42 T:3780 NOTICE: Opening video stream: 0 source: 256
06:17:42 T:3780 NOTICE: Creating video codec with codec id: 2
06:17:42 T:3780 NOTICE: CDVDVideoCodecFFmpeg::Open() Using codec: MPEG-2 video
06:17:42 T:3780 NOTICE: Creating video thread
06:17:42 T:3780 NOTICE: Opening audio stream: 1 source: 256
06:17:42 T:3780 NOTICE: Finding audio codec for: 86019
06:17:42 T:3780 NOTICE: Creating audio thread
06:17:42 T:3780 NOTICE: Opening Subtitle stream: 0 source: 1024
06:17:42 T:2764 NOTICE: Thread DVDPlayerVideo start, auto delete: false
06:17:42 T:2764 NOTICE: running thread: video_thread
06:17:42 T:2872 NOTICE: Thread DVDPlayerAudio start, auto delete: false
06:17:42 T:2872 NOTICE: running thread: CDVDPlayerAudio:Tonguerocess()
06:17:42 T:3780 ERROR: CDVDPlayerSubtitle::OpenStream - Unable to create subtitle parser
06:17:42 T:3780 WARNING: CDVDPlayer::OpenSubtitleStream - Unsupported stream 0. Stream disabled.
06:17:42 T:2872 NOTICE: Creating audio stream (codec id: 86019, channels: 2, sample rate: 48000, pass-through)
06:17:42 T:2764 NOTICE: fps: 29.970030, pwidth: 1920, pheight: 1080, dwidth: 1920, dheight: 1080
06:17:42 T:2764 NOTICE: Display resolution ADJUST : 1920x1080@ 59.94 - Full Screen (16) (weight: 0.000)
06:17:42 T:4984 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.TypeError'>
Error Contents: cannot concatenate 'str' and 'NoneType' objects
Traceback (most recent call last):
File "C:\Users\MyHTPC\AppData\Roaming\XBMC\addons\service.xbmc.callbacks2-master\default.py", line 309, in onPlayBackStarted
self.onPlayBackStartedEx()
File "C:\Users\MyHTPC\AppData\Roaming\XBMC\addons\service.xbmc.callbacks2-master\default.py", line 314, in onPlayBackStartedEx
runtimeargs.append('type=' + self.playing_type())
TypeError: cannot concatenate 'str' and 'NoneType' objects
-->End of Python script error report<--
06:17:43 T:800 NOTICE: 1Channel: Service: Playback started
06:17:46 T:4888 NOTICE: CDVDPlayer::CloseFile()
06:17:46 T:4888 NOTICE: DVDPlayer: waiting for threads to exit
06:17:46 T:3780 NOTICE: CDVDPlayer::OnExit()
06:17:46 T:3780 NOTICE: DVDPlayer: closing audio stream
06:17:46 T:3780 NOTICE: Closing audio stream
06:17:46 T:3780 NOTICE: Waiting for audio thread to exit
06:17:46 T:2872 NOTICE: thread end: CDVDPlayerAudio::OnExit()
06:17:46 T:3780 NOTICE: Closing audio device
06:17:46 T:3780 NOTICE: Deleting audio codec
06:17:46 T:3780 NOTICE: DVDPlayer: closing video stream
06:17:46 T:3780 NOTICE: Closing video stream
06:17:46 T:3780 NOTICE: waiting for video thread to exit
06:17:46 T:2764 NOTICE: thread end: video_thread
06:17:46 T:3780 NOTICE: deleting video codec
06:17:46 T:3780 NOTICE: CDVDPlayer::OnExit() deleting demuxer
06:17:46 T:3780 NOTICE: CDVDPlayer::OnExit() deleting input stream
06:17:46 T:4888 NOTICE: DVDPlayer: finished waiting
command: [C:\Python27\StartPlay.py] for event: onPlaybackStopped
0606:17:46 T:4984 NOTICE: $$$ [xbmc.callbacks2] - Executing :17:46 T:4984 NOTICE: $$$ [xbmc.callbacks2] - Command for onPlaybackStopped executed successfully
Reply
For some reason I cannot reproduce, it cannot detect what type of video it is and it's returning 'None'

I pushed an update that *should* fix that to git: https://github.com/KenV99/service.xbmc.c...quests.zip
you only need to replace the default.py file in your current addon installation from the zip
Reply
(2015-05-23, 14:29)KenV99 Wrote: For some reason I cannot reproduce, it cannot detect what type of video it is and it's returning 'None'

I pushed an update that *should* fix that to git: https://github.com/KenV99/service.xbmc.c...quests.zip
you only need to replace the default.py file in your current addon installation from the zip

I must admit it is pretty strange. I will try your update and let you know if that makes a difference. Overall I love this thing and my little Python program with your addon makes things very easy for me and my wife.

Film at 11.
Reply
Ken: I could try again till this morning as "Good Day" is a Monday - Friday only program. I am attaching the logs. Same thing with your revised "default.py" . It just occurs on a different line. If you look at the logs starting at about 4am, that is when the show starts. It is 4:40am - 5:00am, then 5:00am-6:00am, and then the last time is 6:00am-7:00am. You will see when I watch the shop and stop it before Comskip completes, it triggers the onPlaybackStop fine. But once Comskip has done it's thing, it breaks on the "onPlaybackStart".
Reply
(2015-05-26, 00:18)ReplayHarry Wrote: Ken: I could try again till this morning as "Good Day" is a Monday - Friday only program. I am attaching the logs. Same thing with your revised "default.py" . It just occurs on a different line. If you look at the logs starting at about 4am, that is when the show starts. It is 4:40am - 5:00am, then 5:00am-6:00am, and then the last time is 6:00am-7:00am. You will see when I watch the shop and stop it before Comskip completes, it triggers the onPlaybackStop fine. But once Comskip has done it's thing, it breaks on the "onPlaybackStart".

Update1:
Well, I couldn't attach the log for some reason. I will do a bit of research and try to attach again in a few minutes.

Update2:
I sure didn't think it would be hard to upload a log. I'll be back when I figure it out.
Reply
Please post it to pastebin and post the link. Mods prefer you do it that way.
Reply
(2015-05-26, 00:23)KenV99 Wrote: Please post it to pastebin and post the link. Mods prefer you do it that way.

ok, finally figured out how to use pastebin. Thank God for YouTube.

here is my log: http://pastebin.com/fta226mu
Reply
(2015-05-26, 02:45)ReplayHarry Wrote:
(2015-05-26, 00:23)KenV99 Wrote: Please post it to pastebin and post the link. Mods prefer you do it that way.

ok, finally figured out how to use pastebin. Thank God for YouTube.

here is my log: http://pastebin.com/fta226mu

I pushed another update to the requests branch as before.
Kodi is not getting neither a filename nor a title for the video so that seems to be the issue. I hope those are not actually need for whatever script you are running.
Reply
  • 1
  • 13
  • 14
  • 15(current)
  • 16
  • 17
  • 23

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