src.themerr.gui#
- class src.themerr.gui.Window(player_instance=None)[source]#
Bases:
object
A class to represent the Kodi window.
This class watches for changes to the selected item in the Kodi window and starts/stops the theme accordingly.
- Parameters:
- player_instanceOptional[player.Player]
A player instance to use for testing purposes.
Examples
>>> window = Window() >>> window.window_watcher() ... >>> window = Window(player_instance=player.Player()) >>> window.window_watcher()
- Attributes:
- loglogger.Logger
The logger object.
- monitormonitor.ThemerrMonitor
The monitor object.
- playerplayer.Player
The player object.
- item_selected_forint
The number of seconds the current item has been selected for.
- playing_item_not_selected_forint
The number of seconds the playing item has not been selected for.
- current_selected_item_idOptional[int]
The current selected item ID.
- last_selected_item_idOptional[int]
The last selected item ID.
- uuid_mappingdict
A mapping of uuids to YouTube URLs. The UUID will be the database type and the database ID, separated by an underscore. e.g. tmdb_1 This is used to cache the YouTube URLs for faster lookups.
Methods
window_watcher()
The main method that watches for changes to the Kodi window.
pre_checks()
Perform pre-checks before starting/stopping the theme.
process_kodi_id(kodi_id: str)
Process the Kodi ID and return a YouTube URL.
process_movie(kodi_id: int)
Process the Kodi ID and return a dictionary of IDs.
find_youtube_url(kodi_id: str, db_type: str)
Find the YouTube URL from the IDs.
any_true(check: Optional[bool] = None, checks: Optional[Union[List[bool], Set[bool]]] = ())
Determine if the check is True or if any of the checks are True.
is_home()
Determine if the Kodi window is the home screen.
is_movies()
Determine if the Kodi window is a movies screen.
is_movie_set()
Determine if the Kodi window is a movie set screen.
is_tv_shows()
Determine if the Kodi window is a TV shows screen.
is_seasons()
Determine if the Kodi window is a seasons screen.
is_episodes()
Determine if the Kodi window is an episodes screen.
- static any_true(check: bool | None = None, checks: List[bool] | Set[bool] | None = ())[source]#
Determine if the check is True or if any of the checks are True.
This method can be used to determine if at least one condition is True out of a list of multiple conditions.
- Parameters:
- checkOptional[bool]
The check to perform.
- checksOptional[List[bool]]
The checks to perform.
- Returns:
- bool
True if any of the checks are True, otherwise False.
Examples
>>> Window().any_true(checks=[True, False, False]) True >>> Window().any_true(checks=[False, False, False]) False >>> Window().any_true(check=True) True >>> Window().any_true(check=False) False
- find_youtube_url(kodi_id: str, db_type: str) str | None [source]#
Find YouTube URL from the Dictionary of IDs.
Given a dictionary of IDs, this method will query the Themerr DB to find the YouTube URL.
- Parameters:
- kodi_idstr
The Kodi ID to process.
- db_typestr
The database type.
- Returns:
- Optional[str]
A YouTube URL if found, otherwise None.
Examples
>>> window = Window() >>> window.find_youtube_url(kodi_id='tmdb_1', db_type='movies')
- is_episodes() bool [source]#
Check if the Kodi window is an episodes screen.
This method uses
xbmc.getCondVisibility()
andxbmc.getInfoLabel()
to determine if the Kodi window is an episodes screen.- Returns:
- bool
True if the Kodi window is an episodes screen, otherwise False.
Examples
>>> Window().is_episodes()
- is_home() bool [source]#
Check if the Kodi window is the home screen.
This method uses
xbmc.getCondVisibility()
to determine if the Kodi window is the home screen.- Returns:
- bool
True if the Kodi window is the home screen, otherwise False.
Examples
>>> Window().is_home()
- is_movie_set() bool [source]#
Check if the Kodi window is a movie set screen.
This method uses
xbmc.getCondVisibility()
andxbmc.getInfoLabel()
to determine if the Kodi window is a movie set screen.- Returns:
- bool
True if the Kodi window is a movie set screen, otherwise False.
Examples
>>> Window().is_movie_set()
- is_movies() bool [source]#
Check if the Kodi window is a movies screen.
This method uses
xbmc.getCondVisibility()
andxbmc.getInfoLabel()
to determine if the Kodi window is a movies screen.- Returns:
- bool
True if the Kodi window is a movies screen, otherwise False.
Examples
>>> Window().is_movies()
- is_seasons() bool [source]#
Check if the Kodi window is a seasons screen.
This method uses
xbmc.getCondVisibility()
andxbmc.getInfoLabel()
to determine if the Kodi window is a seasons screen.- Returns:
- bool
True if the Kodi window is a seasons screen, otherwise False.
Examples
>>> Window().is_seasons()
- is_tv_shows() bool [source]#
Check if the Kodi window is a TV shows screen.
This method uses
xbmc.getCondVisibility()
andxbmc.getInfoLabel()
to determine if the Kodi window is a TV shows screen.- Returns:
- bool
True if the Kodi window is a TV shows screen, otherwise False.
Examples
>>> Window().is_tv_shows()
- pre_checks() bool [source]#
Perform pre-checks before starting/stopping the theme.
A series of checks are performed to determine if the theme should be played.
- Returns:
- bool
True if the theme should be played, otherwise False.
Examples
>>> window = Window() >>> window.pre_checks() True
- process_kodi_id(kodi_id: str) str | None [source]#
Generate YouTube URL from a given Kodi ID.
This method takes a Kodi ID and returns a YouTube URL.
- Parameters:
- kodi_idstr
The Kodi ID to process.
- Returns:
- Optional[str]
A YouTube URL if found, otherwise None.
Examples
>>> window = Window() >>> window.process_kodi_id(kodi_id='tmdb_1')