Alpha - pvr.python - A PVR client supporting Python scripting

  Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
RunasSudo Offline
Junior Member
Posts: 16
Joined: Dec 2014
Reputation: 1
Brick  pvr.python - A PVR client supporting Python scripting
Post: #1
It looks like there hasn't been much movement in the other proof-of-concept Python-based PVR thread here, so I thought I'd throw my hat into the ring, since I've been interested in a Python-based PVR system for some time now, too.

pvr.python

A PVR client supporting Python scripting for Kodi

Github - Example

Unlike zcsizmadia's implementation, pvr.python does not require any changes to the Kodi source code. It is entirely self-contained within the single PVR addon shared library. The disadvantage of this is that Python PVR scripts cannot access the normal Kodi Python API, but this has not appeared to be a significant hindrance thus far.

The API is not at all robust or complete, but is sufficient for a Python re-implementation of the demo PVR addon. For more details, check the Github repository for the source code.

Screenshots
watch gallery
find quote
nickr Offline
Team-Kodi Member
Posts: 18,893
Joined: May 2009
Reputation: 388
Location: Christchurch NZ
Post: #2
Nice to see you doing this.

Question: do you have any proof of concept running a real PVR? I know you are in infancy, but I have my doubts about python being quick enough.

Pleased to test anything you have Smile

If I have helped you or increased your knowledge, click the 'thank user' button to give thanks :) (People with less than 20 posts won't see the "Thank you" button.)
find quote
RunasSudo Offline
Junior Member
Posts: 16
Joined: Dec 2014
Reputation: 1
Post: #3
(2016-12-24 10:03)nickr Wrote:  Nice to see you doing this.

Question: do you have any proof of concept running a real PVR? I know you are in infancy, but I have my doubts about python being quick enough.

No idea! In terms of proper PVR hardware, my understanding is that the PVR addon provides a software interface for controlling the PVR hardware, while the PVR hardware is ideally supposed to do most of the heavy lifting. Hence I would think that the Python layer wouldn't add too much of a performance hit. On the other hand, though, interfacing with hardware from Python may be a little tricky, so I would say that writing a native C addon is probably a much better bet for ordinary PVR addons.

In writing pvr.python, though, my interest was more in the direction of supplanting pvr.iptvsimple and friends, to access things like live TV streaming services. For such a use case, I think the penalty from going through Python would be fairly minimal, given that CPU usage is not usually a bottleneck in accessing online services.

That said, though, the only way to find out is to try! Hopefully I'll be able to put a usable interface to a real web service up in the next little while.
(This post was last modified: 2016-12-24 10:17 by RunasSudo.)
find quote
sarbes Offline
Team-Kodi Member
Posts: 383
Joined: Mar 2011
Reputation: 20
Post: #4
Wow, this is awesome. I'll write a proof of concept script in the next few days which aims to replace the iptvsimple add-on.

I should be able to write scrapers for the HbbTV EPGs of German public tv channels. They supply a better EPG over the Internet, compared to DVB-C/S/T (which is a shame). The timing is better, the guide gets quickly adjusted to chances in the program (overtime in football matches) and there are individual thumbnails for every show. Dash streams and dynamic stream urls (with tokens) should be possible too.
find quote
RunasSudo Offline
Junior Member
Posts: 16
Joined: Dec 2014
Reputation: 1
Post: #5
All right, I've implemented an example PVR in Python for the only online internationally-viewable free-to-air TV channel I could find, CCTV English: https://github.com/RunasSudo/pvr.python/...cctv-en.py

Unfortunately, since the servers are located in China, the performance is inherently not very good, so this doesn't appear to be a very good test. I'll look around for other things to try. Suggestions are welcome!
find quote
RunasSudo Offline
Junior Member
Posts: 16
Joined: Dec 2014
Reputation: 1
Post: #6
Merry Christmas, Kodi!

A quick progress update: I've now implemented an example Python PVR script for ABC (Australia) live streams of its TV channels, and I can report that despite unnecessarily juggling the video data between Python and C, it runs pretty well on my laptop. pvr.python also compiles on the Raspberry Pi Model B+ and runs the script correctly, albeit with more difficulty. I'm going to chalk this up to how exceptionally poorly my WiFi adapter performs on the Pi generally, though I'd welcome others' input on this matter.

(Unfortunately, unlike the CCTV stream, the ABC (Australia) live streams are geo-blocked. I hear that setting the *X-Forwarded-For* header to an Australian IP can help, but I've had a need to try.)
(This post was last modified: 2016-12-25 13:26 by RunasSudo.)
find quote
emilsvennesson Offline
Senior Member
Posts: 220
Joined: Mar 2011
Reputation: 20
Location: Sweden
Post: #7
This looks great! Is there any way to access the add-on settings as there's no way to use the Kodi modules?
find quote
RunasSudo Offline
Junior Member
Posts: 16
Joined: Dec 2014
Reputation: 1
Post: #8
(2016-12-27 15:08)emilsvennesson Wrote:  This looks great! Is there any way to access the add-on settings as there's no way to use the Kodi modules?

Kodi provides an XBMC->GetSetting API call to its addons, including PVR addons, which can be exposed to Python (see the bridge_ functions in client.cpp), so it should be possible.

It will be difficult to programmatically define the settings from Python, as they are usually hardcoded in settings.xml, but this appears to be possible based on rewriting settings.xml programmatically.
(This post was last modified: 2016-12-28 03:28 by RunasSudo.)
find quote
benmoran Offline
Junior Member
Posts: 4
Joined: Apr 2016
Reputation: 0
Post: #9
Thanks for your work on this. I will definitely be making use of it to put together my own backend.
find quote
cat_baxter Offline
Junior Member
Posts: 5
Joined: Nov 2014
Reputation: 0
Post: #10
Great job, RunasSudo! Thanks a lot!
find quote
tvking1905 Offline
Junior Member
Posts: 14
Joined: Jan 2014
Reputation: 0
Post: #11
Excellent Idea!

I am hopign to help develop with Kodi master from Git.

I fail to compile... It's because theres no information about this addon in: https://github.com/xbmc/repo-binary-addons After adding the info in, it compiles and all works OK! I can make a pull request to add this information into there? Or should we add this info into the pvr.python repo?


Also; when stopping a stream, Kodi quits with a Segmentation Fault... Any ideas?



PS compile log:

Code:
[email protected]:~/projects/kodi/pvr.python/build$ cmake -DADDONS_TO_BUILD=pvr.python -DADDON_SRC_PREFIX=../.. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=../../xbmc/addons -DPACKAGE_ZIP=1 ../../xbmc/cmake/addons
-- Addon source tarball caching is enabled
-- ZIP packaging enabled (destination: /home/chris/projects/kodi/pvr.python/build/build/zips)
-- Building following addons: pvr.python
-- Overriding addon source directory prefix: /home/chris/projects/kodi
--
-- ---- Preparing general dependencies ----
-- Processing /home/chris/projects/kodi/xbmc/cmake/addons/depends/common/kodi-platform/kodi-platform.txt
-- kodi-platform url: https://github.com/xbmc/kodi-platform
-- kodi-platform depends: tinyxml;p8-platform
-- Processing /home/chris/projects/kodi/xbmc/cmake/addons/depends/common/p8-platform/p8-platform.txt
-- p8-platform url: https://github.com/Pulse-Eight/platform.git
-- Processing /home/chris/projects/kodi/xbmc/cmake/addons/depends/common/tinyxml/tinyxml.txt
-- tinyxml url: http://mirrors.kodi.tv/build-deps/sources/tinyxml-2.6.2_2.tar.gz
-- No platform specific file /home/chris/projects/kodi/xbmc/cmake/addons/depends/linux/CMakeLists.txt found
-- Bootstrapping all default repositories as no addons were found...
-- The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is GNU 4.9.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Bootstrapping all repositories
-- Bootstrapping following addons: pvr.python
-- Bootstrapping addons from binary-addons (https://github.com/xbmc/repo-binary-addons.git master)...
-- Configuring done
-- Generating done
-- Build files have been written to: /home/chris/projects/kodi/pvr.python/build/build/bootstrap
Scanning dependencies of target binary-addons
[ 12%] Creating directories for 'binary-addons'
[ 25%] Performing download step (git clone) for 'binary-addons'
Cloning into 'binary-addons'...
Already on 'master'
Your branch is up-to-date with 'origin/master'.
[ 37%] No patch step for 'binary-addons'
[ 50%] Performing update step for 'binary-addons'
Current branch master is up to date.
[ 62%] No configure step for 'binary-addons'
[ 75%] No build step for 'binary-addons'
[ 87%] Performing install step for 'binary-addons'
-- Bootstrapping following addons: pvr.python
[100%] Completed 'binary-addons'
[100%] Built target binary-addons
CMake Error at CMakeLists.txt:220 (message):
  No addons available to be built


-- Configuring incomplete, errors occurred!
See also "/home/chris/projects/kodi/pvr.python/build/CMakeFiles/CMakeOutput.log".
(This post was last modified: 2017-01-13 18:43 by tvking1905.)
find quote
ivanr Offline
Junior Member
Posts: 1
Joined: Feb 2017
Reputation: 0
Post: #12
@RunasSudo is it possible to add lists with a Reference for a link? (similar to way in which LiveStreamsPro works). If so, could you add an example in the GitHub project or here? Thanks!
(This post was last modified: 2017-06-22 16:47 by ivanr.)
find quote
nmw01223 Offline
Junior Member
Posts: 36
Joined: Aug 2015
Reputation: 0
Post: #13
(2017-01-12 22:36)tvking1905 Wrote:  I fail to compile... It's because theres no information about this addon in: https://github.com/xbmc/repo-binary-addons After adding the info in, it compiles and all works OK! I can make a pull request to add this information into there? Or should we add this info into the pvr.python repo?

I've got a C++ Linux backend I've written which works OK, and am looking to hook it into Kodi as well (I currently use Kodi with MythTV), and if it can be done, then I guess python is a much better bet than native C++ which would have to be built for every target system, which I guess would not apply to python (I've got Windows, Linux and Android Kodi's around).

I see the queries above about performance, I guess the answer is quite right, though the only area where I see there might be performance issues would be stream reading. It would be better if Kodi could just be pointed to a stream file from the backend to read it directly. There does appear to be some mechanism like that, though it appears to be about to be depreciated.

Anyway, main point: I've got the same problem as above - couldn't get it to build. What info did you add to where? (I have never seen cmake before last week, and have no knowledge of how the Kodi build process worked). To be quite honest - never used python yet either.

Actually, a pointer to any information on how to get all this going would be great. The above seems to imply you cannot just create your Kodi addon locally yourself - in some way it has to be part of the main Kodi build process?
find quote
leandrotsampa Offline
Junior Member
Posts: 4
Joined: Jul 2015
Reputation: 0
Shocked  RE: pvr.python - A PVR client supporting Python scripting
Post: #14
Wow, great job my friend.
I will try use Big Grin
find quote
leandrotsampa Offline
Junior Member
Posts: 4
Joined: Jul 2015
Reputation: 0
Post: #15
Hi, I'm trying cross-compile for Android.
But allways get this error:

12:44:28.110 T:547594200144 ERROR: Unable to load /storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/pvr.python/libpvr.python.so, reason: dlopen failed: library "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/pvr.python/libpvr.python.so" needed or dlopened by "/data/app/org.xbmc.kodi-2/lib/arm64/libkodi.so" is not accessible for the namespace "classloader-namespace"

12:44:29.979 T:547594200144 ERROR: UpdateAddons - failed to create add-on PVR Python Client, status = 6

Any idea about this?
find quote
Post Reply