Skip to content

Commit 85bace7

Browse files
committed
add timeshift - version bump
1 parent ccad67d commit 85bace7

File tree

4 files changed

+107
-33
lines changed

4 files changed

+107
-33
lines changed

addon.xml

Lines changed: 14 additions & 32 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.8.1"
4+
version="1.9"
55
provider-name="edit4ever">
66
<requires>
77
<import addon="xbmc.python" version="2.6.0"/>
@@ -17,20 +17,9 @@
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.8.1
21-
- fix username-password display
22-
v1.8
23-
- add support for IPTV Networks
24-
- fix error in muxes when 0 muxes available
25-
v1.7
26-
- add support for Tvh username-password
27-
v1.6
28-
- add backup and import of tvh userdata
29-
- add channel icon reset option
30-
v1.5
31-
- add progress bar for internal epg grab
32-
- add base tvh config parameters (set dvb scan files and channel icon paths)
33-
20+
v1.9
21+
- add timeshift options under DVR configuration
22+
- fix epg grabber progress bar
3423
</description>
3524
<disclaimer>Copyright (C) 2017 edit4ever - edit4ever@gmail.com</disclaimer>
3625
<platform>all</platform>
@@ -43,23 +32,16 @@ v1.5
4332
<screenshot>resources/screenshot-03.jpg</screenshot>
4433
</assets>
4534
<news>
46-
v1.4
47-
- fix adapter network issue
48-
- add multiple network support to adapter
49-
- allow custom Tvh server ip to be recalled
50-
51-
v1.3
52-
- add support for DVB-S mux editing
53-
54-
v1.2
55-
- fix error in network parameters load
56-
- fix wrong epg parameter selection
57-
58-
v1.1
59-
- add triggers for OTA and internal grabbers
60-
61-
v1.0
62-
- Initial Release
35+
v1.8.1 - fix username-password display
36+
v1.8 - add support for IPTV Networks - fix error in muxes when 0 muxes available
37+
v1.7 - add support for Tvh username-password
38+
v1.6 - add backup and import of tvh userdata - add channel icon reset option
39+
v1.5 - add progress bar for internal epg grab - add base tvh config parameters (set dvb scan files and channel icon paths)
40+
v1.4 - fix adapter network issue - add multiple network support to adapter - allow custom Tvh server ip to be recalled
41+
v1.3 - add support for DVB-S mux editing
42+
v1.2 - fix error in network parameters load - fix wrong epg parameter selection
43+
v1.1 - add triggers for OTA and internal grabbers
44+
v1.0 - Initial Release
6345
</news>
6446
</extension>
6547
</addon>

default.py

Lines changed: 91 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def dvr_param_load(dvr_uuid_sel):
204204
dvr_clone = find_param(dvr_load, 'clone')
205205
dvr_storage = find_param(dvr_load, 'storage')
206206
xbmcaddon.Addon().setSetting(id='dvrstorage', value=dvr_storage)
207-
dvr_info_list = ["Name: " + str(dvr_name), "Enabled: " + str(dvr_enabled), "Storage: " + str(dvr_storage), "Days to Keep Recordings: " + str(dvr_keep), "Duplicate Recording Timer If Error Occurs: " + str(dvr_clone), "Stream Profile: " + str(dvr_profile), "Recording File and Folder options"]
207+
dvr_info_list = ["Name: " + str(dvr_name), "Enabled: " + str(dvr_enabled), "Storage: " + str(dvr_storage), "Days to Keep Recordings: " + str(dvr_keep), "Duplicate Recording Timer If Error Occurs: " + str(dvr_clone), "Stream Profile: " + str(dvr_profile), "Recording File and Folder options", "Timeshift Options"]
208208
dvr_param_edit(dvr_uuid_sel, dvr_info_list, dvr_keep_key, dvr_keep_val, dvr_name, dvr_enabled, dvr_storage, dvr_keep, dvr_clone, dvr_profile_key, dvr_profile_val, dvr_profile)
209209

210210
def dvr_param_edit(dvr_uuid_sel, dvr_info_list, dvr_keep_key, dvr_keep_val, dvr_name, dvr_enabled, dvr_storage, dvr_keep, dvr_clone, dvr_profile_key, dvr_profile_val, dvr_profile):
@@ -251,6 +251,8 @@ def dvr_param_edit(dvr_uuid_sel, dvr_info_list, dvr_keep_key, dvr_keep_val, dvr_
251251
param_update = '"profile":' + str(dvr_profile)
252252
if sel_param == 6:
253253
dvr_file_param_load(dvr_uuid_sel)
254+
if sel_param == 7:
255+
time_param_load(dvr_uuid_sel)
254256
if param_update != "":
255257
param_url = 'http://' + tvh_url + ':' + tvh_port + '/api/idnode/save?node={' + param_update + ',"uuid":"' + dvr_uuid_sel + '"}'
256258
param_save = requests.get(param_url)
@@ -345,6 +347,94 @@ def dvr_file_param_edit(dvr_uuid_sel, dvr_file_info_list, dvr_day_dir, dvr_chann
345347
param_save = requests.get(param_url)
346348
dvr_file_param_load(dvr_uuid_sel)
347349

350+
def time_param_load(dvr_uuid_sel):
351+
time_url = 'http://' + tvh_url + ':' + tvh_port + '/api/timeshift/config/load'
352+
time_load = requests.get(time_url).json()
353+
time_enabled = find_param(time_load, 'enabled')
354+
time_ondemand = find_param(time_load, 'ondemand')
355+
time_path = find_param(time_load, 'path')
356+
time_max_period = find_param(time_load, 'max_period')
357+
time_unlimited_period = find_param(time_load, 'unlimited_period')
358+
time_max_size = find_param(time_load, 'max_size')
359+
time_ram_size = find_param(time_load, 'ram_size')
360+
time_unlimited_size = find_param(time_load, 'unlimited_size')
361+
time_ram_only = find_param(time_load, 'ram_only')
362+
time_ram_fit = find_param(time_load, 'ram_fit')
363+
time_teletext = find_param(time_load, 'teletext')
364+
time_info_list = ["Timeshift Enabled: " + str(time_enabled), "Maximum Time (mins): " + str(time_max_period), "Storage Path: " + str(time_path), "Maximum Size (MB): " + str(time_max_size), "Maximum RAM Size (MB): " + str(time_ram_size), "RAM Only: " + str(time_ram_only), "On-demand (no first rewind): " + str(time_ondemand), "Unlimited Time: " + str(time_unlimited_period), "Unlimited Size: " + str(time_unlimited_size), "Fit to RAM (cut rewind): " + str(time_ram_fit), "Include Teletext: " + str(time_teletext)]
365+
time_param_edit(dvr_uuid_sel, time_info_list, time_enabled, time_max_period, time_path, time_max_size, time_ram_size, time_ram_only, time_ondemand, time_unlimited_period, time_unlimited_size, time_ram_fit, time_teletext)
366+
367+
def time_param_edit(dvr_uuid_sel, time_info_list, time_enabled, time_max_period, time_path, time_max_size, time_ram_size, time_ram_only, time_ondemand, time_unlimited_period, time_unlimited_size, time_ram_fit, time_teletext):
368+
sel_param = dialog.select('Timeshift Options - Select parameter to edit', list=time_info_list)
369+
if sel_param < 0:
370+
return
371+
if sel_param >= 0:
372+
param_update = ""
373+
if sel_param == 0:
374+
sel_enabled = dialog.select('Enable/Disable the timeshift function', list=enabledisable)
375+
if sel_enabled >= 0:
376+
time_enabled = truefalse[sel_enabled]
377+
param_update = '"enabled":' + time_enabled
378+
if sel_param == 1:
379+
sel_num = dialog.input('Set maximum time for buffering (minutes)', defaultt=str(time_max_period),type=xbmcgui.INPUT_NUMERIC)
380+
if sel_num >= 0:
381+
time_max_period = sel_num
382+
param_update = '"max_period":' + str(time_max_period)
383+
if sel_param == 2:
384+
if tvh_url == "127.0.0.1":
385+
plugin.open_settings()
386+
time_storage_update_tvh = xbmcaddon.Addon().getSetting('timestorage')
387+
param_update = '"path":"' + str(time_storage_update_tvh) + '"'
388+
else:
389+
dialog.ok('Tvheadend backend on network location', 'Your Tvheadend backend is located on a network. Currently Kodi cannot browse network folders.', 'Please enter the DVR recording location manually.')
390+
time_storage_update_tvh = dialog.input('Edit the timeshift buffer path', defaultt=time_path,type=xbmcgui.INPUT_ALPHANUM)
391+
xbmcaddon.Addon().setSetting(id='timestorage', value=time_storage_update_tvh)
392+
param_update = '"path":"' + str(time_storage_update_tvh) + '"'
393+
if sel_param == 3:
394+
sel_num = dialog.input('Set maximum storage size for buffering (MB)', defaultt=str(time_max_size),type=xbmcgui.INPUT_NUMERIC)
395+
if sel_num >= 0:
396+
time_max_size = sel_num
397+
param_update = '"max_size":' + str(time_max_size)
398+
if sel_param == 4:
399+
sel_num = dialog.input('Set maximum RAM size for buffering (MB)', defaultt=str(time_ram_size),type=xbmcgui.INPUT_NUMERIC)
400+
if sel_num >= 0:
401+
time_ram_size = sel_num
402+
param_update = '"ram_size":' + str(time_ram_size)
403+
if sel_param == 5:
404+
sel_enabled = dialog.select('Enable/Disable to use RAM only', list=enabledisable)
405+
if sel_enabled >= 0:
406+
time_ram_only = truefalse[sel_enabled]
407+
param_update = '"ram_only":' + time_ram_only
408+
if sel_param == 6:
409+
sel_enabled = dialog.select('Enable/Disable timeshift on-demand (no first rewind)', list=enabledisable)
410+
if sel_enabled >= 0:
411+
time_ondemand = truefalse[sel_enabled]
412+
param_update = '"ondemand":' + time_ondemand
413+
if sel_param == 7:
414+
sel_enabled = dialog.select('Enable/Disable unlimited time (may cause slowdown)', list=enabledisable)
415+
if sel_enabled >= 0:
416+
time_unlimited_period = truefalse[sel_enabled]
417+
param_update = '"unlimited_period":' + time_unlimited_period
418+
if sel_param == 8:
419+
sel_enabled = dialog.select('Enable/Disable unlimited size (uses all storage)', list=enabledisable)
420+
if sel_enabled >= 0:
421+
time_unlimited_size = truefalse[sel_enabled]
422+
param_update = '"unlimited_size":' + time_unlimited_size
423+
if sel_param == 9:
424+
sel_enabled = dialog.select('Enable/Disable fit to RAM (clears oldest buffer)', list=enabledisable)
425+
if sel_enabled >= 0:
426+
time_ram_fit = truefalse[sel_enabled]
427+
param_update = '"ram_fit":' + time_ram_fit
428+
if sel_param == 5:
429+
sel_enabled = dialog.select('Enable/Disable to include teletext data', list=enabledisable)
430+
if sel_enabled >= 0:
431+
time_teletext = truefalse[sel_enabled]
432+
param_update = '"teletext":' + time_teletext
433+
if param_update != "":
434+
param_url = 'http://' + tvh_url + ':' + tvh_port + '/api/timeshift/config/save?node={' + param_update + '}'
435+
param_save = requests.get(param_url)
436+
time_param_load(dvr_uuid_sel)
437+
348438
def muxes_load(net_uuid_sel):
349439
net_url = 'http://' + tvh_url + ':' + tvh_port + '/api/idnode/load?uuid=' + str(net_uuid_sel)
350440
net_load = requests.get(net_url).json()

resources/language/English/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
<string id="32023">Tvheadend Password</string>
99
<string id="32025">Tvheadend Paths</string>
1010
<string id="32030">DVR Recording Path</string>
11+
<string id="32035">Timeshift Buffer Path</string>
1112
</strings>

resources/settings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
<setting label="" type="lsep"/>
1010
<setting label="32025" type="lsep"/>
1111
<setting label="32030" type="folder" id="dvrstorage" default="" option="writeable"/>
12+
<setting label="32035" type="folder" id="timestorage" default="" option="writeable"/>
1213
</category>
1314
</settings>

0 commit comments

Comments
 (0)