Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

3.0.1

  • Loading branch information...
commit 3a37bac21e12b594f4f95dd213b7b2af6bf90789 1 parent 357898a
@Giftie authored
View
594 addon.py
@@ -1,26 +1,20 @@
# -*- coding: utf-8 -*-
-# constants
-__script__ = "Cinema Experience"
-__author__ = "nuka1195-giftie-ackbarr"
-__url__ = "https://github.com/Giftie/script.cinema.experience"
-__version__ = "3.0.0"
-__scriptID__ = "script.cinema.experience"
-
-
-
-
import xbmcgui, xbmc, xbmcaddon, xbmcvfs
import os, re, sys, socket, traceback, time, __builtin__
from urllib import quote_plus
from threading import Thread
#from multiprocessing import Process as Thread
-_A_ = xbmcaddon.Addon( __scriptID__ )
+__addon__ = xbmcaddon.Addon()
+__version__ = __addon__.getAddonInfo('version')
+__scriptID__ = __addon__.getAddonInfo('id')
+__script__ = __addon__.getAddonInfo('name')
+__addonname__ = __script__
# language method
-_L_ = _A_.getLocalizedString
+__language__ = __addon__.getLocalizedString
# settings method
-_S_ = _A_.getSetting
+__setting__ = __addon__.getSetting
true = True
false = False
@@ -30,124 +24,128 @@
"Coming Attractions Outro", "Movie Theater Intro", "Countdown", "Feature Presentation Intro", "Audio Format",
"MPAA Rating", "Movie", "Feature Presentation Outro", "Movie Theatre Outro", "Intermission", "Script End", "Pause", "Resume" )
-trivia_settings = { "trivia_mode": int( _S_( "trivia_mode" ) ),
- "trivia_total_time": int( float( _S_( "trivia_total_time" ) ) ),
- "trivia_folder": xbmc.translatePath( _S_( "trivia_folder" ) ),
- "trivia_slide_time": int( float( _S_( "trivia_slide_time" ) ) ),
- "trivia_intro": _S_( "trivia_intro" ),
- "trivia_music": _S_( "trivia_music" ),
- "trivia_adjust_volume": eval( _S_( "trivia_adjust_volume" ) ),
- "trivia_fade_volume": eval( _S_( "trivia_fade_volume" ) ),
- "trivia_fade_time": int( float( _S_( "trivia_fade_time" ) ) ),
- "trivia_music_file": xbmc.translatePath( _S_( "trivia_music_file" ) ),
- "trivia_music_folder": xbmc.translatePath( _S_( "trivia_music_folder" ) ),
- "trivia_music_volume": int( float( _S_( "trivia_music_volume" ) ) ),
- "trivia_unwatched_only": eval( _S_( "trivia_unwatched_only" ) ),
- "trivia_limit_query": eval( _S_( "trivia_limit_query" ) )
+trivia_settings = { "trivia_mode": int( __setting__( "trivia_mode" ) ),
+ "trivia_total_time": int( float( __setting__( "trivia_total_time" ) ) ),
+ "trivia_slide_time": int( float( __setting__( "trivia_slide_time" ) ) ),
+ "trivia_music": int( __setting__( "trivia_music" ) ),
+ "trivia_folder": xbmc.translatePath( __setting__( "trivia_folder" ) ).decode('utf-8'),
+ "trivia_adjust_volume": eval( __setting__( "trivia_adjust_volume" ) ),
+ "trivia_fade_volume": eval( __setting__( "trivia_fade_volume" ) ),
+ "trivia_fade_time": int( float( __setting__( "trivia_fade_time" ) ) ),
+ "trivia_music_file": xbmc.translatePath( __setting__( "trivia_music_file" ) ).decode('utf-8'),
+ "trivia_music_folder": xbmc.translatePath( __setting__( "trivia_music_folder" ) ).decode('utf-8'),
+ "trivia_music_volume": int( float( __setting__( "trivia_music_volume" ) ) ),
+ "trivia_unwatched_only": eval( __setting__( "trivia_unwatched_only" ) ),
+ "trivia_limit_query": eval( __setting__( "trivia_limit_query" ) ),
+ "trivia_moviequiz_mode": int( __setting__( "trivia_moviequiz_mode" ) ),
+ "trivia_moviequiz_qlimit": int( float( __setting__( "trivia_moviequiz_qlimit" ) ) ),
+ "trivia_rating": __setting__( "trivia_rating" )
}
-trailer_settings = { "trailer_count": ( 0, 1, 2, 3, 4, 5, 10, )[int( float( _S_( "trailer_count" ) ) ) ],
- "trailer_scraper": ( "amt_database", "amt_current", "local", "xbmc_library", )[int( float( _S_( "trailer_scraper" ) ) ) ],
- "trailer_play_mode": int( float( _S_( "trailer_play_mode" ) ) ),
- "trailer_download_folder": xbmc.translatePath( _S_( "trailer_download_folder" ) ),
- "trailer_folder": xbmc.translatePath( _S_( "trailer_folder" ) ),
- "trailer_amt_db_file": xbmc.translatePath( _S_( "trailer_amt_db_file" ) ),
- "trailer_newest_only": eval( _S_( "trailer_newest_only" ) ),
- "trailer_quality": ( "Standard", "480p", "720p", "1080p" )[ int( float( _S_( "trailer_quality" ) ) ) ],
- "trailer_quality_url": ( "", "_480p", "_720p", "_720p", )[ int( float( _S_( "trailer_quality" ) ) ) ],
- "trailer_hd_only": eval( _S_( "trailer_hd_only" ) ),
- "trailer_limit_mpaa": eval( _S_( "trailer_limit_mpaa" ) ),
- "trailer_limit_genre": eval( _S_( "trailer_limit_genre" ) ),
- "trailer_rating": _S_( "trailer_rating" ),
- "trailer_unwatched_movie_only": eval( _S_( "trailer_unwatched_movie_only" ) ),
- "trailer_unwatched_only": eval( _S_( "trailer_unwatched_only" ) )
+trailer_settings = { "trailer_count": ( 0, 1, 2, 3, 4, 5, 10, )[int( float( __setting__( "trailer_count" ) ) ) ],
+ "trailer_scraper": ( "amt_database", "amt_current", "local", "xbmc_library", )[int( float( __setting__( "trailer_scraper" ) ) ) ],
+ "trailer_play_mode": int( float( __setting__( "trailer_play_mode" ) ) ),
+ "trailer_download_folder": xbmc.translatePath( __setting__( "trailer_download_folder" ) ).decode('utf-8'),
+ "trailer_folder": xbmc.translatePath( __setting__( "trailer_folder" ) ).decode('utf-8'),
+ "trailer_amt_db_file": xbmc.translatePath( __setting__( "trailer_amt_db_file" ) ).decode('utf-8'),
+ "trailer_newest_only": eval( __setting__( "trailer_newest_only" ) ),
+ "trailer_quality": ( "Standard", "480p", "720p", "1080p" )[ int( float( __setting__( "trailer_quality" ) ) ) ],
+ "trailer_quality_url": ( "", "_480p", "_720p", "_720p", )[ int( float( __setting__( "trailer_quality" ) ) ) ],
+ "trailer_hd_only": eval( __setting__( "trailer_hd_only" ) ),
+ "trailer_limit_mpaa": eval( __setting__( "trailer_limit_mpaa" ) ),
+ "trailer_limit_genre": eval( __setting__( "trailer_limit_genre" ) ),
+ "trailer_rating": __setting__( "trailer_rating" ),
+ "trailer_unwatched_movie_only": eval( __setting__( "trailer_unwatched_movie_only" ) ),
+ "trailer_unwatched_only": eval( __setting__( "trailer_unwatched_only" ) )
}
-video_settings = { "mte_intro": ( 0, 1, 1, 2, 3, 4, 5, )[ int( float( _S_( "mte_intro" ) ) ) ],
- "mte_intro_type": ( "file", "folder" )[ int( float( _S_( "mte_intro" ) ) ) > 1 ],
- "mte_intro_file": xbmc.translatePath( _S_( "mte_intro_file" ) ).decode('utf-8'),
- "mte_intro_folder": xbmc.translatePath( _S_( "mte_intro_folder" ) ).decode('utf-8'),
- "mte_outro": ( 0, 1, 1, 2, 3, 4, 5, )[ int( float( _S_( "mte_outro" ) ) ) ],
- "mte_outro_type": ( "file", "folder" )[ int( float( _S_( "mte_outro" ) ) ) > 1 ],
- "mte_outro_file": xbmc.translatePath( _S_( "mte_outro_file" ) ).decode('utf-8'),
- "mte_outro_folder": xbmc.translatePath( _S_( "mte_outro_folder" ) ).decode('utf-8'),
- "fpv_intro": ( 0, 1, 1, 2, 3, 4, 5, )[ int( float( _S_( "fpv_intro" ) ) ) ],
- "fpv_intro_type": ( "file", "folder" )[ int( float( _S_( "fpv_intro" ) ) ) > 1 ],
- "fpv_intro_file": xbmc.translatePath( _S_( "fpv_intro_file" ) ).decode('utf-8'),
- "fpv_intro_folder": xbmc.translatePath( _S_( "fpv_intro_folder" ) ).decode('utf-8'),
- "fpv_outro": ( 0, 1, 1, 2, 3, 4, 5, )[ int( float( _S_( "fpv_outro" ) ) ) ],
- "fpv_outro_type": ( "file", "folder" )[ int( float( _S_( "fpv_outro" ) ) ) > 1 ],
- "fpv_outro_file": xbmc.translatePath( _S_( "fpv_outro_file" ) ).decode('utf-8'),
- "fpv_outro_folder": xbmc.translatePath( _S_( "fpv_outro_folder" ) ).decode('utf-8'),
- "enable_ratings": eval( _S_( "enable_ratings" ) ),
- "rating_videos_folder": xbmc.translatePath( _S_( "rating_videos_folder" ) ).decode('utf-8'),
- "enable_audio": eval( _S_( "enable_audio" ) ),
- "audio_videos_folder": xbmc.translatePath( _S_( "audio_videos_folder" ) ).decode('utf-8'),
- "countdown_video": ( 0, 1, 1, 2, 3, 4, 5, )[ int( float( _S_( "countdown_video" ) ) ) ],
- "countdown_video_type": ( "file", "folder" )[ int( float( _S_( "countdown_video" ) ) ) > 1 ],
- "countdown_video_file": xbmc.translatePath( _S_( "countdown_video_file" ) ).decode('utf-8'),
- "countdown_video_folder": xbmc.translatePath( _S_( "countdown_video_folder" ) ).decode('utf-8'),
- "cav_intro": ( 0, 1, 1, 2, 3, 4, 5, )[ int( float( _S_( "cav_outro" ) ) ) ],
- "cav_intro_type": ( "file", "folder" )[ int( float( _S_( "cav_intro" ) ) ) > 1 ],
- "cav_intro_file": xbmc.translatePath( _S_( "cav_intro_file" ) ).decode('utf-8'),
- "cav_intro_folder": xbmc.translatePath( _S_( "cav_intro_folder" ) ).decode('utf-8'),
- "cav_outro": ( 0, 1, 1, 2, 3, 4, 5, )[ int( float( _S_( "cav_outro" ) ) ) ],
- "cav_outro_type": ( "file", "folder" )[ int( float( _S_( "cav_outro" ) ) ) > 1 ],
- "cav_outro_file": xbmc.translatePath( _S_( "cav_outro_file" ) ).decode('utf-8'),
- "cav_outro_folder": xbmc.translatePath( _S_( "cav_outro_folder" ) ).decode('utf-8'),
- "trivia_intro": ( 0, 1, 1, 2, 3, 4, 5, )[ int( float( _S_( "trivia_intro" ) ) ) ],
- "trivia_intro_type": ( "file", "folder" )[ int( float( _S_( "trivia_intro" ) ) ) > 1 ],
- "trivia_intro_file": xbmc.translatePath( _S_( "trivia_intro_file" ) ).decode('utf-8'),
- "trivia_intro_folder": xbmc.translatePath( _S_( "trivia_intro_folder" ) ).decode('utf-8'),
- "trivia_outro": ( 0, 1, 1, 2, 3, 4, 5, )[ int( float( _S_( "trivia_outro" ) ) ) ],
- "trivia_outro_type": ( "file", "folder" )[ int( float( _S_( "trivia_outro" ) ) ) > 1 ],
- "trivia_outro_file": xbmc.translatePath( _S_( "trivia_outro_file" ) ).decode('utf-8'),
- "trivia_outro_folder": xbmc.translatePath( _S_( "trivia_outro_folder" ) ).decode('utf-8')
+video_settings = { "mte_intro": ( 0, 1, 1, 2, 3, 4, 5, )[ int( float( __setting__( "mte_intro" ) ) ) ],
+ "mte_intro_type": ( "file", "folder" )[ int( float( __setting__( "mte_intro" ) ) ) > 1 ],
+ "mte_intro_file": xbmc.translatePath( __setting__( "mte_intro_file" ) ).decode('utf-8'),
+ "mte_intro_folder": xbmc.translatePath( __setting__( "mte_intro_folder" ) ).decode('utf-8'),
+ "mte_outro": ( 0, 1, 1, 2, 3, 4, 5, )[ int( float( __setting__( "mte_outro" ) ) ) ],
+ "mte_outro_type": ( "file", "folder" )[ int( float( __setting__( "mte_outro" ) ) ) > 1 ],
+ "mte_outro_file": xbmc.translatePath( __setting__( "mte_outro_file" ) ).decode('utf-8'),
+ "mte_outro_folder": xbmc.translatePath( __setting__( "mte_outro_folder" ) ).decode('utf-8'),
+ "fpv_intro": ( 0, 1, 1, 2, 3, 4, 5, )[ int( float( __setting__( "fpv_intro" ) ) ) ],
+ "fpv_intro_type": ( "file", "folder" )[ int( float( __setting__( "fpv_intro" ) ) ) > 1 ],
+ "fpv_intro_file": xbmc.translatePath( __setting__( "fpv_intro_file" ) ).decode('utf-8'),
+ "fpv_intro_folder": xbmc.translatePath( __setting__( "fpv_intro_folder" ) ).decode('utf-8'),
+ "fpv_outro": ( 0, 1, 1, 2, 3, 4, 5, )[ int( float( __setting__( "fpv_outro" ) ) ) ],
+ "fpv_outro_type": ( "file", "folder" )[ int( float( __setting__( "fpv_outro" ) ) ) > 1 ],
+ "fpv_outro_file": xbmc.translatePath( __setting__( "fpv_outro_file" ) ).decode('utf-8'),
+ "fpv_outro_folder": xbmc.translatePath( __setting__( "fpv_outro_folder" ) ).decode('utf-8'),
+ "enable_ratings": eval( __setting__( "enable_ratings" ) ),
+ "rating_videos_folder": xbmc.translatePath( __setting__( "rating_videos_folder" ) ).decode('utf-8'),
+ "enable_audio": eval( __setting__( "enable_audio" ) ),
+ "audio_videos_folder": xbmc.translatePath( __setting__( "audio_videos_folder" ) ).decode('utf-8'),
+ "countdown_video": ( 0, 1, 1, 2, 3, 4, 5, )[ int( float( __setting__( "countdown_video" ) ) ) ],
+ "countdown_video_type": ( "file", "folder" )[ int( float( __setting__( "countdown_video" ) ) ) > 1 ],
+ "countdown_video_file": xbmc.translatePath( __setting__( "countdown_video_file" ) ).decode('utf-8'),
+ "countdown_video_folder": xbmc.translatePath( __setting__( "countdown_video_folder" ) ).decode('utf-8'),
+ "cav_intro": ( 0, 1, 1, 2, 3, 4, 5, )[ int( float( __setting__( "cav_outro" ) ) ) ],
+ "cav_intro_type": ( "file", "folder" )[ int( float( __setting__( "cav_intro" ) ) ) > 1 ],
+ "cav_intro_file": xbmc.translatePath( __setting__( "cav_intro_file" ) ).decode('utf-8'),
+ "cav_intro_folder": xbmc.translatePath( __setting__( "cav_intro_folder" ) ).decode('utf-8'),
+ "cav_outro": ( 0, 1, 1, 2, 3, 4, 5, )[ int( float( __setting__( "cav_outro" ) ) ) ],
+ "cav_outro_type": ( "file", "folder" )[ int( float( __setting__( "cav_outro" ) ) ) > 1 ],
+ "cav_outro_file": xbmc.translatePath( __setting__( "cav_outro_file" ) ).decode('utf-8'),
+ "cav_outro_folder": xbmc.translatePath( __setting__( "cav_outro_folder" ) ).decode('utf-8'),
+ "trivia_intro": ( 0, 1, 1, 2, 3, 4, 5, )[ int( float( __setting__( "trivia_intro" ) ) ) ],
+ "trivia_intro_type": ( "file", "folder" )[ int( float( __setting__( "trivia_intro" ) ) ) > 1 ],
+ "trivia_intro_file": xbmc.translatePath( __setting__( "trivia_intro_file" ) ).decode('utf-8'),
+ "trivia_intro_folder": xbmc.translatePath( __setting__( "trivia_intro_folder" ) ).decode('utf-8'),
+ "trivia_outro": ( 0, 1, 1, 2, 3, 4, 5, )[ int( float( __setting__( "trivia_outro" ) ) ) ],
+ "trivia_outro_type": ( "file", "folder" )[ int( float( __setting__( "trivia_outro" ) ) ) > 1 ],
+ "trivia_outro_file": xbmc.translatePath( __setting__( "trivia_outro_file" ) ).decode('utf-8'),
+ "trivia_outro_folder": xbmc.translatePath( __setting__( "trivia_outro_folder" ) ).decode('utf-8')
}
-feature_settings = { "enable_notification": eval( _S_( "enable_notification" ) ),
- "number_of_features": int( float( _S_( "number_of_features" ) ) ),
- "intermission_video": ( 0, 1, 1, 2, 3, 4, 5, )[ int( float( _S_( "intermission_video" ) ) ) ],
- "intermission_video_type": ( "file", "folder" )[ int( _S_( "intermission_video" ) ) > 1 ],
- "intermission_video_file": xbmc.translatePath( _S_( "intermission_video_file" ) ).decode('utf-8'),
- "intermission_video_folder": xbmc.translatePath( _S_( "intermission_video_folder" ) ).decode('utf-8'),
- "intermission_audio": eval( _S_( "intermission_audio" ) ),
- "intermission_ratings": eval( _S_( "intermission_ratings" ) )
+feature_settings = { "enable_notification": eval( __setting__( "enable_notification" ) ),
+ "number_of_features": int( float( __setting__( "number_of_features" ) ) ),
+ "intermission_video": ( 0, 1, 1, 2, 3, 4, 5, )[ int( float( __setting__( "intermission_video" ) ) ) ],
+ "intermission_video_type": ( "file", "folder" )[ int( __setting__( "intermission_video" ) ) > 1 ],
+ "intermission_video_file": xbmc.translatePath( __setting__( "intermission_video_file" ) ).decode('utf-8'),
+ "intermission_video_folder": xbmc.translatePath( __setting__( "intermission_video_folder" ) ).decode('utf-8'),
+ "intermission_audio": eval( __setting__( "intermission_audio" ) ),
+ "intermission_ratings": eval( __setting__( "intermission_ratings" ) )
}
-ha_settings = { "ha_enable": eval( _S_( "ha_enable" ) ),
- "ha_multi_trigger": eval( _S_( "ha_multi_trigger" ) ),
- "ha_script_start": eval( _S_( "ha_script_start" ) ),
- "ha_trivia_intro": eval( _S_( "ha_trivia_intro" ) ),
- "ha_trivia_start": eval( _S_( "ha_trivia_start" ) ),
- "ha_trivia_outro": eval( _S_( "ha_trivia_outro" ) ),
- "ha_mte_intro": eval( _S_( "ha_mte_intro" ) ),
- "ha_cav_intro": eval( _S_( "ha_cav_intro" ) ),
- "ha_trailer_start": eval( _S_( "ha_trailer_start" ) ),
- "ha_cav_outro": eval( _S_( "ha_cav_outro" ) ),
- "ha_fpv_intro": eval( _S_( "ha_fpv_intro" ) ),
- "ha_mpaa_rating": eval( _S_( "ha_mpaa_rating" ) ),
- "ha_countdown_video": eval( _S_( "ha_countdown_video" ) ),
- "ha_audio_format": eval( _S_( "ha_audio_format" ) ),
- "ha_movie": eval( _S_( "ha_movie" ) ),
- "ha_fpv_outro": eval( _S_( "ha_fpv_outro" ) ),
- "ha_mte_outro": eval( _S_( "ha_mte_outro" ) ),
- "ha_intermission": eval( _S_( "ha_intermission" ) ),
- "ha_script_end": eval( _S_( "ha_script_end" ) ),
- "ha_paused": eval( _S_( "ha_paused" ) ),
- "ha_resumed": eval( _S_( "ha_resumed" ) )
+ha_settings = { "ha_enable": eval( __setting__( "ha_enable" ) ),
+ "ha_multi_trigger": eval( __setting__( "ha_multi_trigger" ) ),
+ "ha_script_start": eval( __setting__( "ha_script_start" ) ),
+ "ha_trivia_intro": eval( __setting__( "ha_trivia_intro" ) ),
+ "ha_trivia_start": eval( __setting__( "ha_trivia_start" ) ),
+ "ha_trivia_outro": eval( __setting__( "ha_trivia_outro" ) ),
+ "ha_mte_intro": eval( __setting__( "ha_mte_intro" ) ),
+ "ha_cav_intro": eval( __setting__( "ha_cav_intro" ) ),
+ "ha_trailer_start": eval( __setting__( "ha_trailer_start" ) ),
+ "ha_cav_outro": eval( __setting__( "ha_cav_outro" ) ),
+ "ha_fpv_intro": eval( __setting__( "ha_fpv_intro" ) ),
+ "ha_mpaa_rating": eval( __setting__( "ha_mpaa_rating" ) ),
+ "ha_countdown_video": eval( __setting__( "ha_countdown_video" ) ),
+ "ha_audio_format": eval( __setting__( "ha_audio_format" ) ),
+ "ha_movie": eval( __setting__( "ha_movie" ) ),
+ "ha_fpv_outro": eval( __setting__( "ha_fpv_outro" ) ),
+ "ha_mte_outro": eval( __setting__( "ha_mte_outro" ) ),
+ "ha_intermission": eval( __setting__( "ha_intermission" ) ),
+ "ha_script_end": eval( __setting__( "ha_script_end" ) ),
+ "ha_paused": eval( __setting__( "ha_paused" ) ),
+ "ha_resumed": eval( __setting__( "ha_resumed" ) )
}
+extra_settings = { "voxcommando": eval( __setting__( "voxcommando" ) ) }
+
number_of_features = feature_settings[ "number_of_features" ] + 1
playback = ""
BASE_CACHE_PATH = os.path.join( xbmc.translatePath( "special://profile" ).decode('utf-8'), "Thumbnails", "Video" )
-BASE_CURRENT_SOURCE_PATH = os.path.join( xbmc.translatePath( "special://profile/addon_data/" ).decode('utf-8'), os.path.basename( _A_.getAddonInfo('path') ) )
-BASE_RESOURCE_PATH = xbmc.translatePath( os.path.join( _A_.getAddonInfo('path').decode('utf-8'), 'resources' ) )
+BASE_CURRENT_SOURCE_PATH = os.path.join( xbmc.translatePath( "special://profile/addon_data/" ).decode('utf-8'), os.path.basename( __addon__.getAddonInfo('path') ) )
+BASE_RESOURCE_PATH = xbmc.translatePath( os.path.join( __addon__.getAddonInfo('path').decode('utf-8'), 'resources' ) )
sys.path.append( os.path.join( BASE_RESOURCE_PATH, "lib" ) )
-headings = ( _L_(32600), _L_(32601), _L_(32602), _L_(32603), _L_(32604), _L_(32605), _L_(32606), _L_(32607), _L_(32608), _L_(32609), _L_(32610), _L_(32611), _L_(32612) )
+headings = ( __language__(32600), __language__(32601), __language__(32602), __language__(32603), __language__(32604), __language__(32605), __language__(32606), __language__(32607), __language__(32608), __language__(32609), __language__(32610), __language__(32611), __language__(32612) )
header = "Cinema Experience"
time_delay = 200
-image = xbmc.translatePath( os.path.join( _A_.getAddonInfo("path"), "icon.png") ).decode('utf-8')
+image = xbmc.translatePath( os.path.join( __addon__.getAddonInfo("path"), "icon.png") ).decode('utf-8')
playlist = xbmc.PlayList( xbmc.PLAYLIST_VIDEO )
is_paused = False
prev_trigger = ""
@@ -157,51 +155,16 @@
from slides import _fetch_slides
from new_trailer_downloader import downloader
from utils import settings_to_log
-
+from launch_automation import Launch_automation
from pre_eden_code import _store_playlist, _get_queued_video_info
#Check to see if module is moved to /userdata/addon_data/script.cinema.experience
-try:
- if not xbmcvfs.exists( os.path.join( BASE_CURRENT_SOURCE_PATH, "ha_scripts", "home_automation.py" ) ) and ha_settings[ "ha_enable" ]:
- source = os.path.join( BASE_RESOURCE_PATH, "ha_scripts", "home_automation.py" )
- destination = os.path.join( BASE_CURRENT_SOURCE_PATH, "ha_scripts", "home_automation.py" )
- xbmcvfs.mkdir( os.path.join( BASE_CURRENT_SOURCE_PATH, "ha_scripts" ) )
- xbmcvfs.copy( source, destination )
- xbmc.log( "[ script.cinema.experience ] - home_automation.py copied", level=xbmc.LOGNOTICE )
- sys.path.append( os.path.join( BASE_CURRENT_SOURCE_PATH, "ha_scripts" ) )
- from home_automation import Automate
- # Import HA module set ha_imported to True if successful
- ha_imported = True
-except ImportError:
- # or ha_imported to False if unsuccessful
- xbmc.log( "[ script.cinema.experience ] - Failed to import Automate", level=xbmc.LOGNOTICE )
- ha_imported = False
-except:
- traceback.print_exc()
- ha_imported = False
-
-ce_pause_time = int( float( _S_("ha_pause_time") ) )
-
-class CE_Player( xbmc.Player ):
- def __init__(self, *args, **kwargs):
- xbmc.Player.__init__( self )
-
- def onPlayBackPaused( self ):
- Launch_automation().launch_automation( trigger = "Pause", prev_trigger = None )
- is_paused = True
-
- def onPlayBackResumed( self ):
- Launch_automation().launch_automation( trigger = "Resumed", prev_trigger = None )
- is_paused = False
-
-class Launch_automation():
- def __init__(self, *args, **kwargs):
- pass
-
- def launch_automation( self, trigger = None, prev_trigger = None, mode="normal" ):
- if _S_( "ha_enable" ) == "true":
- prev_trigger = Automate().activate_ha( trigger, prev_trigger, mode )
- return prev_trigger
+if not xbmcvfs.exists( os.path.join( BASE_CURRENT_SOURCE_PATH, "ha_scripts", "home_automation.py" ) ) and ha_settings[ "ha_enable" ]:
+ source = os.path.join( BASE_RESOURCE_PATH, "ha_scripts", "home_automation.py" )
+ destination = os.path.join( BASE_CURRENT_SOURCE_PATH, "ha_scripts", "home_automation.py" )
+ xbmcvfs.mkdir( os.path.join( BASE_CURRENT_SOURCE_PATH, "ha_scripts" ) )
+ xbmcvfs.copy( source, destination )
+ xbmc.log( "[ script.cinema.experience ] - home_automation.py copied", level=xbmc.LOGNOTICE )
def footprints():
xbmc.log( "[ script.cinema.experience ] - Script Name: %s" % __script__, level=xbmc.LOGNOTICE )
@@ -209,30 +172,13 @@ def footprints():
xbmc.log( "[ script.cinema.experience ] - Script Version: %s" % __version__, level=xbmc.LOGNOTICE )
xbmc.log( "[ script.cinema.experience ] - Starting Window ID: %s" % xbmcgui.getCurrentWindowId(), level=xbmc.LOGNOTICE )
-def _load_trigger_list():
- xbmc.log( "[script.cinema.experience] - Loading Trigger List", level=xbmc.LOGNOTICE)
- try:
- # set base watched file path
- base_path = os.path.join( BASE_CURRENT_SOURCE_PATH, "trigger_list.txt" )
- # open path
- usock = open( base_path, "r" )
- # read source
- trigger_list = eval( usock.read() )
- # close socket
- usock.close()
- except:
- xbmc.log( "[script.cinema.experience] - Error Loading Trigger List", level=xbmc.LOGNOTICE)
- traceback.print_exc()
- trigger_list = []
- return trigger_list
-
def _clear_watched_items( clear_type ):
xbmc.log( "[ script.cinema.experience ] - _clear_watched_items( %s )" % ( clear_type ), level=xbmc.LOGNOTICE )
# initialize base_path
base_paths = []
# clear trivia or trailers
if ( clear_type == "ClearWatchedTrailers" ):
- # trailer settings, grab them here so we don't need another _S_() object
+ # trailer settings, grab them here so we don't need another __setting__() object
# handle AMT db special
sys.path.append( os.path.join( BASE_RESOURCE_PATH, "lib", "scrapers") )
from amt_database import scraper as scraper
@@ -257,7 +203,7 @@ def _clear_watched_items( clear_type ):
# set proper message
message = ( 32532, 32542, )[ sys.argv[ 1 ] == "ClearWatchedTrailers" ]
# inform user of result
- ok = xbmcgui.Dialog().ok( _L_( 32000 ), _L_( message ) )
+ ok = xbmcgui.Dialog().ok( __language__( 32000 ), __language__( message ) )
def _clear_playlists( mode="both" ):
# clear playlists
@@ -308,282 +254,6 @@ def _build_playlist( movies, mode = "movie_titles" ):
xbmc.log( "[script.cinema.experience] - JSONRPC Response: \n%s" % json_response, level=xbmc.LOGDEBUG )
xbmc.sleep( 50 )
-class Script():
- def __init__(self, *args, **kwargs):
- self. init_var()
-
- def init_var( self ):
- self.player = CE_Player()
-
- def start_script( self, library_view = "oldway" ):
- messy_exit = False
- xbmc.log( "[ script.cinema.experience ] - Library_view: %s" % library_view, level=xbmc.LOGNOTICE )
- early_exit = False
- movie_next = False
- prev_trigger = None
- if library_view != "oldway":
- xbmc.executebuiltin( "ActivateWindow(videolibrary,%s,return)" % library_view )
- # wait until Video Library shows
- while not xbmc.getCondVisibility( "Container.Content(movies)" ):
- pass
- if _S_( "enable_notification" ) == "true":
- xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % (header, _L_( 32546 ), 300000, image) )
- # wait until playlist is full to the required number of features
- xbmc.log( "[ script.cinema.experience ] - Waiting for queue to be filled with %s Feature films" % number_of_features, level=xbmc.LOGNOTICE )
- count = 0
- while playlist.size() < number_of_features:
- if playlist.size() > count:
- xbmc.log( "[ script.cinema.experience ] - User queued %s of %s Feature films" % (playlist.size(), number_of_features), level=xbmc.LOGNOTICE )
- header1 = header + " - Feature " + "%d" % playlist.size()
- message = _L_( 32543 ) + playlist[playlist.size() -1].getdescription()
- if _S_( "enable_notification" ) == "true":
- xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % (header1, message, time_delay, image) )
- count = playlist.size()
- xbmc.sleep(time_delay*2)
- if not xbmc.getCondVisibility( "Container.Content(movies)" ):
- early_exit = True
- break
- xbmc.log( "[ script.cinema.experience ] - User queued %s Feature films" % playlist.size(), level=xbmc.LOGNOTICE )
- if not early_exit:
- header1 = header + " - Feature " + "%d" % playlist.size()
- message = _L_( 32543 ) + playlist[playlist.size() -1].getdescription()
- if _S_( "enable_notification" ) == "true":
- xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % (header1, message, time_delay, image) )
- early_exit = False
- # If for some reason the limit does not get reached and the window changed, cancel script
- if playlist.size() < number_of_features and library_view != "oldway":
- if _S_( "enable_notification" ) == "true":
- xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % (header, _L_( 32544 ), time_delay, image) )
- _clear_playlists()
- else:
- mpaa, audio, genre, movie, equivalent_mpaa = _get_queued_video_info( feature = 0 )
- plist = _store_playlist() # need to store movie playlist
- self._play_trivia( mpaa, genre, plist, equivalent_mpaa )
- _clear_playlists( "music" )
- trigger_list = _load_trigger_list()
- count = -1
- stop_check = 0
- paused = False
- # prelim programming for adding - Activate script and other additions
- while not playlist.getposition() == ( playlist.size() - 1 ):
- if playlist.getposition() > count:
- try:
- xbmc.log( "[ script.cinema.experience ] - Item From Trigger List: %s" % trigger_list[ playlist.getposition() ], level=xbmc.LOGNOTICE )
- except:
- xbmc.log( "[ script.cinema.experience ] - Problem With Trigger List", level=xbmc.LOGNOTICE )
- xbmc.log( "[ script.cinema.experience ] - Playlist Position: %s Playlist Size: %s " % ( ( playlist.getposition() + 1 ), ( playlist.size() ) ), level=xbmc.LOGNOTICE )
- if not playlist.getposition() == ( playlist.size() - 1 ):
- prev_trigger = Launch_automation().launch_automation( trigger_list[ playlist.getposition() ], prev_trigger )
- count = playlist.getposition()
- else:
- break # Reached the last item in the playlist
- try:
- #if not self.player.isPlayingVideo() and not is_paused:
- if not xbmc.getCondVisibility( "Window.IsActive(fullscreenvideo)" ):
- xbmc.log( "[ script.cinema.experience ] - Video may have stopped", level=xbmc.LOGNOTICE )
- messy_exit = True
- break
- except:
- if xbmc.getCondVisibility( "Container.Content(movies)" ):
- xbmc.log( "[ script.cinema.experience ] - Video Definitely Stopped", level=xbmc.LOGNOTICE )
- messy_exit = True
- break
- if not playlist.size() < 1 and not messy_exit: # To catch an already running script when a new instance started
- xbmc.log( "[ script.cinema.experience ] - Playlist Position: %s Playlist Size: %s " % ( playlist.getposition() + 1, ( playlist.size() ) ), level=xbmc.LOGNOTICE )
- prev_trigger = Launch_automation().launch_automation( trigger_list[ playlist.getposition() ], prev_trigger )
- if trigger_list[ playlist.getposition() ] == "Movie":
- xbmc.log( "[ script.cinema.experience ] - Item From Trigger List: %s" % trigger_list[ playlist.getposition() ], level=xbmc.LOGNOTICE )
- else:
- xbmc.log( "[ script.cinema.experience ] - Item From Trigger List: %s" % trigger_list[ playlist.getposition() ], level=xbmc.LOGNOTICE )
- messy_exit = False
- xbmc.sleep(1000)
- self._wait_until_end()
- else:
- xbmc.log( "[ script.cinema.experience ] - User might have pressed stop", level=xbmc.LOGNOTICE )
- xbmc.log( "[ script.cinema.experience ] - Stopping Script", level=xbmc.LOGNOTICE )
- messy_exit = False
- del self.player
- return messy_exit
-
- def broadcastUDP( self, data, port = 8278 ): # XBMC's former HTTP API output port is 8278
- IPADDR = '255.255.255.255'
- PORTNUM = port
- s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0)
- if hasattr(socket,'SO_BROADCAST'):
- s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
- s.connect((IPADDR, PORTNUM))
- s.send(data)
- s.close()
-
- def voxcommando():
- playlistsize = playlist.size()
- if playlistsize > 1:
- movie_titles = ""
- #for feature_count in range (1, playlistsize + 1):
- for feature_count in range (1, playlistsize):
- movie_title = playlist[ feature_count - 1 ].getdescription()
- xbmc.log( "[ script.cinema.experience ] - Feature #%-2d - %s" % ( feature_count, movie_title ), level=xbmc.LOGNOTICE )
- movie_titles = movie_titles + movie_title + "<li>"
- movie_titles = movie_titles.rstrip("<li>")
- if eval( _S_( "voxcommando" ) ):
- self.broadcastUDP( "<b>CElaunch." + str( playlistsize ) + "<li>" + movie_titles + "</b>", port = 33000 )
- else:
- # get the queued video info
- movie_title = playlist[ 0 ].getdescription()
- xbmc.log( "[ script.cinema.experience ] - Feature - %s" % movie_title, level=xbmc.LOGNOTICE )
- if eval( _S_( "voxcommando" ) ):
- self.broadcastUDP( "<b>CElaunch<li>" + movie_title + "</b>", port = 33000 )
-
- # No longer works in Frodo to be removed
- def _sqlquery( self, sqlquery ):
- movie_list = []
- movies = []
- xbmc.executehttpapi( "SetResponseFormat()" )
- xbmc.executehttpapi( "SetResponseFormat(OpenField,)" )
- sqlquery = "SELECT movieview.c00 FROM movieview JOIN genrelinkmovie ON genrelinkmovie.idMovie=movieview.idMovie JOIN genre ON genrelinkmovie.idGenre=genre.idGenre WHERE strGenre='Action' ORDER BY RANDOM() LIMIT 4"
- xbmc.log( "[ script.cinema.experience ] - SQL: %s" % ( sqlquery, ), level=xbmc.LOGDEBUG )
- try:
- sqlresult = xbmc.executehttpapi( "QueryVideoDatabase(%s)" % quote_plus( sqlquery ), )
- xbmc.log( "[ script.cinema.experience ] - sqlresult: %s" % sqlresult, level=xbmc.LOGDEBUG )
- movies = sqlresult.split("</field>")
- movie_list = movies[ 0:len( movies ) -1 ]
- except:
- xbmc.log( "[ script.cinema.experience ] - Error searching database", level=xbmc.LOGNOTICE )
- return movie_list
-
- def trivia_intro( self ):
- xbmc.log( "[ script.cinema.experience ] - ## Intro ##", level=xbmc.LOGNOTICE)
- play_list = playlist
- play_list.clear()
- # initialize intro lists
- playlist_intro = []
- # get trivia intro videos
- _get_special_items( playlist=play_list,
- items=( 0, 1, 1, 2, 3, 4, 5, )[ int( _S_( "trivia_intro" ) ) ],
- path=( xbmc.translatePath( _S_( "trivia_intro_file" ) ), xbmc.translatePath( _S_( "trivia_intro_folder" ) ), )[ int( _S_( "trivia_intro" ) ) > 1 ],
- genre= "Trivia Intro",
- index=0,
- media_type="video"
- )
- if not int( _S_( "trivia_intro" ) ) == 0:
- self.player.play( play_list )
-
- def start_downloader( self, mpaa, genre, equivalent_mpaa ):
- # start the downloader if Play Mode is set to stream and if scraper is not Local or XBMC_library
- if ( int( _S_( "trailer_play_mode" ) ) == 1 ) and ( not ( int( _S_( "trailer_scraper" ) ) in (2, 3) ) ):
- xbmc.log( "[ script.cinema.experience ] - Starting Downloader Thread", level=xbmc.LOGNOTICE )
- thread = Thread( target=downloader, args=( mpaa, genre, equivalent_mpaa ) )
- thread.start()
- else:
- pass
-
- def _wait_until_end( self ): # wait until the end of the playlist(for Trivia Intro)
- xbmc.log( "[ script.cinema.experience ] - Waiting Until End Of Video", level=xbmc.LOGNOTICE)
- try:
- self.psize = int( xbmc.PlayList( xbmc.PLAYLIST_VIDEO ).size() ) - 1
- xbmc.log( "[ script.cinema.experience ] - Playlist Size: %s" % ( self.psize + 1 ), level=xbmc.LOGDEBUG)
- while xbmc.PlayList( xbmc.PLAYLIST_VIDEO ).getposition() < self.psize:
- pass
- xbmc.log( "[ script.cinema.experience ] - Video TotalTime: %s" % self.player.getTotalTime(), level=xbmc.LOGDEBUG)
- while self.player.getTime() < ( self.player.getTotalTime() - 1 ):
- pass
- xbmc.log( "[ script.cinema.experience ] - Video getTime: %s" % self.player.getTime(), level=xbmc.LOGDEBUG)
- #xbmc.sleep(400)
- except:
- traceback.print_exc()
- xbmc.log( "[ script.cinema.experience ] - Video either stopped or skipped, Continuing on...", level=xbmc.LOGDEBUG)
-
- def _play_trivia( self, mpaa, genre, plist, equivalent_mpaa ):
- Launch_automation().launch_automation( triggers[0] ) # Script Start - Or where it seems to be
- if int( _S_( "trivia_mode" ) ) == 2: # Start Movie Quiz Script
- xbmc.log( "[ script.cinema.experience ] - Starting script.moviequiz", level=xbmc.LOGNOTICE )
- self.start_downloader( mpaa, genre, equivalent_mpaa )
- try:
- _MA_= xbmcaddon.Addon( "script.moviequiz" )
- BASE_MOVIEQUIZ_PATH = xbmc.translatePath( _MA_.getAddonInfo('path') )
- sys.path.append( BASE_MOVIEQUIZ_PATH )
- try:
- import quizlib.question as question
- xbmc.log( "[ script.cinema.experience ] - Loaded question module", level=xbmc.LOGNOTICE )
- except ImportError:
- traceback.print_exc()
- xbmc.log( "[ script.cinema.experience ] - Failed to Load question module", level=xbmc.LOGNOTICE )
- except:
- traceback.print_exc()
- try:
- import quizlib.mq_ce_play as moviequiz
- xbmc.log( "[ script.cinema.experience ] - Loaded mq_ce_play module", level=xbmc.LOGNOTICE )
- except ImportError:
- traceback.print_exc()
- xbmc.log( "[ script.cinema.experience ] - Failed to Load mq_ce_play module", level=xbmc.LOGNOTICE )
- except:
- traceback.print_exc()
- # pDialog.close()
- Launch_automation().launch_automation( triggers[0] ) # Script Start - Or where it seems to be
- self.trivia_intro()
- if playlist.size() > 0:
- self._wait_until_end()
- xbmc.sleep(500) # wait .5 seconds
- path = _MA_.getAddonInfo('path')
- question_type = 1
- mode = ( True, False )[ int( float( _S_( "trivia_moviequiz_mode" ) ) ) ]
- mpaa = ( _S_( "trivia_rating" ), equivalent_mpaa, )[ eval( _S_( "trivia_limit_query" ) ) ]
- question_limit = int( float( _S_( "trivia_moviequiz_qlimit" ) ) )
- completion = moviequiz.runCinemaExperience( question_type, mode, mpaa, genre, question_limit )
- if completion:
- xbmc.log( "[ script.cinema.experience ] - Completed script.moviequiz", level=xbmc.LOGNOTICE )
- else:
- xbmc.log( "[ script.cinema.experience ] - Failed in script.moviequiz", level=xbmc.LOGNOTICE )
- except:
- traceback.print_exc()
- xbmc.log( "[ script.cinema.experience ] - Failed to start script.moviequiz", level=xbmc.LOGNOTICE )
- _rebuild_playlist( plist )
- import xbmcscript_player as script
- script.Main()
- #xbmc.sleep(500) # wait .5 seconds
- self.player.play( playlist )
- elif _S_( "trivia_folder" ) and int( _S_( "trivia_mode" ) ) == 1: # Start Slide Show
- self.start_downloader( mpaa, genre, equivalent_mpaa )
- # trivia settings, grab them here so we don't need another _S_() object
- if not int( _S_( "trivia_music" ) )== 0:
- build_music_playlist()
- # set the proper mpaa rating user preference
- mpaa = ( _S_( "trivia_rating" ), equivalent_mpaa, )[ eval( _S_( "trivia_limit_query" ) ) ]
- xbmc.log( "[ script.cinema.experience ] - Slide MPAA Rating: %s" % equivalent_mpaa, level=xbmc.LOGNOTICE )
- # import trivia module and execute the gui
- slide_playlist = _fetch_slides( equivalent_mpaa )
- self.trivia_intro()
- if playlist.size() > 0:
- Launch_automation().launch_automation( triggers[1] ) # Trivia Intro
- xbmc.sleep(500) # wait .5 seconds
- self._wait_until_end()
- #xbmc.sleep(500) # wait .5 seconds
- __builtin__.plist = plist
- __builtin__.slide_playlist = slide_playlist
- __builtin__.movie_mpaa = mpaa
- __builtin__.movie_genre = genre
- from xbmcscript_trivia import Trivia
- xbmc.log( "[ script.cinema.experience ] - Starting Trivia script", level=xbmc.LOGNOTICE )
- Launch_automation().launch_automation( triggers[2] ) # Trivia Start
- ui = Trivia( "script-CExperience-trivia.xml", _A_.getAddonInfo('path'), "default", "720p" )
- ui.doModal()
- del ui
- # we need to activate the video window
- #xbmc.sleep(5) # wait .005 seconds
- xbmc.executebuiltin( "XBMC.ActivateWindow(2005)" )
- self.player.play( playlist )
- elif int( _S_( "trivia_mode" ) ) == 0: # No Trivia
- # no trivia slide show so play the video
- self.start_downloader( mpaa, genre, equivalent_mpaa )
- _rebuild_playlist( plist )
- # play the video playlist
- import xbmcscript_player as script
- script.Main()
- Launch_automation().launch_automation( triggers[0] ) # Script Start - Or where it seems to be
- xbmc.sleep(500) # wait .5 seconds
- self.player.play( playlist )
-
-
if __name__ == "__main__" :
#xbmc.sleep( 2000 )
footprints()
@@ -591,6 +261,7 @@ def _play_trivia( self, mpaa, genre, plist, equivalent_mpaa ):
settings_to_log( BASE_CURRENT_SOURCE_PATH, script_header )
# check to see if an argv has been passed to script
xbmcgui.Window(10025).setProperty( "CinemaExperienceRunning", "True" )
+ from ce_player import Script
try:
try:
if sys.argv[ 1 ]:
@@ -601,8 +272,8 @@ def _play_trivia( self, mpaa, genre, plist, equivalent_mpaa ):
if sys.argv[ 1 ] == "ClearWatchedTrivia" or sys.argv[ 1 ] == "ClearWatchedTrailers":
_clear_watched_items( sys.argv[ 1 ] )
exit = True
- elif sys.argv[ 1 ] == "oldway":
- _A_.setSetting( id='number_of_features', value='0' ) # set number of features to 1
+ elif sys.argv[ 1 ] == "oldway":
+ __addon__.setSetting( id='number_of_features', value='0' ) # set number of features to 1
_clear_playlists()
xbmc.sleep( 250 )
xbmc.executebuiltin( "Action(Queue,%d)" % ( xbmcgui.getCurrentWindowId() - 10000, ) )
@@ -610,6 +281,9 @@ def _play_trivia( self, mpaa, genre, plist, equivalent_mpaa ):
# we need to sleep so the video gets queued properly
xbmc.sleep( 250 )
exit = Script().start_script( "oldway" )
+ elif sys.argv[ 1 ] == "fromplay":
+ xbmc.sleep( 250 )
+ exit = Script().start_script( "oldway" )
elif sys.argv[ 1 ].startswith( "command" ): # Command Arguments
_sys_arg = sys.argv[ 1 ].replace("<li>",";")
_command = re.split(";", _sys_arg, maxsplit=1)[1]
@@ -636,7 +310,7 @@ def _play_trivia( self, mpaa, genre, plist, equivalent_mpaa ):
else:
exit = False
elif _command.startswith( "open_settings" ): # Open Settings
- _A_.openSettings()
+ __addon__.openSettings()
exit = False
elif sys.argv[ 1 ].startswith( "movieid=" ):
_clear_playlists()
@@ -655,7 +329,7 @@ def _play_trivia( self, mpaa, genre, plist, equivalent_mpaa ):
except:
if not int( xbmcgui.getCurrentWindowId() ) == 10001: # Not Started from Addon/Programs window
#start script in 'Old Way' if the script is called with out argv... queue the movie the old way
- _A_.setSetting( id='number_of_features', value='0' ) # set number of features to 1
+ __addon__.setSetting( id='number_of_features', value='0' ) # set number of features to 1
_clear_playlists()
xbmc.executebuiltin( "Action(Queue,%d)" % ( xbmcgui.getCurrentWindowId() - 10000, ) )
xbmc.log( "[ script.cinema.experience ] - Action(Queue,%d)" % ( xbmcgui.getCurrentWindowId() - 10000, ), level=xbmc.LOGNOTICE )
@@ -663,20 +337,20 @@ def _play_trivia( self, mpaa, genre, plist, equivalent_mpaa ):
xbmc.sleep( 500 )
exit = Script().start_script( "oldway" )
else:
- _A_.openSettings()
+ __addon__.openSettings()
exit = True
- #xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % (header, _L_( 32545 ), time_delay, image) )
+ #xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % (header, __language__( 32545 ), time_delay, image) )
xbmc.log( "[ script.cinema.experience ] - messy_exit: %s" % exit, level=xbmc.LOGNOTICE )
if exit:
pass
else:
_clear_playlists()
prev_trigger = Launch_automation().launch_automation( triggers[16], None ) # Script End
- _A_.setSetting( id='number_of_features', value='%d' % (number_of_features - 1) )
+ __addon__.setSetting( id='number_of_features', value='%d' % (number_of_features - 1) )
xbmcgui.Window(10025).setProperty( "CinemaExperienceRunning", "False" )
except:
traceback.print_exc()
# if script fails, changes settings back
- _A_.setSetting( id='number_of_features', value='%d' % (number_of_features - 1) )
+ __addon__.setSetting( id='number_of_features', value='%d' % (number_of_features - 1) )
prev_trigger = Launch_automation().launch_automation( triggers[16], None ) # Script End
xbmcgui.Window(10025).setProperty( "CinemaExperienceRunning", "False" )
View
8 addon.xml
@@ -1,9 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<addon id="script.cinema.experience" name="Cinema Experience" version="3.0.0" provider-name="nuka1195-giftie-ackbarr">
+<addon id="script.cinema.experience"
+ name="Cinema Experience"
+ version="3.0.1"
+ provider-name="Giftie - nuka1195">
<requires>
- <import addon="xbmc.python" version="2.1"/>
+ <import addon="xbmc.python" version="2.1.0"/>
</requires>
<extension point="xbmc.python.script" library="addon.py"/>
+ <extension point="xbmc.service" library="service.py" start="login"/>
<extension point="xbmc.addon.metadata">
<platform>all</platform>
<summary>Re-create a full movie theater experience.</summary>
View
41 changelog.txt
@@ -1,3 +1,44 @@
+3.0.1
+- fix - more HTTP-API calls removed(none should be left in functioning code)
+- fix - Local Folder trailer scraper
+- fix - XBMC Library trailer scraper
+ - Matches Genre to the first genre type in movie(if enabled)
+ - accurately matches Rating(MPAA and BBFC only)(if enabled)
+ - accurately matches unwatched Movies(if enabled)
+- fix - trailer downloader
+- improved - reduce the chance of seeing the Movie Library listing(still flashes but much better)
+- change - code re-arrange and partial re-write(improvements in speed and function)
+- add - New starting method available - RunScript(script.cinema.experience,movieid=xxxx) xxxx = database Movie ID($INFO[ListItem.DBID])
+ - this allows the script to be started inside of a skin as such:(taken from Transperency!)
+ <control type="button" id="1112">
+ <posx>1195</posx>
+ <posy>471</posy>
+ <width>48</width>
+ <height>48</height>
+ <label>-</label>
+ <font>-</font>
+ <texturefocus>cinema-focus.png</texturefocus>
+ <texturenofocus>cinema-nofocus.png</texturenofocus>
+ <onleft>11</onleft>
+ <onright>11</onright>
+ <onup>1113</onup>
+ <ondown>50</ondown>
+ <onclick>Dialog.Close(MovieInformation)</onclick>
+ <onclick>RunScript(script.cinema.experience,movieid=$INFO[ListItem.DBID])</onclick>
+ <visible>Container.Content(Movies) + Skin.HasSetting(CinemaScript_MovieInfo)</visible>
+ </control>
+ - starting in this method stops the movie library from jumping to the next item(making a better flow)
+- add - new service script
+ - allows for pause and resume to function off of xbmc.Player instance(keeps Home Automation scripting fast) - there are still times pause and resume fail to trigger though
+ - allows the script to 'override' the default play action when selecting a video in the Movie Library.
+ - What happens is the the script will see that XBMC has added something to the video playlist then stops the player(about 250ms delay)
+ You may see the Full Screen video show up for a split second(or longer) but the video should not play, then the script will take over.
+ - Need to adjust the new setting in Miscellaneous( 'Override Play button' )
+ - May not work for every one
+ - also requires a restart of XBMC
+- change - the home_automation.py scripting has changed(sorry folks, it was needed.) Will post link to new Event Ghost version
+- change - reduced the amount of shuffling videos(used to shuffle 5 times, now only once) - should help randomizing the videos when only a few are available
+
3.0.0
- first Frodo Version.
View
4 resources/ha_scripts/home_automation.py
@@ -31,8 +31,6 @@ def activate_ha( self, trigger = None, prev_trigger = None, mode="thread" ):
else:
thread = Thread( name='ha_trigger', target=self.activate_on, args=( trigger, ) )
thread.start()
- if not trigger in ( "Pause", "Resumed" ):
- prev_trigger = trigger
return prev_trigger
def activate_on( self, trigger = None ):
@@ -126,3 +124,5 @@ def activate_on( self, trigger = None ):
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 )
View
2  resources/language/English/strings.xml
@@ -202,5 +202,5 @@
<string id="32919">Trigger when resumed</string>
<string id="32920">Enable the Home Automation Script</string>
<string id="32921">Must use Trivia Slide Show as well to provide time for script to download trailer(s)</string>
- <string id="32922"> Delay to determine if movie is paused(in 100ms steps, ie 20 = 2000 ms = 2 secs</string>
+ <string id="32922">Override Play button - Very Experimental(may not work for everyone)</string>
</strings>
View
335 resources/lib/ce_player.py
@@ -0,0 +1,335 @@
+import xbmcgui, xbmc, xbmcaddon, xbmcvfs
+import os, re, sys, socket, traceback, time, __builtin__
+from urllib import quote_plus
+from threading import Thread
+
+true = True
+false = False
+null = None
+
+__script__ = sys.modules[ "__main__" ].__script__
+__scriptID__ = sys.modules[ "__main__" ].__scriptID__
+triggers = sys.modules[ "__main__" ].triggers
+trivia_settings = sys.modules[ "__main__" ].trivia_settings
+trailer_settings = sys.modules[ "__main__" ].trailer_settings
+video_settings = sys.modules[ "__main__" ].video_settings
+feature_settings = sys.modules[ "__main__" ].feature_settings
+ha_settings = sys.modules[ "__main__" ].ha_settings
+extra_settings = sys.modules[ "__main__" ].extra_settings
+
+_A_ = xbmcaddon.Addon( __scriptID__ )
+# language method
+_L_ = _A_.getLocalizedString
+
+number_of_features = feature_settings[ "number_of_features" ] + 1
+playback = ""
+BASE_CACHE_PATH = os.path.join( xbmc.translatePath( "special://profile" ).decode('utf-8'), "Thumbnails", "Video" )
+BASE_CURRENT_SOURCE_PATH = os.path.join( xbmc.translatePath( "special://profile/addon_data/" ).decode('utf-8'), os.path.basename( _A_.getAddonInfo('path') ) )
+BASE_RESOURCE_PATH = xbmc.translatePath( os.path.join( _A_.getAddonInfo('path').decode('utf-8'), 'resources' ) )
+sys.path.append( os.path.join( BASE_RESOURCE_PATH, "lib" ) )
+headings = ( _L_(32600), _L_(32601), _L_(32602), _L_(32603), _L_(32604), _L_(32605), _L_(32606), _L_(32607), _L_(32608), _L_(32609), _L_(32610), _L_(32611), _L_(32612) )
+header = "Cinema Experience"
+time_delay = 200
+image = xbmc.translatePath( os.path.join( _A_.getAddonInfo("path"), "icon.png") ).decode('utf-8')
+playlist = xbmc.PlayList( xbmc.PLAYLIST_VIDEO )
+is_paused = False
+prev_trigger = ""
+script_header = "[ %s ]" % __scriptID__
+
+from ce_playlist import _get_special_items, build_music_playlist, _rebuild_playlist
+from slides import _fetch_slides
+from new_trailer_downloader import downloader
+from utils import settings_to_log
+from launch_automation import Launch_automation
+from pre_eden_code import _store_playlist, _get_queued_video_info
+
+class Script():
+ def __init__(self, *args, **kwargs):
+ self. init_var()
+
+ def init_var( self ):
+ self.player = xbmc.Player()
+
+ def start_script( self, library_view = "oldway" ):
+ messy_exit = False
+ xbmc.log( "[ script.cinema.experience ] - Library_view: %s" % library_view, level=xbmc.LOGNOTICE )
+ early_exit = False
+ movie_next = False
+ prev_trigger = None
+ if library_view != "oldway":
+ xbmc.executebuiltin( "ActivateWindow(videolibrary,%s,return)" % library_view )
+ # wait until Video Library shows
+ while not xbmc.getCondVisibility( "Container.Content(movies)" ):
+ pass
+ if feature_settings[ "enable_notification" ]:
+ xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % (header, _L_( 32546 ), 300000, image) )
+ # wait until playlist is full to the required number of features
+ xbmc.log( "[ script.cinema.experience ] - Waiting for queue to be filled with %s Feature films" % number_of_features, level=xbmc.LOGNOTICE )
+ count = 0
+ while playlist.size() < number_of_features:
+ if playlist.size() > count:
+ xbmc.log( "[ script.cinema.experience ] - User queued %s of %s Feature films" % (playlist.size(), number_of_features), level=xbmc.LOGNOTICE )
+ header1 = header + " - Feature " + "%d" % playlist.size()
+ message = _L_( 32543 ) + playlist[playlist.size() -1].getdescription()
+ if feature_settings[ "enable_notification" ]:
+ xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % (header1, message, time_delay, image) )
+ count = playlist.size()
+ xbmc.sleep(time_delay*2)
+ if not xbmc.getCondVisibility( "Container.Content(movies)" ):
+ early_exit = True
+ break
+ xbmc.log( "[ script.cinema.experience ] - User queued %s Feature films" % playlist.size(), level=xbmc.LOGNOTICE )
+ if not early_exit:
+ header1 = header + " - Feature " + "%d" % playlist.size()
+ message = _L_( 32543 ) + playlist[playlist.size() -1].getdescription()
+ if feature_settings[ "enable_notification" ]:
+ xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % (header1, message, time_delay, image) )
+ early_exit = False
+ # If for some reason the limit does not get reached and the window changed, cancel script
+ if playlist.size() < number_of_features and library_view != "oldway":
+ if feature_settings[ "enable_notification" ]:
+ xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % (header, _L_( 32544 ), time_delay, image) )
+ _clear_playlists()
+ else:
+ mpaa, audio, genre, movie, equivalent_mpaa = _get_queued_video_info( feature = 0 )
+ plist = _store_playlist() # need to store movie playlist
+ self._play_trivia( mpaa, genre, plist, equivalent_mpaa )
+ mplaylist = xbmc.PlayList(xbmc.PLAYLIST_MUSIC)
+ mplaylist.clear()
+ trigger_list = self.load_trigger_list()
+ #xbmc.Player().play( playlist )
+ self.player.play( playlist )
+ count = -1
+ stop_check = 0
+ paused = False
+ # prelim programming for adding - Activate script and other additions
+ while not playlist.getposition() == ( playlist.size() - 1 ):
+ if playlist.getposition() > count:
+ try:
+ xbmc.log( "[ script.cinema.experience ] - Item From Trigger List: %s" % trigger_list[ playlist.getposition() ], level=xbmc.LOGNOTICE )
+ except:
+ xbmc.log( "[ script.cinema.experience ] - Problem With Trigger List", level=xbmc.LOGNOTICE )
+ xbmc.log( "[ script.cinema.experience ] - Playlist Position: %s Playlist Size: %s " % ( ( playlist.getposition() + 1 ), ( playlist.size() ) ), level=xbmc.LOGNOTICE )
+ if not playlist.getposition() == ( playlist.size() - 1 ):
+ prev_trigger = Launch_automation().launch_automation( trigger_list[ playlist.getposition() ], prev_trigger )
+ count = playlist.getposition()
+ else:
+ break # Reached the last item in the playlist
+ try:
+ #if not self.player.isPlayingVideo() and not is_paused:
+ if not xbmc.getCondVisibility( "Window.IsActive(fullscreenvideo)" ):
+ xbmc.log( "[ script.cinema.experience ] - Video may have stopped", level=xbmc.LOGNOTICE )
+ messy_exit = True
+ break
+ except:
+ if xbmc.getCondVisibility( "Container.Content(movies)" ):
+ xbmc.log( "[ script.cinema.experience ] - Video Definitely Stopped", level=xbmc.LOGNOTICE )
+ messy_exit = True
+ break
+ if not playlist.size() < 1 and not messy_exit: # To catch an already running script when a new instance started
+ xbmc.log( "[ script.cinema.experience ] - Playlist Position: %s Playlist Size: %s " % ( playlist.getposition() + 1, ( playlist.size() ) ), level=xbmc.LOGNOTICE )
+ prev_trigger = Launch_automation().launch_automation( trigger_list[ playlist.getposition() ], prev_trigger )
+ if trigger_list[ playlist.getposition() ] == "Movie":
+ xbmc.log( "[ script.cinema.experience ] - Item From Trigger List: %s" % trigger_list[ playlist.getposition() ], level=xbmc.LOGNOTICE )
+ else:
+ xbmc.log( "[ script.cinema.experience ] - Item From Trigger List: %s" % trigger_list[ playlist.getposition() ], level=xbmc.LOGNOTICE )
+ messy_exit = False
+ xbmc.sleep(1000)
+ self._wait_until_end()
+ else:
+ xbmc.log( "[ script.cinema.experience ] - User might have pressed stop", level=xbmc.LOGNOTICE )
+ xbmc.log( "[ script.cinema.experience ] - Stopping Script", level=xbmc.LOGNOTICE )
+ messy_exit = False
+ return messy_exit
+
+ def broadcastUDP( self, data, port = 8278 ): # XBMC's former HTTP API output port is 8278
+ IPADDR = '255.255.255.255'
+ PORTNUM = port
+ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0)
+ if hasattr(socket,'SO_BROADCAST'):
+ s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
+ s.connect((IPADDR, PORTNUM))
+ s.send(data)
+ s.close()
+
+ def load_trigger_list( self ):
+ xbmc.log( "[script.cinema.experience] - Loading Trigger List", level=xbmc.LOGNOTICE)
+ try:
+ # set base watched file path
+ base_path = os.path.join( BASE_CURRENT_SOURCE_PATH, "trigger_list.txt" )
+ # open path
+ usock = open( base_path, "r" )
+ # read source
+ trigger_list = eval( usock.read() )
+ # close socket
+ usock.close()
+ except:
+ xbmc.log( "[script.cinema.experience] - Error Loading Trigger List", level=xbmc.LOGNOTICE)
+ traceback.print_exc()
+ trigger_list = []
+ return trigger_list
+
+ def voxcommando():
+ playlistsize = playlist.size()
+ if playlistsize > 1:
+ movie_titles = ""
+ #for feature_count in range (1, playlistsize + 1):
+ for feature_count in range (1, playlistsize):
+ movie_title = playlist[ feature_count - 1 ].getdescription()
+ xbmc.log( "[ script.cinema.experience ] - Feature #%-2d - %s" % ( feature_count, movie_title ), level=xbmc.LOGNOTICE )
+ movie_titles = movie_titles + movie_title + "<li>"
+ movie_titles = movie_titles.rstrip("<li>")
+ if extra_settings[ "voxcommando" ]:
+ self.broadcastUDP( "<b>CElaunch." + str( playlistsize ) + "<li>" + movie_titles + "</b>", port = 33000 )
+ else:
+ # get the queued video info
+ movie_title = playlist[ 0 ].getdescription()
+ xbmc.log( "[ script.cinema.experience ] - Feature - %s" % movie_title, level=xbmc.LOGNOTICE )
+ if extra_settings[ "voxcommando" ]:
+ self.broadcastUDP( "<b>CElaunch<li>" + movie_title + "</b>", port = 33000 )
+
+ # No longer works in Frodo to be removed
+ def _sqlquery( self, sqlquery ):
+ movie_list = []
+ movies = []
+ xbmc.executehttpapi( "SetResponseFormat()" )
+ xbmc.executehttpapi( "SetResponseFormat(OpenField,)" )
+ sqlquery = "SELECT movieview.c00 FROM movieview JOIN genrelinkmovie ON genrelinkmovie.idMovie=movieview.idMovie JOIN genre ON genrelinkmovie.idGenre=genre.idGenre WHERE strGenre='Action' ORDER BY RANDOM() LIMIT 4"
+ xbmc.log( "[ script.cinema.experience ] - SQL: %s" % ( sqlquery, ), level=xbmc.LOGDEBUG )
+ try:
+ sqlresult = xbmc.executehttpapi( "QueryVideoDatabase(%s)" % quote_plus( sqlquery ), )
+ xbmc.log( "[ script.cinema.experience ] - sqlresult: %s" % sqlresult, level=xbmc.LOGDEBUG )
+ movies = sqlresult.split("</field>")
+ movie_list = movies[ 0:len( movies ) -1 ]
+ except:
+ xbmc.log( "[ script.cinema.experience ] - Error searching database", level=xbmc.LOGNOTICE )
+ return movie_list
+
+ def trivia_intro( self ):
+ xbmc.log( "[ script.cinema.experience ] - ## Intro ##", level=xbmc.LOGNOTICE)
+ play_list = playlist
+ play_list.clear()
+ # initialize intro lists
+ playlist_intro = []
+ # get trivia intro videos
+ _get_special_items( playlist=play_list,
+ items=video_settings[ "trivia_intro" ],
+ path=( video_settings[ "trivia_intro_file" ], video_settings[ "trivia_intro_folder" ], )[ video_settings[ "trivia_intro_type" ] == "folder" ],
+ genre= "Trivia Intro",
+ index=0,
+ media_type="video"
+ )
+ if not video_settings[ "trivia_intro" ] == 0:
+ self.player.play( play_list )
+
+ def start_downloader( self, mpaa, genre, equivalent_mpaa ):
+ # start the downloader if Play Mode is set to stream and if scraper is not Local or XBMC_library
+ if ( trailer_settings[ "trailer_play_mode" ] ) == 1 and not ( trailer_settings[ "trailer_scraper" ] in (2, 3) ):
+ xbmc.log( "[ script.cinema.experience ] - Starting Downloader Thread", level=xbmc.LOGNOTICE )
+ thread = Thread( target=downloader, args=( mpaa, genre, equivalent_mpaa ) )
+ thread.start()
+ else:
+ pass
+
+ def _wait_until_end( self ): # wait until the end of the playlist(for Trivia Intro)
+ xbmc.log( "[ script.cinema.experience ] - Waiting Until End Of Video", level=xbmc.LOGNOTICE)
+ try:
+ self.psize = int( xbmc.PlayList( xbmc.PLAYLIST_VIDEO ).size() ) - 1
+ xbmc.log( "[ script.cinema.experience ] - Playlist Size: %s" % ( self.psize + 1 ), level=xbmc.LOGDEBUG)
+ while xbmc.PlayList( xbmc.PLAYLIST_VIDEO ).getposition() < self.psize:
+ pass
+ xbmc.log( "[ script.cinema.experience ] - Video TotalTime: %s" % self.player.getTotalTime(), level=xbmc.LOGDEBUG)
+ while self.player.getTime() < ( self.player.getTotalTime() - 1 ):
+ pass
+ xbmc.log( "[ script.cinema.experience ] - Video getTime: %s" % self.player.getTime(), level=xbmc.LOGDEBUG)
+ #xbmc.sleep(400)
+ except:
+ traceback.print_exc()
+ xbmc.log( "[ script.cinema.experience ] - Video either stopped or skipped, Continuing on...", level=xbmc.LOGDEBUG)
+
+ def _play_trivia( self, mpaa, genre, plist, equivalent_mpaa ):
+ Launch_automation().launch_automation( triggers[0] ) # Script Start - Or where it seems to be
+ if trivia_settings[ "trivia_mode" ] == 2: # Start Movie Quiz Script
+ xbmc.log( "[ script.cinema.experience ] - Starting script.moviequiz", level=xbmc.LOGNOTICE )
+ self.start_downloader( mpaa, genre, equivalent_mpaa )
+ try:
+ _MA_= xbmcaddon.Addon( "script.moviequiz" )
+ BASE_MOVIEQUIZ_PATH = xbmc.translatePath( _MA_.getAddonInfo('path') )
+ sys.path.append( BASE_MOVIEQUIZ_PATH )
+ try:
+ import quizlib.question as question
+ xbmc.log( "[ script.cinema.experience ] - Loaded question module", level=xbmc.LOGNOTICE )
+ except ImportError:
+ traceback.print_exc()
+ xbmc.log( "[ script.cinema.experience ] - Failed to Load question module", level=xbmc.LOGNOTICE )
+ except:
+ traceback.print_exc()
+ try:
+ import quizlib.mq_ce_play as moviequiz
+ xbmc.log( "[ script.cinema.experience ] - Loaded mq_ce_play module", level=xbmc.LOGNOTICE )
+ except ImportError:
+ traceback.print_exc()
+ xbmc.log( "[ script.cinema.experience ] - Failed to Load mq_ce_play module", level=xbmc.LOGNOTICE )
+ except:
+ traceback.print_exc()
+ # pDialog.close()
+ self.trivia_intro()
+ if playlist.size() > 0:
+ self._wait_until_end()
+ xbmc.sleep(500) # wait .5 seconds
+ path = _MA_.getAddonInfo('path')
+ question_type = 1
+ mode = ( True, False )[ trivia_settings[ "trivia_moviequiz_mode" ] ]
+ mpaa = ( trivia_settings[ "trivia_rating" ], equivalent_mpaa, )[ trivia_settings[ "trivia_limit_query" ] ]
+ question_limit = trivia_settings[ "trivia_moviequiz_qlimit" ]
+ completion = moviequiz.runCinemaExperience( question_type, mode, mpaa, genre, question_limit )
+ if completion:
+ xbmc.log( "[ script.cinema.experience ] - Completed script.moviequiz", level=xbmc.LOGNOTICE )
+ else:
+ xbmc.log( "[ script.cinema.experience ] - Failed in script.moviequiz", level=xbmc.LOGNOTICE )
+ except:
+ traceback.print_exc()
+ xbmc.log( "[ script.cinema.experience ] - Failed to start script.moviequiz", level=xbmc.LOGNOTICE )
+ _rebuild_playlist( plist )
+ import xbmcscript_player as script
+ script.Main()
+ #xbmc.sleep(500) # wait .5 seconds
+ #xbmc.Player().play( playlist )
+ elif trivia_settings[ "trivia_folder" ] and trivia_settings[ "trivia_mode" ] == 1: # Start Slide Show
+ self.start_downloader( mpaa, genre, equivalent_mpaa )
+ if not trivia_settings[ "trivia_music" ] == 0:
+ build_music_playlist()
+ # set the proper mpaa rating user preference
+ mpaa = ( trivia_settings[ "trivia_rating" ], equivalent_mpaa, )[ trivia_settings[ "trivia_limit_query" ] ]
+ xbmc.log( "[ script.cinema.experience ] - Slide MPAA Rating: %s" % equivalent_mpaa, level=xbmc.LOGNOTICE )
+ # import trivia module and execute the gui
+ slide_playlist = _fetch_slides( equivalent_mpaa )
+ self.trivia_intro()
+ if playlist.size() > 0:
+ Launch_automation().launch_automation( triggers[1] ) # Trivia Intro
+ xbmc.sleep(500) # wait .5 seconds
+ self._wait_until_end()
+ #xbmc.sleep(500) # wait .5 seconds
+ __builtin__.plist = plist
+ __builtin__.slide_playlist = slide_playlist
+ __builtin__.movie_mpaa = mpaa
+ __builtin__.movie_genre = genre
+ from xbmcscript_trivia import Trivia
+ xbmc.log( "[ script.cinema.experience ] - Starting Trivia script", level=xbmc.LOGNOTICE )
+ Launch_automation().launch_automation( triggers[2] ) # Trivia Start
+ ui = Trivia( "script-CExperience-trivia.xml", _A_.getAddonInfo('path'), "default", "720p" )
+ ui.doModal()
+ del ui
+ # we need to activate the video window
+ #xbmc.sleep(5) # wait .005 seconds
+ xbmc.executebuiltin( "XBMC.ActivateWindow(2005)" )
+ #xbmc.Player().play( playlist )
+ elif trivia_settings[ "trivia_mode" ] == 0: # No Trivia
+ # no trivia slide show so play the video
+ self.start_downloader( mpaa, genre, equivalent_mpaa )
+ _rebuild_playlist( plist )
+ # play the video playlist
+ import xbmcscript_player as script
+ script.Main()
+ xbmc.sleep(500) # wait .5 seconds
+ #xbmc.Player().play( playlist )
View
2  resources/lib/ce_playlist.py
@@ -43,8 +43,6 @@ def _get_trailers( items, equivalent_mpaa, mpaa, genre, movie, mode = "download"
settings[ "trailer_scraper" ] = "local"
settings[ "trailer_folder" ] = settings[ "trailer_download_folder" ]
# get the correct scraper
- print settings[ "trailer_scraper" ]
- print settings[ "trailer_play_mode" ]
sys.path.append( os.path.join( BASE_RESOURCE_PATH, "lib", "scrapers" ) )
exec "from %s import scraper as scraper" % ( settings[ "trailer_scraper" ], )
Scraper = scraper.Main( equivalent_mpaa, mpaa, genre, settings, movie )
View
31 resources/lib/launch_automation.py
@@ -0,0 +1,31 @@
+import xbmc, xbmcaddon
+import sys, os, traceback
+
+__scriptID__ = sys.modules[ "__main__" ].__scriptID__
+ha_settings = sys.modules[ "__main__" ].ha_settings
+
+_A_ = xbmcaddon.Addon( __scriptID__ )
+BASE_CURRENT_SOURCE_PATH = os.path.join( xbmc.translatePath( "special://profile/addon_data/" ).decode('utf-8'), os.path.basename( _A_.getAddonInfo('path') ) )
+
+try:
+ sys.path.append( os.path.join( BASE_CURRENT_SOURCE_PATH, "ha_scripts" ) )
+ from home_automation import Automate
+ # Import HA module set ha_imported to True if successful
+ ha_imported = True
+except ImportError:
+ # or ha_imported to False if unsuccessful
+ xbmc.log( "[ script.cinema.experience ] - Failed to import Automate", level=xbmc.LOGNOTICE )
+ ha_imported = False
+except:
+ traceback.print_exc()
+ ha_imported = False
+
+class Launch_automation():
+ def __init__(self, *args, **kwargs):
+ pass
+
+ def launch_automation( self, trigger = None, prev_trigger = None, mode="normal" ):
+ if ha_settings[ "ha_enable" ]:
+ prev_trigger = Automate().activate_ha( trigger, prev_trigger, mode )
+ return prev_trigger
+
View
73 resources/lib/utils.py
@@ -5,6 +5,9 @@
import re, os, sys, traceback
import xbmc
+__scriptname__ = sys.modules[ "__main__" ].__addonname__
+__scriptID__ = sys.modules[ "__main__" ].__scriptID__
+
def list_to_string( item ):
list_to_string = ""
if not ( type( item ) is list ):
@@ -16,20 +19,74 @@ def list_to_string( item ):
list_to_string = "".join( item )
return list_to_string
+def smart_unicode(s):
+ """credit : sfaxman"""
+ if not s:
+ return ''
+ try:
+ if not isinstance(s, basestring):
+ if hasattr(s, '__unicode__'):
+ s = unicode(s)
+ else:
+ s = unicode(str(s), 'UTF-8')
+ elif not isinstance(s, unicode):
+ s = unicode(s, 'UTF-8')
+ except:
+ if not isinstance(s, basestring):
+ if hasattr(s, '__unicode__'):
+ s = unicode(s)
+ else:
+ s = unicode(str(s), 'ISO-8859-1')
+ elif not isinstance(s, unicode):
+ s = unicode(s, 'ISO-8859-1')
+ return s
+
+def smart_utf8(s):
+ return smart_unicode(s).encode('utf-8')
+
+def unescape(text):
+ def fixup(m):
+ text = m.group(0)
+ if text[:2] == "&#":
+ # character reference
+ try:
+ if text[:3] == "&#x":
+ return unichr(int(text[3:-1], 16))
+ else:
+ return unichr(int(text[2:-1]))
+ except ValueError:
+ pass
+ else:
+ # named entity
+ try:
+ text = unichr(htmlentitydefs.name2codepoint[text[1:-1]])
+ except KeyError:
+ pass
+ return text # leave as is
+ return re.sub("&#?\w+;", fixup, text)
+
def settings_to_log( settings_path, script_heading="[utils.py]" ):
try:
- xbmc.log( "%s - Settings\n" % script_heading, level=xbmc.LOGDEBUG)
+ log( "Settings\n", xbmc.LOGDEBUG)
# set base watched file path
base_path = os.path.join( settings_path, "settings.xml" )
# open path
- usock = open( base_path, "r" )
- u_read = usock.read()
- settings_list = u_read.replace("<settings>\n","").replace("</settings>\n","").split("/>\n")
+ settings_file = open( base_path, "r" )
+ settings_file_read = settings_file.read()
+ settings_list = settings_file_read.replace("<settings>\n","").replace("</settings>\n","").split("/>\n")
# close socket
- usock.close()
- for set in settings_list:
- match = re.search(' <setting id="(.*?)" value="(.*?)"', set)
+ settings_file.close()
+ for setting in settings_list:
+ match = re.search(' <setting id="(.*?)" value="(.*?)"', setting)
+ if not match:
+ match = re.search(""" <setting id="(.*?)" value='(.*?)'""", setting)
if match:
- xbmc.log( "%s - %30s: %s" % ( script_heading, match.group(1), match.group(2) ), level=xbmc.LOGDEBUG)
+ log( "%30s: %s" % ( match.group(1), str( unescape( match.group(2).decode('utf-8', 'ignore') ) ) ), xbmc.LOGDEBUG )
except:
traceback.print_exc()
+
+def log( text, severity=xbmc.LOGDEBUG ):
+ if type( text).__name__=='unicode':
+ text = text.encode('utf-8')
+ message = ('[%s] - %s' % ( __scriptname__ ,text.__str__() ) )
+ xbmc.log( msg=message, level=severity)
View
2  resources/lib/xbmcscript_trivia.py
@@ -23,12 +23,12 @@
trailer_settings = sys.modules["__main__"].trailer_settings
feature_settings = sys.modules["__main__"].feature_settings
video_settings = sys.modules["__main__"].video_settings
-CEPlayer = xbmc.Player
BASE_RESOURCE_PATH = os.path.join( xbmc.translatePath( _A_.getAddonInfo('path') ), 'resources' )
sys.path.append( os.path.join( BASE_RESOURCE_PATH, "lib" ) )
from music import parse_playlist
from ce_playlist import build_music_playlist
+CEPlayer = xbmc.Player
from pre_eden_code import _rebuild_playlist
from xbmcvfs import delete as delete_file
View
8 resources/settings.xml
@@ -121,16 +121,16 @@
<setting type="sep" />
<setting id="ha_paused" type="bool" label="32918" visible="eq(-20,true)" default="false" />
<setting id="ha_resumed" type="bool" label="32919" visible="eq(-21,true)" default="false" />
- <setting id="ha_pause_time" type="slider" label="32922" visible="eq(-22,true)" enable="eq(-2,true)" option="int" range="0,30" default="20"/>
</category>
<!-- Misc. Settings _-->
-<!--
<category label="32804">
<setting type="lsep" label="32804" />
- <setting id="autorefresh" type="bool" enable="false" label="32401" default="false" />
+<!-- <setting id="autorefresh" type="bool" enable="false" label="32401" default="false" />
<setting id="autorefresh_movie" type="bool" enable="false" visible="eq(-1,true)" enable="eq(-1,true)" label="32402" default="false" />
- <setting id="voxcommando" type="bool" enable="false" label="32403" default="false" />
+-->
+ <setting id="voxcommando" type="bool" label="32403" default="false" />
+ <setting id="override_play" type="bool" label="32922" default="false" />
</category>
-->
</settings>
View
146 service.py
@@ -0,0 +1,146 @@
+import xbmc, xbmcaddon, xbmcgui
+import os, sys
+
+__addon__ = xbmcaddon.Addon()
+__addonversion__ = __addon__.getAddonInfo('version')
+__addonid__ = __addon__.getAddonInfo('id')
+__addonname__ = __addon__.getAddonInfo('name')
+__setting__ = __addon__.getSetting
+__scriptID__ = __addonid__
+
+BASE_RESOURCE_PATH = xbmc.translatePath( os.path.join( __addon__.getAddonInfo('path').decode('utf-8'), 'resources' ) )
+sys.path.append( os.path.join( BASE_RESOURCE_PATH, "lib" ) )
+true = True
+false = False
+null = None
+
+triggers = ( "Script Start", "Trivia Intro", "Trivia", "Trivia Outro", "Coming Attractions Intro", "Movie Trailer",
+ "Coming Attractions Outro", "Movie Theater Intro", "Countdown", "Feature Presentation Intro", "Audio Format",
+ "MPAA Rating", "Movie", "Feature Presentation Outro", "Movie Theatre Outro", "Intermission", "Script End", "Pause", "Resume" )
+
+override_play = eval( __setting__( "override_play" ) )
+
+ha_settings = { "ha_enable": eval( __setting__( "ha_enable" ) ),
+ "ha_multi_trigger": eval( __setting__( "ha_multi_trigger" ) ),
+ "ha_script_start": eval( __setting__( "ha_script_start" ) ),
+ "ha_trivia_intro": eval( __setting__( "ha_trivia_intro" ) ),
+ "ha_trivia_start": eval( __setting__( "ha_trivia_start" ) ),
+ "ha_trivia_outro": eval( __setting__( "ha_trivia_outro" ) ),
+ "ha_mte_intro": eval( __setting__( "ha_mte_intro" ) ),
+ "ha_cav_intro": eval( __setting__( "ha_cav_intro" ) ),
+ "ha_trailer_start": eval( __setting__( "ha_trailer_start" ) ),
+ "ha_cav_outro": eval( __setting__( "ha_cav_outro" ) ),
+ "ha_fpv_intro": eval( __setting__( "ha_fpv_intro" ) ),
+ "ha_mpaa_rating": eval( __setting__( "ha_mpaa_rating" ) ),
+ "ha_countdown_video": eval( __setting__( "ha_countdown_video" ) ),
+ "ha_audio_format": eval( __setting__( "ha_audio_format" ) ),
+ "ha_movie": eval( __setting__( "ha_movie" ) ),
+ "ha_fpv_outro": eval( __setting__( "ha_fpv_outro" ) ),
+ "ha_mte_outro": eval( __setting__( "ha_mte_outro" ) ),
+ "ha_intermission": eval( __setting__( "ha_intermission" ) ),
+ "ha_script_end": eval( __setting__( "ha_script_end" ) ),
+ "ha_paused": eval( __setting__( "ha_paused" ) ),
+ "ha_resumed": eval( __setting__( "ha_resumed" ) )
+ }
+
+from launch_automation import Launch_automation
+from utils import log
+
+class CE_Monitor( xbmc.Monitor ):
+ def __init__(self, *args, **kwargs):
+ xbmc.Monitor.__init__(self)
+ self.enabled = kwargs['enabled']
+ self.update_settings = kwargs['update_settings']
+
+ def onSettingsChanged( self ):
+ self.update_settings()
+
+class CE_Player( xbmc.Player ):
+ def __init__(self, *args, **kwargs):
+ xbmc.Player.__init__( self )
+ self.enabled = kwargs['enabled']
+
+ def onPlayBackStarted( self ):
+ xbmc.sleep( 1000 )
+ if xbmcgui.Window(10025).getProperty( "CinemaExperienceRunning" ) == "True":
+ log( 'Playback Started' )
+
+ def onPlayBackEnded( self ):
+ # Will be called when xbmc stops playing a file
+ if xbmcgui.Window(10025).getProperty( "CinemaExperienceRunning" ) == "True":
+ log( "Playback Ended" )
+
+ def onPlayBackStopped( self ):
+ # Will be called when user stops xbmc playing a file
+ if xbmcgui.Window(10025).getProperty( "CinemaExperienceRunning" ) == "True":
+ log( "Playback Stopped" )
+
+ def onPlayBackPaused( self ):
+ if xbmcgui.Window(10025).getProperty( "CinemaExperienceRunning" ) == "True":
+ log( 'Playback Paused' )
+ if ha_settings[ "ha_enable" ]:
+ Launch_automation().launch_automation( trigger = "Pause", prev_trigger = "Playing", mode = "normal" )
+
+ def onPlayBackResumed( self ):
+ if xbmcgui.Window(10025).getProperty( "CinemaExperienceRunning" ) == "True":
+ log( 'Playback Resumed' )
+ if ha_settings[ "ha_enable" ]:
+ Launch_automation().launch_automation( trigger = "Resume", prev_trigger = "Paused", mode = "normal" )
+
+class Main():
+ def __init__(self):
+ self._init_vars()
+ self.update_settings
+ self._daemon()
+
+ def _init_vars(self):
+ self.Player = CE_Player( enabled = True )
+ self.Monitor = CE_Monitor( enabled = True, update_settings = self.update_settings )
+
+ def update_settings( self ):
+ log( "service.py - Settings loaded" )
+ self.override_play = eval( __setting__( "override_play" ) )
+ self.ha_settings = { "ha_enable": eval( __setting__( "ha_enable" ) ),
+ "ha_multi_trigger": eval( __setting__( "ha_multi_trigger" ) ),
+ "ha_script_start": eval( __setting__( "ha_script_start" ) ),
+ "ha_trivia_intro": eval( __setting__( "ha_trivia_intro" ) ),
+ "ha_trivia_start": eval( __setting__( "ha_trivia_start" ) ),
+ "ha_trivia_outro": eval( __setting__( "ha_trivia_outro" ) ),
+ "ha_mte_intro": eval( __setting__( "ha_mte_intro" ) ),
+ "ha_cav_intro": eval( __setting__( "ha_cav_intro" ) ),
+ "ha_trailer_start": eval( __setting__( "ha_trailer_start" ) ),
+ "ha_cav_outro": eval( __setting__( "ha_cav_outro" ) ),
+ "ha_fpv_intro": eval( __setting__( "ha_fpv_intro" ) ),
+ "ha_mpaa_rating": eval( __setting__( "ha_mpaa_rating" ) ),
+ "ha_countdown_video": eval( __setting__( "ha_countdown_video" ) ),
+ "ha_audio_format": eval( __setting__( "ha_audio_format" ) ),
+ "ha_movie": eval( __setting__( "ha_movie" ) ),
+ "ha_fpv_outro": eval( __setting__( "ha_fpv_outro" ) ),
+ "ha_mte_outro": eval( __setting__( "ha_mte_outro" ) ),
+ "ha_intermission": eval( __setting__( "ha_intermission" ) ),
+ "ha_script_end": eval( __setting__( "ha_script_end" ) ),
+ "ha_paused": eval( __setting__( "ha_paused" ) ),
+ "ha_resumed": eval( __setting__( "ha_resumed" ) )
+ }
+ override_play = self.override_play
+ ha_settings = self.ha_settings
+
+ def _daemon( self ):
+ while (not xbmc.abortRequested):
+ if not xbmc.getCondVisibility('VideoPlayer.Content(movies)'):
+ xbmc.sleep( 250 )
+ else:
+ if int( xbmc.PlayList( xbmc.PLAYLIST_VIDEO ).size() ) > 0 and xbmc.getCondVisibility('VideoPlayer.Content(movies)') and override_play and not xbmcgui.Window(10025).getProperty( "CinemaExperienceRunning" ) == "True":
+ #xbmc.sleep( 100 )
+ xbmc.Player().stop()
+ xbmc.executebuiltin( "RunScript(script.cinema.experience,fromplay)" )
+ else:
+ xbmc.sleep( 250 )
+
+if (__name__ == "__main__"):
+ log('Cinema Experience service script version %s started' % __addonversion__)
+ Main()
+ del CE_Player
+ del CE_Monitor
+ del Main
+ log('Cinema Experience service script version %s stopped' % __addonversion__)
Please sign in to comment.
Something went wrong with that request. Please try again.