Add ISO 3166-1 alpha-2 country codes via tvg-country attribute
to all #EXTINF lines, enabling IPTV players to filter and display
channels by country.
Co-authored-by: Kálmán „KAMI” Szalai <kami911gmail.com>
* Improve make_playlist.py code quality and fix bugs
- Fix group name bug: replace underscores with spaces before title()
so filenames like north_korea.md produce "North Korea" not "North_Korea"
- Fix resource leaks: use context managers for all file handles including
EPG list and per-country playlist files
- Remove os.chdir() global side effect: use absolute paths derived from
the script location instead
- Avoid calling to_m3u_line() twice per channel by caching the result
- Fix redundant trailing colon in filename[:-3:] slice
- Consistent use of write() for headers instead of mixing print/write
- Strip blank lines from EPG URL list when reading
* Skip commit and push when playlist has no changes
Prevents the workflow from failing with exit code 1 when the generated
playlist is identical to the previous run and there is nothing to commit.
* Use current branch instead of hardcoded master for push
Replace hardcoded origin/master reference with @{u} (upstream of current
branch) for the diff check, and use HEAD for the push target so the
workflow works correctly on any branch.
---------
Co-authored-by: Kálmán „KAMI” Szalai <kami911gmail.com>
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).