How the Free-TV IPTV Script Handles Valid vs Invalid Channel URLs in Playlists

The script filters playlist entries by scanning each line for the literal string [>], processing only lines containing this marker into M3U playlists while silently skipping any line marked with [x] or lacking the validation marker.

The Free-TV/IPTV repository automates playlist generation through make_playlist.py, which parses markdown files in the lists/ directory to produce country-specific and master M3U playlists. Understanding how this script distinguishes between functional channels and broken links is essential for contributors maintaining the channel database.

Line-by-Line Validation Logic

The core filtering mechanism resides in make_playlist.py between lines 49-55. As the script iterates through each markdown file, it evaluates every line to determine if it represents a valid channel entry.

for line in markup_file:
    if "[>]" not in line:
        continue                # ← skip any line that isn’t marked as a valid entry

    channel = Channel(group, line, country_code)
    …

This simple string-check acts as the primary gatekeeper. Lines containing [>] proceed to the Channel class constructor for processing, while lines containing [x] or missing the marker entirely trigger the continue statement, causing the loop to skip them without logging or output.

Processing Valid [>] Channel Entries

When a line passes the [>] filter, the script processes it through the Channel class instantiation (lines 94-105) and subsequent M3U formatting.

Data Extraction and Object Creation

The Channel class constructor parses the markdown table row to extract:

  • Channel number and display name
  • Stream URL (the value inside parentheses following [>])
  • Logo URL from the image tag
  • Optional EPG identifier from the anchor tag

M3U Playlist Generation

After extraction, the to_m3u_line() method formats the channel data into standard #EXTINF format. According to the source code, the script writes these entries to two locations:

  • playlist.m3u8 — the consolidated master playlist
  • playlists/playlist_<country>.m3u8 — country-specific filtered lists

Only channels explicitly marked with [>] appear in these output files.

How Invalid [x] Entries Are Discarded

The script treats any line without the [>] marker as invalid. When encountering [x] markers (indicating dead or problematic streams), the condition if "[>]" not in line: evaluates to True, executing continue immediately. This means:

  • No Channel object is instantiated
  • No output is written to any M3U file
  • No error log is generated (silent exclusion)

Practical Examples

Valid Channel Line (Processed)

|1|BBC News|[>](http://example.com/stream.m3u8) |<img src="https://example.com/logo.png"/>|<a href="epg_id">EPG</a>

The script detects [>] at line 49, extracts http://example.com/stream.m3u8, and generates this M3U output via Channel.to_m3u_line():

#EXTINF:-1 group-title="News" tvg-logo="https://example.com/logo.png" tvg-id="epg_id",BBC News
http://example.com/stream.m3u8

Invalid Channel Line (Ignored)

|2|Fake TV|[x](http://invalid.com/stream.m3u8) |<img src="https://example.com/fake.png"/>

Because this line contains [x] instead of [>], the continue statement at line 51 skips it entirely. The URL http://invalid.com/stream.m3u8 never appears in any generated playlist, and no error is recorded.

Summary

  • The script validates channels using a simple string filter checking for [>] in each line of markdown files located in the lists/ directory.
  • Valid entries instantiate Channel objects (lines 94-105) that extract URLs, logos, and EPG data before formatting them into #EXTINF lines via to_m3u_line().
  • Invalid entries marked with [x] or lacking markers are silently skipped via the continue statement in make_playlist.py lines 49-55.
  • Output generates both a master playlist.m3u8 and country-specific playlist_<country>.m3u8 files containing only validated streams.

Frequently Asked Questions

Why does the script use [>] and [x] markers instead of checking if URLs are reachable?

The Free-TV/IPTV repository uses static markdown files as the source of truth. The [>] marker indicates human-verified working channels, while [x] marks known broken or geo-blocked streams. This approach avoids runtime network validation, making playlist generation fast and deterministic according to the repository's design.

What happens if a line contains both [>] and [x] markers?

According to the logic in make_playlist.py, the script only checks if [>] is present in the line at line 49. If found, the line is processed regardless of other content. However, standard practice in the repository is to use exclusively one marker to maintain clarity and predictable behavior.

How can I convert an [x] entry back to a valid [>] channel?

Edit the corresponding markdown file in the lists/ directory, replacing [x] with [>] while ensuring the parenthetical URL is correct and functional. The next execution of make_playlist.py will automatically include the channel in the generated playlists.

Does the script log skipped invalid entries?

No. The continue statement at line 51 of make_playlist.py silently skips invalid lines without writing to stderr or a log file. The script is designed to be quiet about exclusions, producing clean M3U files containing only valid channels.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →