Skip to content

Commit c693138

Browse files
committed
add epg grabber cron wizard
1 parent 003c06c commit c693138

File tree

4 files changed

+100
-34
lines changed

4 files changed

+100
-34
lines changed

addon.xml

Lines changed: 6 additions & 17 deletions
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.5"
4+
version="1.9.6"
55
provider-name="edit4ever">
66
<requires>
77
<import addon="xbmc.python" version="2.6.0"/>
@@ -17,11 +17,7 @@
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
22-
v1.9
23-
- add timeshift options under DVR configuration
24-
- fix epg grabber progress bar
20+
2521
</description>
2622
<disclaimer>Copyright (C) 2017 edit4ever - edit4ever@gmail.com</disclaimer>
2723
<platform>all</platform>
@@ -34,16 +30,9 @@ v1.9
3430
<screenshot>resources/screenshot-03.jpg</screenshot>
3531
</assets>
3632
<news>
37-
v1.8.1 - fix username-password display
38-
v1.8 - add support for IPTV Networks - fix error in muxes when 0 muxes available
39-
v1.7 - add support for Tvh username-password
40-
v1.6 - add backup and import of tvh userdata - add channel icon reset option
41-
v1.5 - add progress bar for internal epg grab - add base tvh config parameters (set dvb scan files and channel icon paths)
42-
v1.4 - fix adapter network issue - add multiple network support to adapter - allow custom Tvh server ip to be recalled
43-
v1.3 - add support for DVB-S mux editing
44-
v1.2 - fix error in network parameters load - fix wrong epg parameter selection
45-
v1.1 - add triggers for OTA and internal grabbers
46-
v1.0 - Initial Release
47-
</news>
33+
1.9.6 - add epg grabber cron wizard
34+
1.9.5 - add picons downloader (test)
35+
1.9 - add timeshift options under DVR configuration - fix epg grabber progress bar
36+
</news>
4837
</extension>
4938
</addon>

changelog.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
v1.9.6 (2017-11-29)
2+
- add epg grabber cron wizard
3+
4+
v1.9.5 (2017-08-08)
5+
- add picons downloader (test)
6+
7+
v1.9 (2017-08-03)
8+
- add timeshift options under DVR configuration - fix epg grabber progress bar
9+
10+
v1.8.1 (2017-07-28)
11+
- fix username-password display
12+
13+
v1.6/1.7/1.8 (2017-07-26)
14+
- add backup and import of tvh userdata - add channel icon reset option
15+
- add support for Tvh username-password
16+
- add support for IPTV Networks - fix error in muxes when 0 muxes available
17+
18+
v1.5 (2017-07-14)
19+
- add progress bar for internal epg grab - add base tvh config parameters (set dvb scan files and channel icon paths)
20+
21+
v1.4 (2017-07-10)
22+
- fix adapter network issue - add multiple network support to adapter - allow custom Tvh server ip to be recalled
23+
24+
v1.3 (2017-07-08)
25+
- add support for DVB-S mux editing
26+
27+
v1.2 (2017-07-08)
28+
- fix error in network parameters load - fix wrong epg parameter selection
29+
30+
v1.1 (2017-07-07)
31+
- add triggers for OTA and internal grabbers
32+
33+
v1.0 (2017-07-06)
34+
- Initial Release

default.py

Lines changed: 59 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,7 @@ def ch_param_edit(ch_uuid_sel, ch_info_list, ch_enabled, ch_autoname, ch_name, c
11361136
param_update = '"autoname":' + ch_autoname
11371137
if sel_param == 4:
11381138
sel_ch_icon = dialog.input('Edit the channel icon URL', defaultt=ch_icon,type=xbmcgui.INPUT_ALPHANUM)
1139-
if sel_ch_name == "":
1139+
if sel_ch_icon == "":
11401140
ch_param_load(ch_uuid_sel)
11411141
else:
11421142
param_update = '"icon":"' + sel_ch_icon + '"'
@@ -1167,6 +1167,45 @@ def ch_param_edit(ch_uuid_sel, ch_info_list, ch_enabled, ch_autoname, ch_name, c
11671167
ch_param_load(ch_uuid_sel)
11681168

11691169

1170+
def cron_edit(epg_intcron):
1171+
cron_def_weekday_list = ['Everyday', 'Every Other Day', 'on Sundays', 'on Mondays', 'on Tuesdays', 'on Wednesdays', 'on Thursdays', 'on Fridays', 'on Saturdays']
1172+
cron_def_weekday = {'*':'Everyday', '2-30/2': 'Every Other Day', '0':'on Sundays', '1':'on Mondays', '2':'on Tuesdays', '3':'on Wednesdays', '4':'on Thursdays', '5':'on Fridays', '6':'on Saturdays'}
1173+
cron_def_split_hour_list = ['Specific Hour', '2x a Day', '3x a Day', '4x a Day', '6x a Day', '8x a Day', '12x a Day', 'every Hour']
1174+
cron_def_split_hour = {'*':'every Hour', '*/2':'12x a Day', '*/3':'8x a Day', '*/4':'6x a Day','*/6':'4x a Day', '*/8':'3x a Day', '*/12':'2x a Day'}
1175+
cron_def_hours = ['12:00AM - Midnight', '1:00AM', '2:00AM', '3:00AM', '4:00AM', '5:00AM', '6:00AM', '7:00AM', '8:00AM', '9:00AM', '10:00AM', '11:00AM', '12:00PM - Noon', '1:00PM', '2:00PM', '3:00PM', '4:00PM', '5:00PM', '6:00PM', '7:00PM', '8:00PM', '9:00PM', '10:00PM', '11:00PM']
1176+
epg_intcron_clean = re.sub('#.*\n', '', epg_intcron)
1177+
cron_current = epg_intcron_clean.split(' ')
1178+
cron_current_min = str(int(cron_current[0])).zfill(2)
1179+
if '*' in cron_current[1]:
1180+
cron_current_str = cron_current_min + ' Minutes past the hour, ' + cron_def_split_hour[cron_current[1]] + ', ' + cron_def_weekday[cron_current[2]]
1181+
else:
1182+
cron_ampm = 'AM'
1183+
if cron_current[1] == '00' or cron_current[1] == '0':
1184+
cron_current_hour = '12'
1185+
elif int(cron_current[1]) > 12:
1186+
cron_current_hour = str(24 - int(cron_current[1]))
1187+
cron_ampm = 'PM'
1188+
else:
1189+
cron_current_hour = cron_current[1]
1190+
cron_current_str = cron_current_hour + ':' + cron_current_min + cron_ampm + ' - ' + cron_def_weekday[cron_current[2]]
1191+
cron_edit_sel = dialog.yesno('Cron edit', 'The grabber is set to run at:', cron_current_str, 'Do you wish to edit this cron setting?')
1192+
if cron_edit_sel:
1193+
cron_sel_weekday = dialog.select('Select which day(s) to run the grabber', list=cron_def_weekday_list)
1194+
if cron_sel_weekday >= 0:
1195+
cron_new_weekday = cron_def_weekday.keys()[cron_def_weekday.values().index(cron_def_weekday_list[cron_sel_weekday])]
1196+
cron_sel_hour = dialog.select('Select which hour(s) to run the grabber', list=cron_def_split_hour_list)
1197+
if cron_sel_hour == 0:
1198+
cron_sel_hour_spec = dialog.select('Select which hour(s) to run the grabber', list=cron_def_hours)
1199+
cron_new_hour = cron_sel_hour_spec
1200+
if cron_sel_hour > 0:
1201+
cron_new_hour = cron_def_split_hour.keys()[cron_def_split_hour.values().index(cron_def_split_hour_list[cron_sel_hour])]
1202+
cron_new_min = dialog.input('Enter the minutes after the hour to run the grabber', defaultt='0', type=xbmcgui.INPUT_NUMERIC)
1203+
cron_update = str(cron_new_min) + ' ' + str(cron_new_hour) + ' ' + cron_new_weekday + ' * *'
1204+
return cron_update
1205+
else:
1206+
return epg_intcron
1207+
1208+
11701209
def epg_param(sel_epg, epg_rename, epg_renumber, epg_reicon, epg_dbsave, epg_intcron, epg_otainit, epg_otacron, epg_otatime):
11711210
param_update = ""
11721211
if sel_epg == 3:
@@ -1190,20 +1229,32 @@ def epg_param(sel_epg, epg_rename, epg_renumber, epg_reicon, epg_dbsave, epg_int
11901229
sel_epg_dbsave = epg_dbsave
11911230
param_update = '"epgdb_periodicsave":' + str(sel_epg_dbsave)
11921231
if sel_epg == 7:
1193-
sel_epg_intcron = dialog.input('Edit the cron multiline for internal grabbers', defaultt=epg_intcron,type=xbmcgui.INPUT_ALPHANUM)
1194-
if sel_epg_intcron == "":
1195-
sel_epg_intcron = epg_intcron
1232+
sel_epg_intcron_type = dialog.yesno('Edit the cron for internal grabbers', 'If you are familiar with cron settings you can manually enter the cron.', '', 'Otherwise use the wizard to select the grabber run times.', 'Wizard', 'Manual')
1233+
if sel_epg_intcron_type:
1234+
sel_epg_intcron = dialog.input('Edit the cron multiline for internal grabbers', defaultt=epg_intcron,type=xbmcgui.INPUT_ALPHANUM)
1235+
if sel_epg_intcron == "":
1236+
sel_epg_intcron = epg_intcron
1237+
else:
1238+
sel_epg_intcron = cron_edit(epg_intcron)
1239+
if sel_epg_intcron == "":
1240+
sel_epg_intcron = epg_intcron
11961241
param_update = '"cron":"' + sel_epg_intcron + '"'
11971242
if sel_epg == 8:
11981243
sel_epg_otainit = dialog.select('Enable or disable initial EPG grab at startup', list=enabledisable)
11991244
if sel_epg_otainit >= 0:
12001245
epg_otainit = truefalse[sel_epg_otainit]
12011246
param_update = '"ota_initial":' + epg_otainit
12021247
if sel_epg == 9:
1203-
sel_epg_otacron = dialog.input('Edit the cron multiline for over-the-air grabbers', defaultt=epg_otacron,type=xbmcgui.INPUT_ALPHANUM)
1204-
if sel_epg_otacron == "":
1205-
sel_epg_otacron = epg_otacron
1206-
param_update = '"cron":"' + sel_epg_otacron + '"'
1248+
sel_epg_otacron_type = dialog.yesno('Edit the cron for OTA grabbers', 'If you are familiar with cron settings you can manually enter the cron.', '', 'Otherwise use the wizard to select the grabber run times.', 'Wizard', 'Manual')
1249+
if sel_epg_otacron_type:
1250+
sel_epg_otacron = dialog.input('Edit the cron multiline for over-the-air grabbers', defaultt=epg_otacron,type=xbmcgui.INPUT_ALPHANUM)
1251+
if sel_epg_otacron == "":
1252+
sel_epg_otacron = epg_otacron
1253+
else:
1254+
sel_epg_otacron = cron_edit(epg_otacron)
1255+
if sel_epg_otacron == "":
1256+
sel_epg_otacron = epg_otacron
1257+
param_update = '"ota_cron":"' + sel_epg_otacron + '"'
12071258
if sel_epg == 10:
12081259
sel_epg_otatime = dialog.input('OTA EPG scan timeout in seconds (30-7200)', defaultt=str(epg_otatime),type=xbmcgui.INPUT_NUMERIC)
12091260
if sel_epg_otatime == "":
@@ -1751,8 +1802,6 @@ def wizard_start():
17511802
for adapter_t in adapter_get:
17521803
adapter_list.append(adapter_t['text'])
17531804
sel_adapter = dialog.select('Select which adapter you would like to setup first', list=adapter_list)
1754-
if sel_adapter < 0:
1755-
return
17561805
if sel_adapter >= 0:
17571806
adapter_uuid_sel = adapter_uuid[sel_adapter]
17581807
adapter_text_sel = adapter_list[sel_adapter]
@@ -1902,8 +1951,6 @@ def adapters():
19021951
adapters_full = zip(adapter_text, adapter_enabled)
19031952
adapters_list = ["%s %s" % x for x in adapters_full]
19041953
sel_adapter = dialog.select('Select which adapter you would like to configure', list=adapters_list)
1905-
if sel_adapter < 0:
1906-
return
19071954
if sel_adapter >= 0:
19081955
adapter_uuid_sel = adapter_uuid[sel_adapter]
19091956
adapt_param_load(adapter_uuid_sel)
@@ -1919,8 +1966,6 @@ def networks():
19191966
for net_u in networks['entries']:
19201967
net_uuid.append(net_u['uuid'])
19211968
sel_network = dialog.select('Select a network to configure', list=net_name)
1922-
if sel_network < 0:
1923-
return
19241969
if sel_network == 0:
19251970
net_uuid_sel = network_new()
19261971
if net_uuid_sel == "":
@@ -1942,8 +1987,6 @@ def muxes():
19421987
for net_u in networks['entries']:
19431988
net_uuid.append(net_u['uuid'])
19441989
sel_network = dialog.select('Select a network to see list of muxes', list=net_name)
1945-
if sel_network < 0:
1946-
return
19471990
if sel_network >= 0:
19481991
net_uuid_sel = net_uuid[sel_network]
19491992
muxes_load(net_uuid_sel)

picons.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def compare_release(url_latest, picons_file, picons_source_value):
5555
ljson = json.loads(latest_json.read())
5656
picons_src = int(picons_source_value) - 1
5757
latest = ljson['Picons']['latest'][picons_src]['name']
58-
if os.path.exists(log_json):
58+
if os.path.isfile(log_json):
5959
with open(log_json) as release_json:
6060
rjson = json.load(release_json)
6161
release = rjson['Picons']['latest'][picons_src]['name']

0 commit comments

Comments
 (0)