2022-08-10, 21:57
Ok, unfortunally, my knowledge do not alowed me to get this work, I need some help from experts:
I have this two buttons on a skin:
This two buttons poit to this script:
If the button with the argument "issue" is pressed, the "make_issue" def is executed.
If the button with the argument "album" is pressed, the "make_album" def is executed.
Until this point, this work very well.
My question is:
When the secont button is pressed (the one with "album" argument), "make_album" def calls the "_command_add_new_album" def in main.py from de addon NewsStand (this is just a private addon that I'm "creating" to learn how to develop addon for Kodi, ignore it for now).
the begining of this "_command_add_new_album" is this one:
It's possible to insert the "path" variable from the first script?
I already tried using "from the .make_issue import *", but the variable becomes "?com=ADD_ALBUM_SKIN". And from what I've researched, the command "xbmc.executebuiltin('RunPlugin(plugin') is the one who changes the sys.argv variables, correct?
Is there a way to do this?
thanks in advance
I have this two buttons on a skin:
Code:
<!-- This Button Make a Issue -->
<control type="button" id="1032">
<visible>Container.Content(images) + System.HasAddon(plugin.program.newsstand) + Container.HasFiles</visible>
<include>DialogSettingButton</include>
<onclick>RunScript(special://home/addons/plugin.program.newsstand/resources/make_issue.py, issue, $INFO[ListItem.Path], $INFO[ListItem.FolderName])</onclick>
<label>Make this folder a Issue</label>
<align>center</align>
</control>
<!-- This Button Make a Album -->
<control type="button" id="1033">
<visible>Container.Content(images) + System.HasAddon(plugin.program.newsstand) + Container.HasFiles</visible>
<include>DialogSettingButton</include>
<onclick>RunScript(special://home/addons/plugin.program.newsstand/resources/make_issue.py, album, $INFO[ListItem.Path], $INFO[ListItem.FolderName])</onclick>
<label>Add to NewsStand Albuns</label>
<align>center</align>
</control>
This two buttons poit to this script:
Code:
import xbmc
import xbmcgui
import sys
path = sys.argv[2]
name = sys.argv[3]
def make_issue():
if not os.path.exists(path + name + '.album'):
with open(path + name + '.album', 'w') as f:
f.write('this is a album file!')
xbmcgui.Dialog().notification('NewsStand', 'Album "{}" created on "{}"'.format(name, path), xbmcgui.NOTIFICATION_INFO)
else:
xbmcgui.Dialog().notification('NewsStand', 'Album "{}" already saved on "{}"'.format(name, path), xbmcgui.NOTIFICATION_WARNING)
def make_album():
xbmc.executebuiltin('RunPlugin(plugin://plugin.program.newsstand/?com=ADD_ALBUM_SKIN)')
# --- Script Entry Point ---#
if ( __name__ == "__main__" ):
if len(sys.argv[ 1 ]) > 0:
if sys.argv[1] == "issue":
make_issue()
elif sys.argv[1] == "album":
make_album()
If the button with the argument "issue" is pressed, the "make_issue" def is executed.
If the button with the argument "album" is pressed, the "make_album" def is executed.
Until this point, this work very well.
My question is:
When the secont button is pressed (the one with "album" argument), "make_album" def calls the "_command_add_new_album" def in main.py from de addon NewsStand (this is just a private addon that I'm "creating" to learn how to develop addon for Kodi, ignore it for now).
the begining of this "_command_add_new_album" is this one:
Code:
def _command_add_new_album(self):
LAUNCHER_FOLDER = 2
categoryID = 'Albuns'
launcher_type = LAUNCHER_FOLDER
app = MAGAZINE_FOLDER_APP_NAME
app_FName = FileName(app)
ext = 'album'
args = '$rom$'
path = 'I Need to put the variable "path = sys.argv[2]" here'
....
It's possible to insert the "path" variable from the first script?
I already tried using "from the .make_issue import *", but the variable becomes "?com=ADD_ALBUM_SKIN". And from what I've researched, the command "xbmc.executebuiltin('RunPlugin(plugin') is the one who changes the sys.argv variables, correct?
Is there a way to do this?
thanks in advance