Skip to content

Instantly share code, notes, and snippets.

@adrianmihalko
Created January 21, 2022 19:06
Show Gist options
  • Select an option

  • Save adrianmihalko/abd30eb6f3dd458d81b73c80885b52ae to your computer and use it in GitHub Desktop.

Select an option

Save adrianmihalko/abd30eb6f3dd458d81b73c80885b52ae to your computer and use it in GitHub Desktop.

Revisions

  1. adrianmihalko created this gist Jan 21, 2022.
    16 changes: 16 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    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)