Skip to content

Commit

Permalink
Version 1.0, fully working addon
Browse files Browse the repository at this point in the history
 - English language provided
 - Addon finds NVIDIA GeForce NOW in it's default location if installed
 - Automatically stops any playback from Kodi
 - In settings user can input a custom location
  • Loading branch information
ZoltePudeleczko authored Mar 2, 2020
1 parent ef917fd commit 067831e
Show file tree
Hide file tree
Showing 7 changed files with 203 additions and 0 deletions.
104 changes: 104 additions & 0 deletions script.kodi.geforcenow/addon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import xbmc
import xbmcaddon
import xbmcgui

import platform
import os.path
import subprocess


# Getting addon constants
ADDON = xbmcaddon.Addon('script.kodi.launches.steam')
ADDON_ID = ADDON.getAddonInfo('id')
ADDON_NAME = ADDON.getAddonInfo('name')
ADDON_VERSION = ADDON.getAddonInfo('version')
MSG = ADDON.getLocalizedString

# Getting main settings
useCustomExecutable = ADDON.getSetting('useCustomExecutable')


####################### Defining common methods #######################

# Method to print logs on a standard way
def log(message, level=xbmc.LOGNOTICE):
xbmc.log("[{0}:v{1}] {2}".format(ADDON_ID, ADDON_VERSION, message), level)
# log

# Method to show when addon couldn't detect the executable in the default directory
def showExecutableNotFoundDialog():
title = MSG(32003)
message = MSG(32004)
xbmcgui.Dialog().ok(title, message)
showOpenSettingsDialog()
# showExecutableNotFoundDialog

# Method to ask if user wants to open Addon Settings
def showOpenSettingsDialog():
title = MSG(32005)
message = MSG(32006)
if xbmcgui.Dialog().yesno(title, message):
ADDON.openSettings()
# showOpenSettingsDialog

# Method to show when addon is launched on Linux / Mac (as only Windows is supported)
def showWindowsNotDetected():
title = MSG(32007)
message = MSG(32008)
xbmcgui.Dialog().ok(title, message)
# showWindowsNotDetected

# Method to show when user has provided a custom executable path that doesn't exist
def showCustomExecutableNotFoundDialog():
title = MSG(32009)
message = MSG(32010)
xbmcgui.Dialog().ok(title, message)
showOpenSettingsDialog()
# showCustomExecutableNotFoundDialog

# Method to stop media playback in Kodi
def stopMediaPlayback():
player = xbmc.Player()
player.stop()
# stopMediaPlayback

# Method to execute GeForceNOW using provided executable
def execute(executable):
parameters = ''
log('Calling executable: {0} with parameters: {1}'.format(executable,parameters))
stopMediaPlayback()
subprocess.call([executable, parameters])
# execute

####################### Addon entrypoint #######################

# Starting the Addon
log("Starting Addon")

# Calling custom executable (if it is activated on Addon Settings)
if useCustomExecutable == 'true':
customExecutable = ADDON.getSetting('customExecutable')
if os.path.isfile(customExecutable):
execute(customExecutable)
else:
log('Executable not found on the custom location provided by user', xbmc.LOGERROR)
showCustomExecutableNotFoundDialog()

# Finding default GeForceNOW executable location
else:
executable = ''
executableTemp = ''

if platform.system() == 'Windows':
executableTemp = os.path.expandvars(r'%LOCALAPPDATA%\NVIDIA Corporation\GeForceNOW\CEF\GeForceNOW.exe')
if os.path.isfile(executableTemp):
executable = executableTemp
else:
log('Windows executable not found on default paths', xbmc.LOGERROR)
showExecutableNotFoundDialog()
if executable:
execute(executable)

else:
log('Platforms other than Windows are not supported now', xbmc.LOGERROR)
showWindowsNotDetected()
25 changes: 25 additions & 0 deletions script.kodi.geforcenow/addon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.kodi.geforcenow" name="GeForce NOW" version="1.0.0" provider-name="GanzeVA">
<requires>
<import addon="xbmc.python" version="2.25.0"/>
</requires>
<extension point="xbmc.python.script" library="addon.py">
<provides>executable</provides>
</extension>
<extension point="xbmc.addon.metadata">
<platform>windx</platform>
<summary lang="en">Kodi Addon for launching GeForce NOW</summary>
<description lang="en">Kodi Addon for launching NVIDIA GeForce NOW app.</description>
<license>GNU GENERAL PUBLIC LICENSE. Version 3, 29 June 2007</license>
<language>en</language>
<source>https://github.com/GanzeVA/Kodi-GeForceNOW</source>
<website>https://github.com/GanzeVA/Kodi-GeForceNOW</website>
<forum></forum>
<email>[email protected]</email>
<news></news>
<assets>
<icon>icon.png</icon>
<fanart>fanart.jpg</fanart>
</assets>
</extension>
</addon>
6 changes: 6 additions & 0 deletions script.kodi.geforcenow/changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
v.1.0
- First Release
- English language provided
- Addon finds NVIDIA GeForce NOW in it's default location if installed
- Automatically stops any playback from Kodi
- In settings user can input a custom location
Binary file added script.kodi.geforcenow/fanart.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added script.kodi.geforcenow/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 61 additions & 0 deletions script.kodi.geforcenow/resources/language/English/strings.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Kodi Media Center language file
# Addon Name: Kodi GeForceNOW
# Addon id: script.kodi.geforcenow
# Addon Provider: iampeluca <[email protected]>
msgid ""
msgstr ""
"Project-Id-Version: script.kodi.geforcenow\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2020-03-02 15:30-0600\n"
"PO-Revision-Date: 2020-03-02 15:30-0600\n"
"Last-Translator: Szymon Zborowski <[email protected]>\n"
"Language-Team: English <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: en\n"
"Plural-Forms: nplurals=2; plural=(n != 1);f\n"

msgctxt "#32000"
msgid "General"
msgstr ""

msgctxt "#32001"
msgid "Use custom executable:"
msgstr ""

msgctxt "#32002"
msgid "Custom Executable:"
msgstr ""

msgctxt "#32003"
msgid "Executable not found"
msgstr ""

msgctxt "#32004"
msgid "The NVIDIA GeForceNOW executable was not found on your System on the expected locations."
msgstr ""

msgctxt "#32005"
msgid "Addon Settings"
msgstr ""

msgctxt "#32006"
msgid "Would you like to open the Addon Settings and specify the NVIDIA GeForceNOW location?"
msgstr ""

msgctxt "#32007"
msgid "Windows Not Detected"
msgstr ""

msgctxt "#32008"
msgid "This Addon currently works only on Windows platforms."
msgstr ""

msgctxt "#32009"
msgid "Custom executable not found"
msgstr ""

msgctxt "#32010"
msgid "The custom executable was not found. Please select a new location for it on the Addon Settings."
msgstr ""
7 changes: 7 additions & 0 deletions script.kodi.geforcenow/resources/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<settings>
<category label="32000">
<setting id="useCustomExecutable" label="32001" type="bool" default="false"/>
<setting id="customExecutable" label="32002" type="executable" default="" subsetting="true" enable="eq(-1,true)"/>
</category>
</settings>

0 comments on commit 067831e

Please sign in to comment.