Welcome to World of IPTV

With

+23k members
+11k threads
+106k posts

we are the most popular IPTV community on the web. 

IMPORTANT NOTE:
WE HAVE RECENTLY NOTICED THAT TOO MANY DOUBLE FAKE ACCOUNTS ARE CREATED IN THE PAST.
TO PREVENT THIS ISSUE THE DECISION WAS MADE THAT IN THE FUTURE A ANNUALLY FEE 20 EURO WILL BE RAISED FOR NEW MEMBERSHIPS.

Join now to the World of IPTV

Forum Rules

Before you start, check out the forum rules first

Account upgrade

Upgrade your account to get access to full features

Advertising

Would you like to place your advertisement with us ?

Resources Manager

Hundreds of IPTV scripts and apps are available for download

Tutorial Export m3u base on catigory

gzowner

Extended Member
Ext. Member
Joined
Mar 14, 2020
Messages
160
Reaction score
342
Points
74
Location
home
make a php file and input the following code. Edit line 3 with your m3u file. This will export the line into its own categories.
<?php

// Define the file path of the M3U playlist
$m3u_file_path = 'path/to/playlist.m3u';

// Define the output directory path where the category-based playlists will be saved
$output_directory_path = 'output/';

// Read the contents of the M3U playlist into a variable
$m3u_content = file_get_contents($m3u_file_path);

// Split the M3U content into an array of lines
$m3u_lines = explode("\n", $m3u_content);

// Initialize an array to store the category-based playlists
$category_playlists = array();

// Loop through the array of M3U lines and create a separate M3U playlist file for each category
foreach ($m3u_lines as $line) {
if (strpos($line, '#EXTINF') === 0) {
$category = getCategoryFromLine($line);
if (!isset($category_playlists[$category])) {
$category_playlists[$category] = "#EXTM3U\n\n";
}
$category_playlists[$category] .= "{$line}\n";
} elseif (strpos($line, '#EXTM3U') === false) {
$category_playlists[$category] .= "{$line}\n";
}
}

// Loop through the array of category-based playlists and save each one to a separate file in the output directory
foreach ($category_playlists as $category => $playlist_data) {
// Define the output file path
$output_file_path = $output_directory_path . $category . '.m3u';

// Save the playlist data to the output file, overwriting any existing file
file_put_contents($output_file_path, $playlist_data, FILE_APPEND | LOCK_EX);
}

// Function to extract the category from an M3U line that starts with #EXTINF
function getCategoryFromLine($line) {
$start = strpos($line, 'group-title="') + 13;
$end = strpos($line, '"', $start);
return substr($line, $start, $end - $start);
}
 

darllanfavero

Basic Member
Basic Member
Ext. Member
Joined
Nov 18, 2023
Messages
12
Reaction score
3
Points
14
Location
Brazil
scrypt python

Python:
import os

def getCategoryFromLine(line):
    start = line.find('group-title="') + 13
    end = line.find('"', start)
    return line[start:end]

# Define the file path of the M3U playlist
m3u_file_path = 'movies.m3u'

# Define the output directory path where the category-based playlists will be saved
output_directory_path = 'output/'

# Read the contents of the M3U playlist into a variable
with open('movies.m3u', 'r', errors='ignore') as f:
    m3u_content = f.read()


# Split the M3U content into an array of lines
m3u_lines = m3u_content.split('\n')

# Initialize a dictionary to store the category-based playlists
category_playlists = {}

# Loop through the array of M3U lines and create a separate M3U playlist file for each category
category = None
for line in m3u_lines:
    if line.startswith('#EXTINF'):
        category = getCategoryFromLine(line)
        if category not in category_playlists:
            category_playlists[category] = "#EXTM3U\n\n"
        category_playlists[category] += line + "\n"
    elif not line.startswith('#EXTM3U') and category is not None:
        category_playlists[category] += line + "\n"

# Loop through the dictionary of category-based playlists and save each one to a separate file in the output directory
for category, playlist_data in category_playlists.items():
    # Replace the '|' character with '_'
    safe_category = category.replace('|', '_')

    # Define the output file path
    output_file_path = os.path.join(output_directory_path, safe_category + '.m3u')

    # Save the playlist data to the output file, overwriting any existing file
    with open(output_file_path, 'w') as f:
        f.write(playlist_data)
 
shape1
shape2
shape3
shape4
shape5
shape6
Top
AdBlock Detected

We know, ad-blocking software do a great job at blocking ads. But our site is sponsored by advertising. 

For the best possible site experience please take a moment to disable your AdBlocker.
You can create a Account with us or if you already have account, you can prefer an Account Upgrade.

I've Disabled AdBlock