betonme / e2openplugin-EnhancedMovieCenter

EMC is an enhanced movielist replacement for Linux based receivers.
36 stars 61 forks source link

Reuse of EitSupport as standalone application #274

Open WolfgangFahl opened 3 years ago

WolfgangFahl commented 3 years ago

Thank you for your great software. I have been using an extract of your software for EIT parsing since 2016. I am now in the process of creating a standalone version and would love to make sure that the standalone version can stay in sync with your original code.

For python3 the byte handling seems to need to be modified. Please find my changes at:

https://github.com/WolfgangFahl/eitparser/blob/main/eit/eitparser.py

I'd appreciate some feedback whether the code could be changed to a common base class used by both projects. I'd like to avoid the dependencies

#from Components.config import config
#from Components.Language import language
#from EMCTasker import emcDebugOut
#from IsoFileSupport import IsoSupport

and for that only minor changes where necessary. I also added a main function and some static methods.

dhwz commented 3 years ago

This is not matching our current code, there is a lot of wrong and obsolete code in your code.

WolfgangFahl commented 3 years ago

I in the process of refactoring and suggest using something like:

class Event(object):

    def __init__(self,name):
        self.name=name
        self.descriptor = []

        self.descriptor_multi = []
        self.codepage = None

    def readDescription(self,data,pos,lenOfs,startOfs):
        '''
        read my description
        '''
        event_name_length = bord(data[pos+lenOfs])
        self.description= Bytes()
        for i in range (pos+startOfs,pos+startOfs+event_name_length):
            try:
                if str(bord(data[i]))=="10" or int(str(bord(data[i])))>31:
                    self.description.add(data[i])
            except IndexError as e:
                emcDebugOut("[META] Exception in readEitFile: " + str(e))

    def readCodePage(self,data,pos,startOfs):
        if not self.codepage:
            try:
                byte1 = str(bord(data[pos+startOfs]))
            except:
                byte1 = ''
            if byte1=="1": self.codepage = 'iso-8859-5'
            elif byte1=="2": self.codepage = 'iso-8859-6'
            elif byte1=="3": self.codepage = 'iso-8859-7'
            elif byte1=="4": self.codepage = 'iso-8859-8'
            elif byte1=="5": self.codepage = 'iso-8859-9'
            elif byte1=="6": self.codepage = 'iso-8859-10'
            elif byte1=="7": self.codepage = 'iso-8859-11'
            elif byte1=="9": self.codepage = 'iso-8859-13'
            elif byte1=="10": self.codepage = 'iso-8859-14'
            elif byte1=="11": self.codepage = 'iso-8859-15'
            elif byte1=="21": self.codepage = 'utf-8'
            if self.codepage:
                emcDebugOut("[META] Found name_event encoding-type: " + self.codepage)

please stay tuned for the next commit

WolfgangFahl commented 3 years ago

https://github.com/WolfgangFahl/eitparser/commit/b72cc5e5772690e802c3ccc7b5e3b3e98e5590c2 has a refactoring state that is close to what i am up to. It uses a Bytes and Event class and makes debugging simpler.

WolfgangFahl commented 3 years ago

https://pypi.org/project/eitparser/ version 0.0.1 is out now. It passes the testing against the 392 eit files from my Vu+ Duo² I'd need a proper set of eit files for testing it with all possible encodings and there is lots more todo.