2013-04-29, 12:26
Tested... Doesn't work. If I add the few lines of code into the script under the #place code here part of any section, the CE script just wont run. Using the script file that came with the latest CE on Frodo I have the following:
http://pastebin.com/DTqgFbnn
Not really sure what I am doing but it would be good to have the commands I need in the script file.
EDIT: Seems to work when I test in the #trailers section. May have something to do with the fact I am not using the Trivia Info?
Code:
# This module's future home should be inside userdata/addon_data/script.cinema.experience/ha_scripts
# to make sure it does not get over written when updating the script
import xbmc, xbmcaddon
import socket, sys
from threading import Thread
triggers = sys.modules[ "__main__" ].triggers
ha_settings = sys.modules[ "__main__" ].ha_settings
M1IP = "192.168.0.251"
M1PORT = 2101
class Automate:
def __init__( self ):
pass
def activate_ha( self, trigger = None, prev_trigger = None, mode="thread" ):
if ha_settings[ "ha_enable" ]:
if ha_settings[ "ha_multi_trigger" ] and prev_trigger == trigger:
pass
elif mode != "thread":
self.activate_on( trigger )
else:
thread = Thread( name='ha_trigger', target=self.activate_on, args=( trigger, ) )
thread.start()
return prev_trigger
def activate_on( self, trigger = None ):
"""
Scripting to trigger almost anything(HA, other scripts, etc...) when videos start.
Usage:
activate_on( "Movie" )
will trigger code that is set under the Movie heading.
"""
if not trigger:
xbmc.log( "[script.cinema.experience] - [ home_automation.py ] - No Trigger Sent, Returning", level=xbmc.LOGNOTICE )
return
xbmc.log( "[script.cinema.experience] - [ home_automation.py ] - activate_on( %s ) Triggered" % trigger, level=xbmc.LOGNOTICE )
if trigger in triggers:
xbmc.log( "[script.cinema.experience] - [ home_automation.py ] - Trigger %s" % trigger, level=xbmc.LOGNOTICE )
# Script Start
if trigger == "Script Start" and ha_settings[ "ha_script_start" ]:
# place code below this line
pass
# Trivia Intro
elif trigger == "Trivia Intro" and ha_settings[ "ha_trivia_intro" ]:
pass
# place code below this line
srvsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
srvsock.settimeout(3) # 3 second timeout on commands
srvsock.connect((M1IP, M1PORT))
srvsock.sendall(b'09ct01000CF4\r')
srvsock.close()
# Trivia
elif trigger == "Trivia" and ha_settings[ "ha_trivia_start" ]:
pass
# place code below this line
# Trivia Outro
elif trigger == "Trivia Outro" and ha_settings[ "ha_trivia_outro" ]:
pass
# place code below this line
# Movie Theatre Intro
elif trigger == "Movie Theater Intro" and ha_settings[ "ha_mte_intro" ]:
pass
# place code below this line
# Coming Attractions Intro
elif trigger == "Coming Attractions Intro" and ha_settings[ "ha_cav_intro" ]:
pass
# place code below this line
# Trailer
elif trigger == "Movie Trailer" and ha_settings[ "ha_trailer_start" ]:
pass
# place code below this line
# Coming Attractions Outro
elif trigger == "Coming Attractions Outro" and ha_settings[ "ha_cav_outro" ]:
pass
# place code below this line
# Feature Presentation Intro
elif trigger == "Feature Presentation Intro" and ha_settings[ "ha_fpv_intro" ]:
pass
# place code below this line
# MPAA Rating
elif trigger == "MPAA Rating" and ha_settings[ "ha_mpaa_rating" ]:
pass
# place code below this line
# Countdown
elif trigger == "Countdown" and ha_settings[ "ha_countdown_video" ]:
pass
# place code below this line
# Audio Format
elif trigger == "Audio Format" and ha_settings[ "ha_audio_format" ]:
pass
# place code below this line
# Movie
elif trigger == "Movie" and ha_settings[ "ha_movie" ]:
pass
# place code below this line
# Feature Presentation Outro
elif trigger == "Feature Presentation Outro" and ha_settings[ "ha_fpv_outro" ]:
pass
# place code below this line
# Movie Theatre Intro
elif trigger == "Movie Theatre Outro" and ha_settings[ "ha_mte_outro" ]:
pass
# place code below this line
# Intermission
elif trigger == "Intermission" and ha_settings[ "ha_intermission" ]:
pass
# place code below this line
# Script End
elif trigger == "Script End" and ha_settings[ "ha_script_end" ]:
pass
# place code below this line
# Paused
elif trigger == "Pause" and ha_settings[ "ha_paused" ]:
pass
# place code below this line
# Resumed
elif trigger == "Resume" and ha_settings[ "ha_resumed" ]:
pass
# place code below this line
else:
xbmc.log( "[script.cinema.experience] - [ home_automation.py ] - Opps. Something happened", level=xbmc.LOGNOTICE )
http://pastebin.com/DTqgFbnn
Not really sure what I am doing but it would be good to have the commands I need in the script file.
EDIT: Seems to work when I test in the #trailers section. May have something to do with the fact I am not using the Trivia Info?