$attributes['title'], 'category' => $attributes['group-title'] ?? 'General', 'poster_url' => $attributes['tvg-logo'] ?? '', 'stream_url' => $stream_url, ]; $i++; // Skip the next line as it's the URL } else { $malformed_entries++; } } } if (!empty($new_channels)) { $content_file = 'premium_content.json'; $existing_channels = []; if (!$overwrite && file_exists($content_file)) { $existing_content = json_decode(file_get_contents($content_file), true); if (is_array($existing_content)) { $existing_channels = $existing_content; } } $last_id = 0; if (!empty($existing_channels)) { $last_item = end($existing_channels); $last_id = $last_item['id'] ?? 0; } foreach($new_channels as &$channel) { $last_id++; $channel['id'] = $last_id; } $all_channels = array_merge($existing_channels, $new_channels); if (json_encode($all_channels, JSON_PRETTY_PRINT)) { file_put_contents($content_file, json_encode($all_channels, JSON_PRETTY_PRINT)); $message = 'Successfully uploaded and processed ' . count($new_channels) . ' new channels.'; if ($malformed_entries > 0) { $error = $malformed_entries . ' entries in your file were malformed and could not be imported.'; } } else { $error = 'Failed to encode data to JSON. Check for special characters.'; } } else { $error = 'No valid channel data found in the uploaded M3U file.'; if ($malformed_entries > 0) { $error .= ' All entries appear to be malformed.'; } } } } else { $error = 'File upload failed with error code: ' . $file['error']; } } ?> Admin - Upload M3U Playlist

Upload Premium Channels

Upload an M3U Playlist File

The file should be a valid M3U playlist (starting with #EXTM3U). The parser will attempt to extract channel information from #EXTINF lines.

If checked, all current premium channels will be replaced by the ones in this file. If unchecked, new channels will be added to the existing list.
Back to Admin