Created
January 21, 2022 19:06
-
-
Save adrianmihalko/abd30eb6f3dd458d81b73c80885b52ae to your computer and use it in GitHub Desktop.
Fix empty tvg-name for IPTV playlist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If for some reason you got an IPTV playlist which has empty tvg-name, but actual channel names are exists at the end of line, example: | |
#EXTINF:-1 tvg-id="none" tvg-name="none" tvg-logo="" group-title="Testing", Test_Title_CC (GER) | |
#EXTINF:-1 tvg-id="none" tvg-name="none" tvg-logo="" group-title="Testing", Cup Mus (GER) | |
#EXTINF:-1 tvg-id="none" tvg-name="New World (NED)" tvg-logo="" group-title="Apple", New World (NED) | |
you can use awk to fix this issue: | |
awk 'BEGIN{FS=", "}/^#EXTINF:-1/&&/tvg-name="none"/{sub(/tvg-name="none"/,"tvg-name=\x22" $NF "\x22")}{print}' file.txt | |
example output: | |
#EXTINF:-1 tvg-id="none" tvg-name="Test_Title_CC (GER)" tvg-logo="" group-title="Testing", Test_Title_CC (GER) | |
#EXTINF:-1 tvg-id="none" tvg-name="Cup Mus (GER)" tvg-logo="" group-title="Testing", Cup Mus (GER) | |
#EXTINF:-1 tvg-id="none" tvg-name="New World (NED)" tvg-logo="" group-title="Apple", New World (NED) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment