Skip to content

Commit 4ac1913

Browse files
committed
picons downloader
1 parent 85bace7 commit 4ac1913

File tree

5 files changed

+426
-4
lines changed

5 files changed

+426
-4
lines changed

addon.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
22
<addon id="script.module.tvh2kodi"
33
name="Tvheadend Setup for Kodi"
4-
version="1.9"
4+
version="1.9.5"
55
provider-name="edit4ever">
66
<requires>
77
<import addon="xbmc.python" version="2.6.0"/>
@@ -17,6 +17,8 @@
1717
<description>Tvh2Kodi gives access to the basic Tvheadend settings directly from the Kodi interface. This can be used in place of the Tvheadend web interface to get your Tvheadend backend server configured and running. It is also provides an easy way to scan for new services and channels and to configure your channel EPG sources.
1818

1919
* minimum version of Tvheadend is 4.2
20+
v1.9.5
21+
- add picons downloader test
2022
v1.9
2123
- add timeshift options under DVR configuration
2224
- fix epg grabber progress bar

default.py

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
#!/usr/bin/env python
2+
################################################################################
3+
# This file is part of LibreELEC - https://libreelec.tv
4+
# Copyright (C) 2016-2017 Team LibreELEC
5+
# Copyright (C) 2017 Tnds82 (tndsrepo@gmail.com)
6+
#
7+
# LibreELEC is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation, either version 2 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# LibreELEC is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with LibreELEC. If not, see <http://www.gnu.org/licenses/>.
19+
################################################################################
20+
121
import xbmc,xbmcaddon,xbmcvfs,xbmcgui,xbmcplugin
222
import subprocess
323
from subprocess import Popen
@@ -13,8 +33,8 @@
1333
import ast
1434
import zipfile
1535
import datetime
16-
#from requests.exceptions import HTTPError
17-
#from requests.exceptions import ConnectionError
36+
import urllib
37+
import picons
1838

1939
plugin = Plugin()
2040
dialog = xbmcgui.Dialog()
@@ -183,6 +203,48 @@ def _ArchiveDirectory(parentDirectory):
183203
_ArchiveDirectory(inputDir)
184204
zipOut.close()
185205

206+
def picons_param_load():
207+
picons_source_list = ["CvH Picons - Name", "CvH Picons - Frequency", "ati711 - Color", "ait711 - Black", "ati711 - White", "URL"]
208+
picons_source_value = xbmcaddon.Addon().getSetting('psource')
209+
picons_source = picons_source_list[int(picons_source_value)]
210+
picons_dest = xbmcaddon.Addon().getSetting('pdest')
211+
picons_url = xbmcaddon.Addon().getSetting('purl')
212+
picons_list = ["Picons Source: " + str(picons_source), "Picons Destination: " + str(picons_dest), "DOWNLOAD PICONS"]
213+
sel_param = dialog.select('Picons Download - Select parameter', list=picons_list)
214+
if sel_param < 0:
215+
return
216+
if sel_param >= 0:
217+
if sel_param == 0:
218+
sel_psource = dialog.select('Select Picons Source', list=picons_source_list)
219+
if sel_psource < 0:
220+
picons_param_load()
221+
else:
222+
picons_source_set = xbmcaddon.Addon().setSetting(id='psource', value=str(sel_psource))
223+
picons_param_load()
224+
if sel_param == 1:
225+
picons_dest_update = dialog.browse(3, "Select Picons Destination", "files", defaultt=picons_dest)
226+
picons_dest_set = xbmcaddon.Addon().setSetting(id='pdest', value=picons_dest_update)
227+
picons_param_load()
228+
if sel_param == 2:
229+
addon = xbmcaddon.Addon(id='script.module.tvh2kodi')
230+
addonname = addon.getAddonInfo('name')
231+
addonfolder = addon.getAddonInfo('path')
232+
addonicon = os.path.join(addonfolder, 'resources/icon.png')
233+
addondata = xbmc.translatePath(addon.getAddonInfo('profile'))
234+
snp_json = os.path.join(addondata, 'data/snp.json')
235+
srp_json = os.path.join(addondata, 'data/srp.json')
236+
url_latest = 'http://cvh.libreelec.tv/picons/latest2.json'
237+
latest_json = urllib.urlopen(url_latest)
238+
if picons_source_value == "0":
239+
picons.compare_release_snp(snp_json)
240+
if picons_source_value == "1":
241+
picons.compare_release_srp(srp_json)
242+
if picons_source_value == "5":
243+
sel_purl = dialog.input('Enetr the Picons URL to Download', defaultt=picons_url,type=xbmcgui.INPUT_ALPHANUM)
244+
if sel_purl != "":
245+
picons_url_set = xbmcaddon.Addon().setSetting(id='purl', value=str(sel_purl))
246+
picons.picons_ext(sel_purl)
247+
186248
def dvr_param_load(dvr_uuid_sel):
187249
dvr_url = 'http://' + tvh_url + ':' + tvh_port + '/api/idnode/load?uuid=' + dvr_uuid_sel
188250
dvr_load = requests.get(dvr_url).json()
@@ -2061,7 +2123,7 @@ def tvh():
20612123
ch_icon_scheme, ch_icon_scheme_key, ch_icon_scheme_val = find_param_dict(tvh_config_load, 'chiconscheme', 'enum')
20622124
picon_path = find_param(tvh_config_load, 'piconpath')
20632125
picon_scheme, picon_scheme_key, picon_scheme_val = find_param_dict(tvh_config_load, 'piconscheme', 'enum')
2064-
tvh_config_info_list = ["DVB scan path: " + str(dvb_scan_path), "Prefer picon: " + str(prefer_picon), "Channel icon path: " + str(ch_icon_path), "Channel icon scheme: " + str(ch_icon_scheme), "Picon path: " + str(picon_path), "Picon scheme: " + str(picon_scheme), "RESET ALL CHANNEL ICONS", "BACKUP TVHEADEND USERDATA", "IMPORT TVHEADEND USERDATA"]
2126+
tvh_config_info_list = ["DVB scan path: " + str(dvb_scan_path), "Prefer picon: " + str(prefer_picon), "Channel icon path: " + str(ch_icon_path), "Channel icon scheme: " + str(ch_icon_scheme), "Picon path: " + str(picon_path), "Picon scheme: " + str(picon_scheme), "RESET ALL CHANNEL ICONS", "BACKUP TVHEADEND USERDATA", "IMPORT TVHEADEND USERDATA", "DOWNLOAD PICONS"]
20652127
param_update = ""
20662128
sel_tvh = dialog.select('Select a Tvh configuration parameter to edit', list=tvh_config_info_list)
20672129
if sel_tvh < 0:
@@ -2173,6 +2235,8 @@ def tvh():
21732235
dialog.ok("Unable to Restart Tvheadend Service!", "Unable to restart the Tvheadend service.", "Please enable the service in Kodi addons.")
21742236
else:
21752237
dialog.ok("Tvheadend Service Still Running!", "Unable to stop the Tvheadend service.", "Unable to complete backup.")
2238+
if sel_tvh == 9:
2239+
picons_param_load()
21762240
if param_update != "":
21772241
param_url = 'http://' + tvh_url + ':' + tvh_port + '/api/config/save?node={' + param_update + '}'
21782242
param_save = requests.get(param_url)

0 commit comments

Comments
 (0)