Simple channel zapping in Python help please!

  • Hello,


    I am writing a plugin for the Dreambox DM7025+ (E2), but need some help.


    I wish to change (zap) TV channels, but need a simplied Python way to perform this operation using a single Bouquet (Favourites).


    I have looked at other plugin examples but are finding it difficult to reverse-engineer the functionality of the zap, services, etc, as they work with the EPG which adds complexity :(


    Can anyone help with guidance, or preferably an example Python subroutine to achieve this operation?


    Many thanks in advance.


    Regards,
    Andrew.

  • well in General it's pretty easy to zap.
    You can simply use:


    self.session.nav.playService(serviceReference)


    where serviceReference must be a valid enigma2 Service Reference.


    I'll post a slightly simpliflied example using Webinterface Sources:



    if you have specific questions don't hesitate to ask!

    mfg ,
    Reichi

  • Hello Reichi,


    Thanks for the reply to my post, and the code example.


    I'm a newbie writing for E2. I've not experimented with the E2 services before so forgive the stupid questions ;)


    The example looks similar to the code used in the webif.py. I've embedded this code into my program, it compiles OK and are getting valid objects for fav, SwitchService and ServiceList.


    fav = <enigma.eServiceReference; proxy of <Swig Object of type 'eServiceReference *' at 0x10788588>
    self["SwitchService"] = <Components.Sources.ServiceList.ServiceList object at 0x2edeb9f0>
    self["ServiceList"] = <Components.Sources.ServiceList.ServiceList object at 0x2edeba10>


    From there I get lost. I guess I have to call the zapTo function with a serviceReference (fav?) to change the channel.


    How do I specify the TV channel in the serviceReference (by channel name, channel number, or by index in a list?)


    Many thanks,
    Andrew.

  • ok, self["ServiceList"] is a pythonlist filled with "User defined TV Bouquets"-Tuples.
    If you don't know the difference between python lists and python tuples you should ask google for that as python works a little different than you might know from other languages (especially scripting languages like php).


    You have to get e.g. the first Bouquet and use it's ref to get a new Servicelist which then will contain the actual "tunable Services" (again you will run into tuples there).


    you should try pprint to see the actual content ob objects, lists and tuples.
    On dreamboxes it's not installed by default so you will have to do that manually (it's available by online update so no big deal there).

    Code
    ipkg update && ipkg list|grep pprint

    should tell you what to install ;).
    This will give a way better overview what all the data looks like.


    Another thing:


    I know you are just "messing around" right now so it doesn't matter yet but you should replace the self["ServiceList"]-styled stuff if there are no "GUI Elements" involved.
    Stick to real variables like self.ServiceList style instead.


    self[""] always tells you are actually working with a gui- or a webinterface-content component.


    Enigma2 is pretty big and at the very beginning it can be hard to understand the whole concept but once you got it it's really consistent, flexible and pretty easy to extend.


    Oh... and the Webinterface is really not the easiest example code to dive into enigma2... it does some pretty crazy stuff, at least for a "newbie".

    mfg ,
    Reichi

    Edited 3 times, last by Reichi ().

  • Hello Reichi,


    Yes, still finding my way around Python. My background is C++.


    My development environment is a bit basic, making it difficult to explore the data structures of E2.


    This is my setup:
    Oozoon img.
    WPython for Windows (I use the IDLE editor to write code)
    DCC for Dreambox control
    Interrogate error logs through the /media/hdd directory (enigma2_crash_xxxxxxxx) when problems.
    Use serial port for passing simple debug messages (PySerial) back to the PC.


    Can you recommend what type of debug enviroment the developer guys are using for writing plugins? There must be a better way :)


    Typed "ipkg update && ipkg list|grep pprint" through TelNet to Dreambox. It went through the update process OK.


    I had seen print statements in Python code but unsure where they output to, possibly to a std output or a log file?


    Many thanks again,
    Andrew.

  • ipkg install package


    where package is the name of the package the command shows.
    from pprint import pprint.


    pprint(list)


    there actually is a python debugger but i've never tried it... i'm debugging by print-output...

    mfg ,
    Reichi

  • Hello Reichi,


    Have installed PPrint. Thanks for the guidance.


    Tried to analyse the following objects:


    Code
    fav = eServiceReference('1:7:1:0:0:0:0:0:0:0:(type == 1) || (type == 17) || (type == 195) || (type == 25) FROM BOUQUET "bouquets.tv" ORDER BY bouquet')
    
    
    self["SwitchService"] = ServiceList(fav, command_func = self.zapTo, validate_commands=False)
    
    
    self["ServiceList"] = ServiceList(fav, command_func = self.getServiceList, validate_commands=False)


    My pprint calls (ser_this is my serial port; set depth to 10):

    Code
    pprint(fav, ser_this, 1, 80, 10)
    pprint(self["SwitchService"], ser_this, 1, 80, 10)
    pprint(self["ServiceList"], ser_this, 1, 80, 10)


    Results:

    Code
    fav  = <enigma.eServiceReference; proxy of <Swig Object of type 'eServiceReference *' at 0x1099a510> >
    
    
    self["ServiceList"] = <Components.Sources.ServiceList.ServiceList object at 0x2d7cb3d0>
    
    
    self["ServiceList"] = <Components.Sources.ServiceList.ServiceList object at 0x2d7cb3f0>


    I've tried varying depth values but with no change to the results. Cannot get it to disassemble the list/tuple structure in more detail ?(


    I've done a sanity test with the following test routine:

    Code
    stuff = sys.path[:]
    stuff.insert(0, stuff[:])
    pprint(stuff, ser_this, 1, 80, 4)


    This prints the system paths OK, So I assume pprint installed & working OK.


    Any help will be appreciated :)


    Regards,
    Andrew.

    Edited once, last by vxdandy ().

  • Hi everyone, I apologize if I write on this very old thread, but I would need a hand to finish building a plugin. I created a plugin that searches for channels in bouquets (especially in bouquets of wave channels), and the only thing I can't do (for the moment 😅) is redirect to the channel found. once the search is done, the script produces a list: Channel title found (visible), and as a selection the reference value (#service 1: 0: 0: 0 :). When I click on the channel of my interest it gives me this error:


    Code
    - {E} /usr/lib/python2.7/site-packages/twisted/python/util.py:815 untilConcludes 2021-02-28 21: 27: 36 + 0100  [-] TypeError: in method 'eServiceReference___eq__', argument 2 of type 'eServiceReference const &'
    - python / python.cpp: 210 call [ePyObject] (PyObject_CallObject (<bound method ActionMap.action of <Components.ActionMap.ActionMap instance at 0xb257b878 >>, ('SetupActions', 'ok')  ) failed)


    What am I doing wrong? Thank you


    This is my code:

    This is the function that is called when I do the search.

    This is the function of my class (which generates another screen with a list of results) and here is the error:

    Edited 2 times, last by aldobel ().