103 lines
3.8 KiB
PHP
103 lines
3.8 KiB
PHP
<?php
|
|
|
|
$playlist_url = $_GET['url'] ?? null;
|
|
|
|
if (!$playlist_url) {
|
|
header('Location: index.php');
|
|
exit;
|
|
}
|
|
|
|
function parse_m3u($content) {
|
|
$channels = [];
|
|
$lines = explode("\n", $content);
|
|
$channel_info = null;
|
|
|
|
foreach ($lines as $line) {
|
|
$line = trim($line);
|
|
if (empty($line)) continue;
|
|
|
|
if (strpos($line, '#EXTINF') === 0) {
|
|
preg_match('/(?<=tvg-name=").*?(?=")/', $line, $name_match);
|
|
preg_match('/(?<=tvg-logo=").*?(?=")/', $line, $logo_match);
|
|
$title = empty($name_match) ? substr(strrchr($line, ","), 1) : $name_match[0];
|
|
|
|
$channel_info = [
|
|
'name' => $title,
|
|
'logo' => empty($logo_match) ? 'https://via.placeholder.com/150' : $logo_match[0]
|
|
];
|
|
} elseif ($channel_info && strpos($line, 'http') === 0) {
|
|
$channel_info['url'] = $line;
|
|
$channels[] = $channel_info;
|
|
$channel_info = null;
|
|
}
|
|
}
|
|
return $channels;
|
|
}
|
|
|
|
$m3u_content = file_get_contents($playlist_url);
|
|
$channels = parse_m3u($m3u_content);
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Player - gomoviz.asia</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
|
<style>
|
|
body, html { height: 100%; }
|
|
.player-wrapper { display: flex; height: 100vh; }
|
|
.channel-sidebar { width: 300px; background-color: #1E1E1E; overflow-y: auto; height: 100%; }
|
|
.player-main { flex-grow: 1; background-color: #000; display: flex; align-items: center; justify-content: center; }
|
|
#video-player { width: 100%; height: 100%; }
|
|
.channel-item { display: flex; align-items: center; padding: 10px; cursor: pointer; border-bottom: 1px solid #333; }
|
|
.channel-item:hover { background-color: #2F2F2F; }
|
|
.channel-item img { width: 50px; height: 50px; border-radius: 50%; margin-right: 15px; }
|
|
.channel-item span { color: #E0E0E0; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="player-wrapper">
|
|
<div class="channel-sidebar">
|
|
<div class="p-3 text-center">
|
|
<a class="navbar-brand fw-bold" href="index.php">gomoviz.asia</a>
|
|
</div>
|
|
<div id="channel-list">
|
|
<?php foreach ($channels as $channel): ?>
|
|
<div class="channel-item" data-url="<?php echo htmlspecialchars($channel['url']); ?>">
|
|
<img src="<?php echo htmlspecialchars($channel['logo']); ?>" alt="Logo">
|
|
<span><?php echo htmlspecialchars($channel['name']); ?></span>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
<main class="player-main">
|
|
<video id="video-player" controls autoplay src=""></video>
|
|
</main>
|
|
</div>
|
|
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const channelItems = document.querySelectorAll('.channel-item');
|
|
const videoPlayer = document.getElementById('video-player');
|
|
|
|
channelItems.forEach(item => {
|
|
item.addEventListener('click', function() {
|
|
const streamUrl = this.dataset.url;
|
|
videoPlayer.src = streamUrl;
|
|
videoPlayer.play();
|
|
});
|
|
});
|
|
|
|
// Auto-play the first channel if available
|
|
if (channelItems.length > 0) {
|
|
channelItems[0].click();
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|