Permalink
Browse files

3.0.4

  • Loading branch information...
1 parent 22ba643 commit 510830bfcd927d2447601ab316e52ad20f1928ce @Giftie committed Feb 22, 2013
View
@@ -152,12 +152,11 @@
prev_trigger = ""
script_header = "[ %s ]" % __scriptID__
-from ce_playlist import _get_special_items, build_music_playlist, _rebuild_playlist
+from ce_playlist import _get_special_items, build_music_playlist, _rebuild_playlist, _store_playlist, _get_queued_video_info
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
if not xbmcvfs.exists( os.path.join( BASE_CURRENT_SOURCE_PATH, "ha_scripts", "home_automation.py" ) ) and ha_settings[ "ha_enable" ]:
View
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.cinema.experience"
name="Cinema Experience"
- version="3.0.3"
+ version="3.0.4"
provider-name="Giftie - nuka1195">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
View
@@ -1,12 +1,17 @@
+3.0.4
+- fix - setting error for a single music file during trivia
+- change - code clean up
+- add - FSK Ratings added, along with converting to near MPAA rating
+
3.0.3
-- fix - Coming Attraction Intro Videos
-- fix - removed code that could cause the music library to flash after trivia
-- add - give user the ability to diable YouTube(or any plug-in required) Trailers
-- fix - stop downloader from trying to download local trailers
+- fix - Coming Attraction Intro Videos
+- fix - removed code that could cause the music library to flash after trivia
+- add - give user the ability to diable YouTube(or any plug-in required) Trailers
+- fix - stop downloader from trying to download local trailers
3.0.2
-- fix - make sure home_automation.py is moved in service.py if it does not exist
-- fix - have script wait until full screen video is playing before detecting a stop, should fix when XBMC is slow to start
+- fix - make sure home_automation.py is moved in service.py if it does not exist
+- fix - have script wait until full screen video is playing before detecting a stop, should fix when XBMC is slow to start
3.0.1
- fix - more HTTP-API calls removed(none should be left in functioning code)
View
@@ -7,41 +7,39 @@
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__ )
+__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
+BASE_CACHE_PATH = sys.modules["__main__"].BASE_CACHE_PATH
+BASE_RESOURCE_PATH = sys.modules["__main__"].BASE_RESOURCE_PATH
+BASE_CURRENT_SOURCE_PATH = sys.modules["__main__"].BASE_CURRENT_SOURCE_PATH
+__addon__ = xbmcaddon.Addon( __scriptID__ )
# language method
-_L_ = _A_.getLocalizedString
+__language__ = __addon__.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) )
+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 = ""
script_header = "[ %s ]" % __scriptID__
-from ce_playlist import _get_special_items, build_music_playlist, _rebuild_playlist
+from ce_playlist import _get_special_items, build_music_playlist, _rebuild_playlist, _store_playlist, _get_queued_video_info
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):
@@ -62,15 +60,15 @@ def start_script( self, library_view = "oldway" ):
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) )
+ xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % (header, __language__( 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()
+ message = __language__( 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()
@@ -81,14 +79,14 @@ def start_script( self, library_view = "oldway" ):
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()
+ message = __language__( 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) )
+ xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % (header, __language__( 32544 ), time_delay, image) )
_clear_playlists()
else:
mpaa, audio, genre, movie, equivalent_mpaa = _get_queued_video_info( feature = 0 )
@@ -321,7 +319,7 @@ def _play_trivia( self, mpaa, genre, plist, equivalent_mpaa ):
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 = Trivia( "script-CExperience-trivia.xml", __addon__.getAddonInfo('path'), "default", "720p" )
ui.doModal()
del ui
# we need to activate the video window
@@ -1,38 +1,32 @@
# -*- coding: utf-8 -*-
+import traceback, os, re, sys
+from urllib import quote_plus
+from random import shuffle, random
__script__ = "Cinema Experience"
__scriptID__ = "script.cinema.experience"
__modname__ = "ce_playlist.py"
-import traceback, os, re, sys
import xbmc, xbmcaddon, xbmcgui
-from urllib import quote_plus
-from random import shuffle, random
log_message = "[ " + __scriptID__ + " ] - [ " + __modname__ + " ]"
-_A_ = xbmcaddon.Addon( __scriptID__ )
-# language method
-_L_ = _A_.getLocalizedString
-
-trivia_settings = sys.modules["__main__"].trivia_settings
-trailer_settings = sys.modules["__main__"].trailer_settings
-feature_settings = sys.modules["__main__"].feature_settings
-video_settings = sys.modules["__main__"].video_settings
-
+log_sep = "-"*70
-#tmp_paths = []
-BASE_CACHE_PATH = os.path.join( xbmc.translatePath( "special://profile" ), "Thumbnails", "Video" )
-BASE_RESOURCE_PATH = xbmc.translatePath( os.path.join( _A_.getAddonInfo('path'), 'resources' ) )
+trivia_settings = sys.modules[ "__main__" ].trivia_settings
+trailer_settings = sys.modules[ "__main__" ].trailer_settings
+feature_settings = sys.modules[ "__main__" ].feature_settings
+video_settings = sys.modules[ "__main__" ].video_settings
+BASE_CACHE_PATH = sys.modules[ "__main__" ].BASE_CACHE_PATH
+BASE_RESOURCE_PATH = sys.modules[ "__main__" ].BASE_RESOURCE_PATH
+BASE_CURRENT_SOURCE_PATH = sys.modules[ "__main__" ].BASE_CURRENT_SOURCE_PATH
sys.path.append( os.path.join( BASE_RESOURCE_PATH, "lib" ) )
from music import parse_playlist
-
-from pre_eden_code import _rebuild_playlist
+from json_utils import find_movie_details, retrieve_json_dict
+from utils import list_to_string
from xbmcvfs import exists as exists
from folder import dirEntries
-log_sep = "-"*70
-
def _get_trailers( items, equivalent_mpaa, mpaa, genre, movie, mode = "download" ):
xbmc.log( "[script.cinema.experience] - [ce_playlist.py] - _get_trailers started", level=xbmc.LOGDEBUG )
# return if not user preference
@@ -264,7 +258,7 @@ def build_music_playlist():
track_info, track_location = parse_playlist( saved_playlist, xbmc.getSupportedMedia('music') )
elif os.path.splitext( trivia_settings[ "trivia_music_file" ] )[1] in xbmc.getSupportedMedia('music'):
for track in range(100):
- track_location.append( trivia[ "trivia_music_file" ] )
+ track_location.append( trivia_settings[ "trivia_music_file" ] )
# otherwise
else:
if trivia_settings[ "trivia_music_folder" ]:
@@ -274,3 +268,104 @@ def build_music_playlist():
shuffle( track_location )
for track in track_location:
music_playlist.add( track, )
+
+def get_equivalent_rating( rating ):
+ if rating == "":
+ rating = "NR"
+ #MPAA
+ elif rating.startswith("Rated"):
+ rating = rating.split( " " )[ 1 - ( len( rating.split( " " ) ) == 1 ) ]
+ rating = ( rating, "NR", )[ rating not in ( "G", "PG", "PG-13", "R", "NC-17", "Unrated", ) ]
+ #BBFC
+ elif rating.startswith("UK"):
+ if rating.startswith( "UK:" ):
+ rating = rating.split( ":" )[ 1 - ( len( rating.split( ":" ) ) == 1 ) ]
+ else:
+ rating = rating.split( " " )[ 1 - ( len( rating.split( " " ) ) == 1 ) ]
+ rating = ( rating, "NR", )[ rating not in ( "12", "12A", "PG", "15", "18", "R18", "MA", "U", ) ]
+ elif rating.startswith("FSK"):
+ if rating.startswith( "FSK:" ):
+ rating = rating.split( ":" )[ 1 - ( len( rating.split( ":" ) ) == 1 ) ]
+ else:
+ rating = rating.split( " " )[ 1 - ( len( rating.split( " " ) ) == 1 ) ]
+ else:
+ rating = ( rating, "NR", )[ rating not in ( "0", "6", "12", "12A", "PG", "15", "16", "18", "R18", "MA", "U", ) ]
+ if rating not in ( "G", "PG", "PG-13", "R", "NC-17", "Unrated", "NR" ):
+ if rating in ("12", "12A",):
+ equivalent_mpaa = "PG-13"
+ elif rating in ( "15", "16" ):
+ equivalent_mpaa = "R"
+ elif rating in ( "0", "U" ):
+ equivalent_mpaa = "G"
+ elif rating in ( "6", ):
+ equivalent_mpaa = "PG"
+ elif rating in ("18", "R18", "MA",):
+ equivalent_mpaa = "NC-17"
+ else:
+ equivalent_mpaa = rating
+ return equivalent_mpaa, rating
+
+# moved from pre_eden_code
+def _store_playlist():
+ p_list = []
+ xbmc.log( "[script.cinema.experience] - Storing Playlist in memory", level=xbmc.LOGNOTICE )
+ json_query = '{"jsonrpc": "2.0", "method": "Playlist.GetItems", "params": {"playlistid": 1, "properties": ["title", "file", "thumbnail", "streamdetails", "mpaa", "genre"] }, "id": 1}'
+ p_list = retrieve_json_dict( json_query, items="items", force_log=False )
+ return p_list
+
+def _movie_details( movie_id ):
+ movie_details = []
+ xbmc.log( "[script.cinema.experience] - Retrieving Movie Details", level=xbmc.LOGNOTICE )
+ json_query = '{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovieDetails", "params": {"movieid": %d, "properties": ["title", "file", "thumbnail", "streamdetails", "mpaa", "genre"]}, "id": 1}' % movie_id
+ movie_details = retrieve_json_dict( json_query, items="moviedetails", force_log=False )
+ return movie_details
+
+def _rebuild_playlist( plist ): # rebuild movie playlist
+ xbmc.log( "[script.cinema.experience] - [ce_playlist.py] - Rebuilding Playlist", level=xbmc.LOGNOTICE )
+ playlist = xbmc.PlayList( xbmc.PLAYLIST_VIDEO )
+ playlist.clear()
+ for movie in plist:
+ try:
+ xbmc.log( "[script.cinema.experience] - Movie Title: %s" % movie["title"], level=xbmc.LOGDEBUG )
+ xbmc.log( "[script.cinema.experience] - Movie Thumbnail: %s" % movie["thumbnail"], level=xbmc.LOGDEBUG )
+ xbmc.log( "[script.cinema.experience] - Full Movie Path: %s" % movie["file"], level=xbmc.LOGDEBUG )
+ json_command = '{"jsonrpc": "2.0", "method": "Playlist.Add", "params": {"playlistid": 1, "item": {"movieid": %d} }, "id": 1}' % movie["id"]
+ json_response = xbmc.executeJSONRPC(json_command)
+ xbmc.log( "[script.cinema.experience] - JSONRPC Response: \n%s" % movie["title"], level=xbmc.LOGDEBUG )
+ except:
+ traceback.print_exc()
+ # give XBMC a chance to add to the playlist... May not be needed, but what's 50ms?
+ xbmc.sleep( 50 )
+
+def _get_queued_video_info( feature = 0 ):
+ xbmc.log( "%s - _get_queued_video_info() Started" % log_message, level=xbmc.LOGDEBUG )
+ equivalent_mpaa = "NR"
+ try:
+ # get movie name
+ plist = _store_playlist()
+ movie_detail = _movie_details( plist[feature]['id'] )
+ movie_title = movie_detail['title']
+ path = movie_detail['file']
+ mpaa = movie_detail['mpaa']
+ genre = list_to_string( movie_detail['genre'] )
+ try:
+ audio = movie_detail['streamdetails']['audio'][0]['codec']
+ except:
+ audio = "other"
+ equivalent_mpaa, short_mpaa = get_equivalent_rating( mpaa )
+ except:
+ traceback.print_exc()
+ movie_title = path = mpaa = audio = genre = movie = equivalent_mpaa, short_mpaa = ""
+ # spew queued video info to log
+ xbmc.log( "%s - Queued Movie Information" % log_message, level=xbmc.LOGDEBUG )
+ xbmc.log( "%s %s" % ( log_message,log_sep ), level=xbmc.LOGDEBUG )
+ xbmc.log( "%s - Title: %s" % ( log_message, movie_title, ), level=xbmc.LOGDEBUG )
+ xbmc.log( "%s - Path: %s" % ( log_message, path, ), level=xbmc.LOGDEBUG )
+ xbmc.log( "%s - Genre: %s" % ( log_message, genre, ), level=xbmc.LOGDEBUG )
+ xbmc.log( "%s - MPAA: %s" % ( log_message, short_mpaa, ), level=xbmc.LOGDEBUG )
+ xbmc.log( "%s - Audio: %s" % ( log_message, audio, ), level=xbmc.LOGDEBUG )
+ if video_settings[ "audio_videos_folder" ]:
+ xbmc.log( "%s - Folder: %s" % ( log_message, ( video_settings[ "audio_videos_folder" ] + { "dts": "DTS", "dca": "DTS", "ac3": "Dolby", "dtsma": "DTSHD-MA", "dtshd_ma": "DTSHD-MA", "a_truehd": "Dolby TrueHD", "truehd": "Dolby TrueHD" }.get( audio, "Other" ) + video_settings[ "audio_videos_folder" ][ -1 ], ) ), level=xbmc.LOGDEBUG )
+ xbmc.log( "%s %s" % ( log_message, log_sep ), level=xbmc.LOGDEBUG )
+ # return results
+ return short_mpaa, audio, genre, path, equivalent_mpaa
Oops, something went wrong.

0 comments on commit 510830b

Please sign in to comment.