Skip to content

Commit

Permalink
manual channel add
Browse files Browse the repository at this point in the history
  • Loading branch information
Cip committed Mar 23, 2021
1 parent 92fd769 commit 7463c4e
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 5 deletions.
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v 0.1.0
1. migrate to python 3 for kodi 19

v 0.0.3
1. skip ad links from response

Expand Down
25 changes: 21 additions & 4 deletions default.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
settings = xbmcaddon.Addon(id=addon_id)
fileslist = xbmc.translatePath(settings.getAddonInfo('profile'))

MODE_SEARCH = 1
MODE_MANUAL_ADD = 7

def get_params():
param=[]

Expand Down Expand Up @@ -68,9 +71,17 @@ def CHANNEL_LIST():
liz.setArt({'icon': "DefaultFolder.png"})
liz.setInfo( type="Video", infoLabels={ "Title": None } )
liz.setProperty('IsPlayable', 'false')
url = sys.argv[0] + "?mode=1"
url = sys.argv[0] + "?mode=" + str(MODE_SEARCH)
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=liz, isFolder=True)

# Manual add channel
liz=xbmcgui.ListItem('[B][COLOR green]'+addon.getLocalizedString(30413)+'[/COLOR][/B]')
liz.setArt({'icon': "DefaultFolder.png"})
liz.setInfo( type="Video", infoLabels={ "Title": None } )
liz.setProperty('IsPlayable', 'false')
url = sys.argv[0] + "?mode=" + str(MODE_MANUAL_ADD)
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=liz, isFolder=False)

channels = Channels()
arrChannels = channels.loadChannels()
for ch in arrChannels:
Expand All @@ -96,7 +107,7 @@ def STREAM(name, url, ch_id):
if(SETTINGS.ACE_ENGINE_TYPE == 1): #use plexus
try:
addon_log('plexus')
xbmc.executebuiltin('XBMC.RunPlugin(plugin://program.plexus/?mode=1&url='+url+'&name='+name+'&iconimage='+iconimage+')')
xbmc.executebuiltin('RunPlugin(plugin://program.plexus/?mode=1&url='+url+'&name='+name+'&iconimage='+iconimage+')')
except Exception as inst:
addon_log(inst)
xbmc.executebuiltin("Notification(%s,%s,%i)" % (addon.getLocalizedString(30303), "", 10000))
Expand All @@ -122,7 +133,7 @@ def STREAM(name, url, ch_id):
channels = Channels()
channels.migrateDb()
CHANNEL_LIST()
elif mode==1: #search
elif mode == MODE_SEARCH: #search
channels = Channels()
arrChannels = channels.search()
LIST_SEARCH(arrChannels = arrChannels)
Expand All @@ -138,7 +149,8 @@ def STREAM(name, url, ch_id):
pass
elif (mode==4): #delete stream
channels = Channels()
channels.deleteStream(params["id"])
if(channels.deleteStream(params["id"])):
xbmc.executebuiltin("Container.Refresh")
elif (mode==5): #update stream
channels = Channels()
if(channels.updateStream(params["id"])):
Expand All @@ -149,6 +161,11 @@ def STREAM(name, url, ch_id):
if(channels.updateAllStreams()):
xbmc.executebuiltin("Notification(%s,%s,%i)" % (addon.getLocalizedString(30409), "", 1))
xbmc.executebuiltin("Container.Refresh")
elif(mode == MODE_MANUAL_ADD):
channels = Channels()
if(channels.manualAdd()):
xbmc.executebuiltin("Notification(%s,%s,%i)" % (addon.getLocalizedString(30405), "", 1))
xbmc.executebuiltin("Container.Refresh")

addon_log('------------- END ---------------')
xbmcplugin.endOfDirectory(int(sys.argv[1]))
21 changes: 20 additions & 1 deletion resources/acestreamsearch/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def search(self):
return scrapper.execute(name=name)

def add(self, name, url):
url = url.lower()
ch = Channel(name = name,
address = url)
if(ch.checkAddrExist()):
Expand All @@ -75,7 +76,7 @@ def deleteStream(self, chId):
ch = Channel()
ch.findOne(chId)
ch.delete()
xbmc.executebuiltin("Container.Refresh")
return True

def loadChannels(self):
db_connection=sqlite3.connect(SETTINGS.CHANNELS_DB)
Expand Down Expand Up @@ -129,5 +130,23 @@ def updateAllStreams(self):
percent = round(i * 100 / len(arrChannels))
pDialog.update(percent, ch.name)
i = i + 1

def manualAdd(self):
kb = xbmc.Keyboard('', addon.getLocalizedString(30403))
#url
kb.doModal()
if (kb.isConfirmed()):
name = kb.getText()
name = name.title()
if name == '' : sys.exit(0)
else:
kb = xbmc.Keyboard('', addon.getLocalizedString(30404))
kb.doModal()
if (kb.isConfirmed()):
address = kb.getText()
address = address.title()
if address == '' : sys.exit(0)
else:
return self.add(name, address)


13 changes: 13 additions & 0 deletions resources/language/English/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ msgctxt "#30402"
msgid "Search"
msgstr ""

msgctxt "#30403"
msgid "Name"
msgstr ""

msgctxt "#30404"
msgid "Address"
msgstr ""

msgctxt "#30405"
msgid "Successfully added!"
msgstr ""
Expand Down Expand Up @@ -116,3 +124,8 @@ msgstr ""
msgctxt "#30412"
msgid "Updating channels addresses..."
msgstr ""

msgctxt "#30413"
msgid "Manually add channel"
msgstr ""

0 comments on commit 7463c4e

Please sign in to comment.