Kodi Community Forum

Full Version: IPTV Recorder
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I done multiple tests, it works with some date but not with some others

I tried to hardcode with 2018-03-25 02:00:00 giving the following tupple : (2018, 3, 25, 2, 0, 0, 6, 84, -1)

Code:
time.mktime((2018, 3, 25, 2, 0, 0, 6, 84, -1))

On my PC this line is working, but not in the box, maybe relative to python's version ?

Code:
Error Contents: mktime argument out of range

Kodi : 17.6
Android : 6.0.1
That is quite a bizarre bug in Android.
On the next release I'm totally bypassing the jsonrpc calls and grabbing all the data from the xmltv file.
Hopefully there is a way to not use that time conversion.
The code is in the db branch on github if you want a preview.
I think this db branch is about ready to release but I'll sleep on it and see if I can deal with the spaces and timetamp problems before I do.
I fixed the timestamp with the following code :


def utc2local (utc):
    now = time.time()
    offset = datetime.fromtimestamp(now) - datetime.utcfromtimestamp(now)
    return utc + offset

But now I have another issue when the record starts :

Code:

23:02:41.573 T:18446744072910272816  NOTICE: [xbmcswift2] Request for "/broadcast/1/MyChannel/MyProgram/2018-03-24+21%3A35%3A00/2018-03-24+22%3A30%3A00" matches rule for function "broadcast"
23:02:41.578 T:18446744072910272816 WARNING: [xbmcswift2] No converter provided, unicode should be used, but returning str value
23:02:44.331 T:18446744072910272816 WARNING: Previous line repeats 2 times.
23:02:44.331 T:18446744072910272816  NOTICE: [xbmcswift2] Request for "/record_once/MyChannel/MyProgram/2018-03-24+21%3A35%3A00/2018-03-24+22%3A30%3A00" matches rule for function "record_once"
23:02:44.612 T:18446744072910272816 WARNING: [xbmcswift2] No converter provided, unicode should be used, but returning str value
23:02:44.645 T:18446744073432856880 WARNING: Previous line repeats 3 times.
23:02:44.645 T:18446744073432856880   ERROR: GetDirectory - Error getting plugin://plugin.video.iptv.recorder/record_once/MyChannel/MyProgram/2018-03-24+21%3A35%3A00/2018-03-24+22%3A30%3A00
23:02:44.649 T:18446744073432856880   ERROR: CGUIMediaWindow::GetDirectory(plugin://plugin.video.iptv.recorder/record_once/MyChannel/MyProgram/2018-03-24+21%3A35%3A00/2018-03-24+22%3A30%3A00) failed
23:03:09.496 T:18446744072910272816  NOTICE: [xbmcswift2] Request for "/record_once/MyChannel/MyProgram/2018-03-24+21%3A35%3A00/2018-03-24+22%3A30%3A00" matches rule for function "record_once"
23:03:09.769 T:18446744072910272816 WARNING: [xbmcswift2] No converter provided, unicode should be used, but returning str value
23:03:23.521 T:18446744072896903472 WARNING: Previous line repeats 3 times.
23:03:23.521 T:18446744072896903472 WARNING: CPythonInvoker(34): Script invoked without an addon. Adding all addon modules installed to python path as fallback. This behaviour will be removed in future version.
23:03:24.793 T:18446744072896903472   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.OSError'>
                                            Error Contents: [Errno 13] Permission denied
                                            Traceback (most recent call last):
                                              File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/userdata/addon_data/plugin.video.iptv.recorder/jobs/2bac69f0-2faf-11e8-9f7b-19e8357f1bb0.py", line 3, in <module>
                                                subprocess.call(probe_cmd,shell=False)
                                              File "/home/jenkins/workspace/Android-ARM/tools/depends/xbmc-depends/arm-linux-androideabi-android-21/lib/python2.7/subprocess.py", line 523, in call
                                              File "/home/jenkins/workspace/Android-ARM/tools/depends/xbmc-depends/arm-linux-androideabi-android-21/lib/python2.7/subprocess.py", line 711, in __init__
                                              File "/home/jenkins/workspace/Android-ARM/tools/depends/xbmc-depends/arm-linux-androideabi-android-21/lib/python2.7/subprocess.py", line 1343, in _execute_child
                                            OSError: [Errno 13] Permission denied
                                            -->End of Python script error report<--
23:03:24.883 T:18446744072881699120  NOTICE: [xbmcswift2] Request for "/broadcast/1/MyChannel/MyProgram/2018-03-24+21%3A35%3A00/2018-03-24+22%3A30%3A00" matches rule for function "broadcast"
23:03:24.887 T:18446744072881699120 WARNING: [xbmcswift2] No converter provided, unicode should be used, but returning str value
23:03:24.963 T:18446744073432856880 WARNING: Previous line repeats 2 times.
23:03:24.963 T:18446744073432856880   ERROR: GetDirectory - Error getting plugin://plugin.video.iptv.recorder/record_once/MyChannel/MyProgram/2018-03-24+21%3A35%3A00/2018-03-24+22%3A30%3A00
23:03:24.967 T:18446744073432856880   ERROR: CGUIMediaWindow::GetDirectory(plugin://plugin.video.iptv.recorder/record_once/MyChannel/MyProgram/2018-03-24+21%3A35%3A00/2018-03-24+22%3A30%3A00) failed
Good work. If you want to add in pull requests I'd be grateful. I'm working on the db branch for the next release.

Check that the job file is pointing to the /data/data directory for the ffmpeg program.
/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/userdata/addon_data/plugin.video.iptv.recorder/jobs/2bac69f0-2faf-11e8-9f7b-19e8357f1bb0.py

It should have copied ffmpeg to the right place and made it executable here:
https://github.com/primaeval/plugin.vide...in.py#L308

It works ok for me but there can be lots of variations in the android world.
Using now() won't quite work as the utc2local function might be converting a time that is after summer time changes but now is still in winter time.
What about this one ? Working for me and should be compatible


def utc2local(utc):
    timestamp = calendar.timegm(utc.timetuple())
    local = datetime.fromtimestamp(timestamp)
    return local.replace(microsecond=utc.microsecond)

The job is correctly pointing to "/data/data/org.xbmc.kodi/ffmpeg", but I cannot access to /data directory, permission denied
for me everything works great as long as i keep my tags clean:
Quote:#EXTINF:-1 tvg-id="Nova_TV" tvg-name="Nova TV" tvg-logo="" group-title="",Nova TV
if the guide contains id with a space like "Nova TV", then i must have tvg-id="Nova_TV" and not with a space in the m3u for it to work properly. any space must be replaced by _
Quote:#EXTINF:-1,Nova TV
wouldn't work in that case. the tvg-id"" must be named correctly.
(2018-03-25, 03:12)Chychy Wrote: [ -> ]What about this one ? Working for me and should be compatible


def utc2local(utc):
    timestamp = calendar.timegm(utc.timetuple())
    local = datetime.fromtimestamp(timestamp)
    return local.replace(microsecond=utc.microsecond)

The job is correctly pointing to "/data/data/org.xbmc.kodi/ffmpeg", but I cannot access to /data directory, permission denied
 Thanks. It worked for me on a Nvidia Shield which isn't rooted.
Try putting a log message around here to see what the st.st_mode is.
https://github.com/primaeval/plugin.vide...in.py#L305
I presume the permission error is with ffmpeg but it might not be.
Warning! The new db version is going to start again with recording jobs and rules.
Does anyone need me to write a converter for your old jobs?
(2018-03-25, 03:47)ray2301 Wrote: [ -> ]for me everything works great as long as i keep my tags clean:
Quote:#EXTINF:-1 tvg-id="Nova_TV" tvg-name="Nova TV" tvg-logo="" group-title="",Nova TV
if the guide contains id with a space like "Nova TV", then i must have tvg-id="Nova_TV" and not with a space in the m3u for it to work properly. any space must be replaced by _
Quote:#EXTINF:-1,Nova TV
wouldn't work in that case. the tvg-id"" must be named correctly. 
 I've added in a fix in the new db version which can handle spaces and missing tvg_id fields as long as the channel name matches the xmltv channel id.
I'll release it later.
Looks like it doesn't enter in the if condition, but I guess it should as it's not executable by default (600)

log(st.st_mode) # 33152 -> 100 600
log(st.st_mode | stat.S_IEXEC) # 33216 -> 100 700
if not (st.st_mode | stat.S_IEXEC):
    log('if?')

EDIT: Working for me with this condition :

if not (stat.S_IXUSR & st.st_mode):
Thanks. This is probably why.

Code:
S_IXUSR
S_IEXEC

Execute (for ordinary files) or search (for directories) permission bit for the owner of the file. Usually 0100. S_IEXEC is an obsolete synonym provided for BSD compatibility.
https://www.gnu.org/software/libc/manual...-Bits.html
Do you want a PR for both modifications ?

Now I launched a record job with no error, but I think it's not recording (no file in destination directory, maybe the file is in cache until it's finished ?)
And looks like the UTC date is unsed under the job menu, for a program starting at 11:20 (local time +2), I see 09:20, could be related ?
I've added in those changes already so its ok.
Anything bigger would be good as a pull request.

Are you testing with the released version or my db branch?

It would be best to test the new db version so I can release it soon.

What are the dates like in your xmltv file? What timezone are they from?
Mine are in UTC +0000 so that might be why I don't see any problems.

You could try something instead of ffmpeg to debug whether it ran or not.
I usually use notepad on Windows. I'm not sure what would work on Android.
https://github.com/primaeval/plugin.vide...in.py#L377