Skip to content

Commit 067831e

Browse files
Version 1.0, fully working addon
- 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
1 parent ef917fd commit 067831e

File tree

7 files changed

+203
-0
lines changed

7 files changed

+203
-0
lines changed

script.kodi.geforcenow/addon.py

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import xbmc
2+
import xbmcaddon
3+
import xbmcgui
4+
5+
import platform
6+
import os.path
7+
import subprocess
8+
9+
10+
# Getting addon constants
11+
ADDON = xbmcaddon.Addon('script.kodi.launches.steam')
12+
ADDON_ID = ADDON.getAddonInfo('id')
13+
ADDON_NAME = ADDON.getAddonInfo('name')
14+
ADDON_VERSION = ADDON.getAddonInfo('version')
15+
MSG = ADDON.getLocalizedString
16+
17+
# Getting main settings
18+
useCustomExecutable = ADDON.getSetting('useCustomExecutable')
19+
20+
21+
####################### Defining common methods #######################
22+
23+
# Method to print logs on a standard way
24+
def log(message, level=xbmc.LOGNOTICE):
25+
xbmc.log("[{0}:v{1}] {2}".format(ADDON_ID, ADDON_VERSION, message), level)
26+
# log
27+
28+
# Method to show when addon couldn't detect the executable in the default directory
29+
def showExecutableNotFoundDialog():
30+
title = MSG(32003)
31+
message = MSG(32004)
32+
xbmcgui.Dialog().ok(title, message)
33+
showOpenSettingsDialog()
34+
# showExecutableNotFoundDialog
35+
36+
# Method to ask if user wants to open Addon Settings
37+
def showOpenSettingsDialog():
38+
title = MSG(32005)
39+
message = MSG(32006)
40+
if xbmcgui.Dialog().yesno(title, message):
41+
ADDON.openSettings()
42+
# showOpenSettingsDialog
43+
44+
# Method to show when addon is launched on Linux / Mac (as only Windows is supported)
45+
def showWindowsNotDetected():
46+
title = MSG(32007)
47+
message = MSG(32008)
48+
xbmcgui.Dialog().ok(title, message)
49+
# showWindowsNotDetected
50+
51+
# Method to show when user has provided a custom executable path that doesn't exist
52+
def showCustomExecutableNotFoundDialog():
53+
title = MSG(32009)
54+
message = MSG(32010)
55+
xbmcgui.Dialog().ok(title, message)
56+
showOpenSettingsDialog()
57+
# showCustomExecutableNotFoundDialog
58+
59+
# Method to stop media playback in Kodi
60+
def stopMediaPlayback():
61+
player = xbmc.Player()
62+
player.stop()
63+
# stopMediaPlayback
64+
65+
# Method to execute GeForceNOW using provided executable
66+
def execute(executable):
67+
parameters = ''
68+
log('Calling executable: {0} with parameters: {1}'.format(executable,parameters))
69+
stopMediaPlayback()
70+
subprocess.call([executable, parameters])
71+
# execute
72+
73+
####################### Addon entrypoint #######################
74+
75+
# Starting the Addon
76+
log("Starting Addon")
77+
78+
# Calling custom executable (if it is activated on Addon Settings)
79+
if useCustomExecutable == 'true':
80+
customExecutable = ADDON.getSetting('customExecutable')
81+
if os.path.isfile(customExecutable):
82+
execute(customExecutable)
83+
else:
84+
log('Executable not found on the custom location provided by user', xbmc.LOGERROR)
85+
showCustomExecutableNotFoundDialog()
86+
87+
# Finding default GeForceNOW executable location
88+
else:
89+
executable = ''
90+
executableTemp = ''
91+
92+
if platform.system() == 'Windows':
93+
executableTemp = os.path.expandvars(r'%LOCALAPPDATA%\NVIDIA Corporation\GeForceNOW\CEF\GeForceNOW.exe')
94+
if os.path.isfile(executableTemp):
95+
executable = executableTemp
96+
else:
97+
log('Windows executable not found on default paths', xbmc.LOGERROR)
98+
showExecutableNotFoundDialog()
99+
if executable:
100+
execute(executable)
101+
102+
else:
103+
log('Platforms other than Windows are not supported now', xbmc.LOGERROR)
104+
showWindowsNotDetected()

script.kodi.geforcenow/addon.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<addon id="script.kodi.geforcenow" name="GeForce NOW" version="1.0.0" provider-name="GanzeVA">
3+
<requires>
4+
<import addon="xbmc.python" version="2.25.0"/>
5+
</requires>
6+
<extension point="xbmc.python.script" library="addon.py">
7+
<provides>executable</provides>
8+
</extension>
9+
<extension point="xbmc.addon.metadata">
10+
<platform>windx</platform>
11+
<summary lang="en">Kodi Addon for launching GeForce NOW</summary>
12+
<description lang="en">Kodi Addon for launching NVIDIA GeForce NOW app.</description>
13+
<license>GNU GENERAL PUBLIC LICENSE. Version 3, 29 June 2007</license>
14+
<language>en</language>
15+
<source>https://github.com/GanzeVA/Kodi-GeForceNOW</source>
16+
<website>https://github.com/GanzeVA/Kodi-GeForceNOW</website>
17+
<forum></forum>
18+
<email>[email protected]</email>
19+
<news></news>
20+
<assets>
21+
<icon>icon.png</icon>
22+
<fanart>fanart.jpg</fanart>
23+
</assets>
24+
</extension>
25+
</addon>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
v.1.0
2+
- First Release
3+
- English language provided
4+
- Addon finds NVIDIA GeForce NOW in it's default location if installed
5+
- Automatically stops any playback from Kodi
6+
- In settings user can input a custom location

script.kodi.geforcenow/fanart.jpg

22.8 KB
Loading

script.kodi.geforcenow/icon.png

18.2 KB
Loading
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Kodi Media Center language file
2+
# Addon Name: Kodi GeForceNOW
3+
# Addon id: script.kodi.geforcenow
4+
# Addon Provider: iampeluca <[email protected]>
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: script.kodi.geforcenow\n"
8+
"Report-Msgid-Bugs-To: [email protected]\n"
9+
"POT-Creation-Date: 2020-03-02 15:30-0600\n"
10+
"PO-Revision-Date: 2020-03-02 15:30-0600\n"
11+
"Last-Translator: Szymon Zborowski <[email protected]>\n"
12+
"Language-Team: English <[email protected]>\n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: 8bit\n"
16+
"Language: en\n"
17+
"Plural-Forms: nplurals=2; plural=(n != 1);f\n"
18+
19+
msgctxt "#32000"
20+
msgid "General"
21+
msgstr ""
22+
23+
msgctxt "#32001"
24+
msgid "Use custom executable:"
25+
msgstr ""
26+
27+
msgctxt "#32002"
28+
msgid "Custom Executable:"
29+
msgstr ""
30+
31+
msgctxt "#32003"
32+
msgid "Executable not found"
33+
msgstr ""
34+
35+
msgctxt "#32004"
36+
msgid "The NVIDIA GeForceNOW executable was not found on your System on the expected locations."
37+
msgstr ""
38+
39+
msgctxt "#32005"
40+
msgid "Addon Settings"
41+
msgstr ""
42+
43+
msgctxt "#32006"
44+
msgid "Would you like to open the Addon Settings and specify the NVIDIA GeForceNOW location?"
45+
msgstr ""
46+
47+
msgctxt "#32007"
48+
msgid "Windows Not Detected"
49+
msgstr ""
50+
51+
msgctxt "#32008"
52+
msgid "This Addon currently works only on Windows platforms."
53+
msgstr ""
54+
55+
msgctxt "#32009"
56+
msgid "Custom executable not found"
57+
msgstr ""
58+
59+
msgctxt "#32010"
60+
msgid "The custom executable was not found. Please select a new location for it on the Addon Settings."
61+
msgstr ""
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
2+
<settings>
3+
<category label="32000">
4+
<setting id="useCustomExecutable" label="32001" type="bool" default="false"/>
5+
<setting id="customExecutable" label="32002" type="executable" default="" subsetting="true" enable="eq(-1,true)"/>
6+
</category>
7+
</settings>

0 commit comments

Comments
 (0)