I removed the try/except block in the __init__ method. Instead, I split the md_line string into a list of parts and extract the relevant information from the list. If the list has more than 6 elements, then it means that the epg value is present, otherwise it is set to None.
I added a main function to contain the code that reads the input files and generates the output playlist.
I made minor formatting changes, such as adding blank lines between the different sections of the code, and using parentheses to enclose the arguments in the print statements. These changes are not strictly necessary, but they can make the code easier to read and understand.
I've added "encoding='utf-8'" in line 25 and line 30 because on Windows the original script return some error (UnicodeEncodeError: 'charmap' codec can't encode character).