streamsphere-explorer / index.html
ravamarcos's picture
no deja buscar, no se ve la lista, no funciona la busqueda por url
ec77e98 verified
Raw History Blame Contribute Delete
20.8 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>StreamSphere Explorer - IPTV Player</title>
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/feather-icons"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.globe.min.js"></script>
<style>
.channel-card:hover {
transform: translateY(-5px);
transition: all 0.3s ease;
}
.video-container {
background: #000;
border-radius: 12px;
overflow: hidden;
}
.country-flag {
width: 24px;
height: 16px;
object-fit: cover;
border-radius: 2px;
}
</style>
</head>
<body class="bg-gradient-to-br from-gray-900 to-black text-white min-h-screen">
<!-- Navigation -->
<nav class="bg-gray-800/80 backdrop-blur-md border-b border-gray-700 sticky top-0 z-50">
<div class="container mx-auto px-4 py-3">
<div class="flex items-center justify-between">
<div class="flex items-center space-x-2">
<i data-feather="globe" class="text-blue-400"></i>
<h1 class="text-xl font-bold bg-gradient-to-r from-blue-400 to-purple-500 bg-clip-text text-transparent">
StreamSphere Explorer
</h1>
</div>
<div class="flex items-center space-x-4">
<button id="uploadBtn" class="bg-blue-600 hover:bg-blue-700 px-4 py-2 rounded-lg flex items-center space-x-2 transition-colors">
<i data-feather="upload" class="w-4 h-4"></i>
<span>Upload M3U</span>
</button>
<button id="addUrlBtn" class="bg-purple-600 hover:bg-purple-700 px-4 py-2 rounded-lg flex items-center space-x-2 transition-colors">
<i data-feather="link" class="w-4 h-4"></i>
<span>Add URL</span>
</button>
</div>
</div>
</div>
</nav>
<!-- Main Content -->
<div class="container mx-auto px-4 py-8">
<div class="grid lg:grid-cols-4 gap-8">
<!-- Sidebar -->
<div class="lg:col-span-1 space-y-6">
<!-- Search -->
<div class="bg-gray-800/50 rounded-xl p-4 backdrop-blur-sm">
<div class="flex items-center space-x-2 mb-4">
<i data-feather="search" class="text-gray-400"></i>
<input type="text" id="searchInput" placeholder="Search channels..."
class="bg-gray-700/50 border border-gray-600 rounded-lg px-3 py-2 text-white w-full focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<!-- Country Filter -->
<div class="space-y-3">
<h3 class="font-semibold text-gray-300 flex items-center space-x-2">
<i data-feather="map-pin" class="w-4 h-4"></i>
<span>Filter by Country</span>
</h3>
<select id="countryFilter" class="w-full bg-gray-700/50 border border-gray-600 rounded-lg px-3 py-2 text-white focus:outline-none focus:ring-2 focus:ring-blue-500">
<option value="">All Countries</option>
</select>
</div>
<!-- Category Filter -->
<div class="space-y-3 mt-4">
<h3 class="font-semibold text-gray-300 flex items-center space-x-2">
<i data-feather="grid" class="w-4 h-4"></i>
<span>Filter by Category</span>
</h3>
<select id="categoryFilter" class="w-full bg-gray-700/50 border border-gray-600 rounded-lg px-3 py-2 text-white focus:outline-none focus:ring-2 focus:ring-blue-500">
<option value="">All Categories</option>
</select>
</div>
</div>
<!-- Playlists -->
<div class="bg-gray-800/50 rounded-xl p-4 backdrop-blur-sm">
<h3 class="font-semibold text-gray-300 mb-3 flex items-center space-x-2">
<i data-feather="list" class="w-4 h-4"></i>
<span>Playlists</span>
</h3>
<div id="playlistList" class="space-y-2 max-h-60 overflow-y-auto">
<!-- Playlists will be populated here -->
</div>
</div>
</div>
<!-- Main Content Area -->
<div class="lg:col-span-3">
<!-- Video Player -->
<div class="video-container mb-8 shadow-2xl">
<video id="videoPlayer" controls class="w-full h-64 lg:h-96" poster="http://static.photos/abstract/1024x576/42">
Your browser does not support the video tag.
</video>
</div>
<!-- Channels Grid -->
<div class="mb-6 flex items-center justify-between">
<h2 class="text-2xl font-bold">Available Channels</h2>
<div class="text-gray-400 text-sm" id="channelCount">0 channels</div>
</div>
<div id="channelsGrid" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">
<!-- Channels will be populated here -->
<div class="text-center py-12 text-gray-500">
<i data-feather="tv" class="w-12 h-12 mx-auto mb-3"></i>
<p>Upload an M3U file or add a playlist URL to get started</p>
</div>
</div>
</div>
</div>
</div>
<!-- Modals -->
<!-- Upload Modal -->
<div id="uploadModal" class="fixed inset-0 bg-black/70 flex items-center justify-center z-50 hidden">
<div class="bg-gray-800 rounded-2xl p-6 w-full max-w-md mx-4">
<div class="flex items-center justify-between mb-4">
<h3 class="text-lg font-semibold">Upload M3U File</h3>
<button id="closeUploadModal" class="text-gray-400 hover:text-white">
<i data-feather="x" class="w-5 h-5"></i>
</button>
</div>
<input type="file" id="m3uFile" accept=".m3u,.m3u8" class="w-full mb-4">
<button id="processM3U" class="w-full bg-blue-600 hover:bg-blue-700 py-2 rounded-lg transition-colors">
Process File
</button>
</div>
</div>
<!-- URL Modal -->
<div id="urlModal" class="fixed inset-0 bg-black/70 flex items-center justify-center z-50 hidden">
<div class="bg-gray-800 rounded-2xl p-6 w-full max-w-md mx-4">
<div class="flex items-center justify-between mb-4">
<h3 class="text-lg font-semibold">Add Playlist URL</h3>
<button id="closeUrlModal" class="text-gray-400 hover:text-white">
<i data-feather="x" class="w-5 h-5"></i>
</button>
</div>
<input type="url" id="playlistUrl" placeholder="https://example.com/playlist.m3u"
class="w-full bg-gray-700 border border-gray-600 rounded-lg px-3 py-2 text-white mb-4 focus:outline-none focus:ring-2 focus:ring-blue-500">
<button id="addPlaylistUrl" class="w-full bg-purple-600 hover:bg-purple-700 py-2 rounded-lg transition-colors">
Add Playlist
</button>
</div>
</div>
<script>
// Vanta.js Background
VANTA.GLOBE({
el: "body",
mouseControls: true,
touchControls: true,
gyroControls: false,
minHeight: 200.00,
minWidth: 200.00,
scale: 1.00,
scaleMobile: 1.00,
color: 0x3b82f6,
backgroundColor: 0x111827,
size: 0.8
});
// Global state
let playlists = [];
let channels = [];
let filteredChannels = [];
// DOM Elements
const uploadBtn = document.getElementById('uploadBtn');
const addUrlBtn = document.getElementById('addUrlBtn');
const uploadModal = document.getElementById('uploadModal');
const urlModal = document.getElementById('urlModal');
const closeUploadModal = document.getElementById('closeUploadModal');
const closeUrlModal = document.getElementById('closeUrlModal');
const processM3U = document.getElementById('processM3U');
const addPlaylistUrl = document.getElementById('addPlaylistUrl');
const m3uFile = document.getElementById('m3uFile');
const playlistUrl = document.getElementById('playlistUrl');
const searchInput = document.getElementById('searchInput');
const countryFilter = document.getElementById('countryFilter');
const categoryFilter = document.getElementById('categoryFilter');
const channelsGrid = document.getElementById('channelsGrid');
const playlistList = document.getElementById('playlistList');
const videoPlayer = document.getElementById('videoPlayer');
const channelCount = document.getElementById('channelCount');
// Event Listeners
uploadBtn.addEventListener('click', () => uploadModal.classList.remove('hidden'));
addUrlBtn.addEventListener('click', () => urlModal.classList.remove('hidden'));
closeUploadModal.addEventListener('click', () => uploadModal.classList.add('hidden'));
closeUrlModal.addEventListener('click', () => urlModal.classList.add('hidden'));
processM3U.addEventListener('click', processM3UFile);
addPlaylistUrl.addEventListener('click', addPlaylistFromUrl);
searchInput.addEventListener('input', filterChannels);
countryFilter.addEventListener('change', filterChannels);
categoryFilter.addEventListener('change', filterChannels);
// Functions
function processM3UFile() {
const file = m3uFile.files[0];
if (!file) return;
const reader = new FileReader();
reader.onload = function(e) {
const content = e.target.result;
parseM3UContent(content, file.name);
uploadModal.classList.add('hidden');
};
reader.readAsText(file);
}
async function addPlaylistFromUrl() {
const url = playlistUrl.value.trim();
if (!url) return;
try {
// Add CORS proxy to bypass CORS restrictions
const proxyUrl = 'https://cors-anywhere.herokuapp.com/';
const response = await fetch(proxyUrl + url);
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
const content = await response.text();
parseM3UContent(content, url);
urlModal.classList.add('hidden');
playlistUrl.value = '';
} catch (error) {
alert('Error loading playlist from URL: ' + error.message);
}
}
function parseM3UContent(content, source) {
const lines = content.split('\n');
const newChannels = [];
let currentChannel = {};
for (let i = 0; i < lines.length; i++) {
const line = lines[i].trim();
if (line.startsWith('#EXTINF:')) {
currentChannel = parseExtinfLine(line);
} else if (line.startsWith('http')) {
currentChannel.url = line;
currentChannel.source = source;
newChannels.push(currentChannel);
currentChannel = {};
}
}
// Add new channels to global list
channels = [...channels, ...newChannels];
// Add playlist if it doesn't exist
if (!playlists.find(p => p.source === source)) {
playlists.push({
source: source,
name: source.split('/').pop() || 'Custom Playlist',
channelCount: newChannels.length
});
}
updatePlaylistList();
updateFilters();
filterChannels();
}
function parseExtinfLine(line) {
const channel = {};
// Extract duration and name
const match = line.match(/#EXTINF:(-?\d+)(.*?),(.*)/);
if (match) {
channel.duration = parseInt(match[1]);
const attributes = match[2];
channel.name = match[3].trim();
// Extract attributes using a more robust approach
if (attributes) {
// Extract tvg-name
const tvgNameMatch = attributes.match(/tvg-name="([^"]*)"/i);
if (tvgNameMatch) channel.tvgName = tvgNameMatch[1];
// Extract tvg-logo
const tvgLogoMatch = attributes.match(/tvg-logo="([^"]*)"/i);
if (tvgLogoMatch) channel.tvgLogo = tvgLogoMatch[1];
// Extract group-title
const groupTitleMatch = attributes.match(/group-title="([^"]*)"/i);
if (groupTitleMatch) channel.group = groupTitleMatch[1];
// Extract country
const countryMatch = attributes.match(/tvg-country="([^"]*)"/i);
if (countryMatch) channel.country = countryMatch[1];
}
// Set default values if not present
if (!channel.country) channel.country = 'Unknown';
if (!channel.group) channel.group = 'General';
}
return channel;
}
function updatePlaylistList() {
playlistList.innerHTML = playlists.map(playlist => `
<div class="flex items-center justify-between p-2 bg-gray-700/30 rounded-lg hover:bg-gray-700/50 cursor-pointer transition-colors">
<div class="flex items-center space-x-2">
<i data-feather="play-circle" class="w-4 h-4 text-green-400"></i>
<span class="text-sm truncate">${playlist.name}</span>
</div>
<span class="text-xs text-gray-400 bg-gray-600 px-2 py-1 rounded">
${playlist.channelCount}
</span>
</div>
`).join('');
feather.replace();
}
function updateFilters() {
// Update country filter
const countries = [...new Set(channels.map(c => c.country).filter(Boolean))].sort();
countryFilter.innerHTML = '<option value="">All Countries</option>' +
countries.map(country => `<option value="${country}">${country}</option>`).join('');
// Update category filter
const categories = [...new Set(channels.map(c => c.group).filter(Boolean))].sort();
categoryFilter.innerHTML = '<option value="">All Categories</option>' +
categories.map(category => `<option value="${category}">${category}</option>`).join('');
}
function filterChannels() {
const searchTerm = searchInput.value.toLowerCase();
const selectedCountry = countryFilter.value;
const selectedCategory = categoryFilter.value;
filteredChannels = channels.filter(channel => {
const matchesSearch = !searchTerm ||
channel.name.toLowerCase().includes(searchTerm) ||
(channel.group && channel.group.toLowerCase().includes(searchTerm));
const matchesCountry = !selectedCountry || channel.country === selectedCountry;
const matchesCategory = !selectedCategory || channel.group === selectedCategory;
return matchesSearch && matchesCountry && matchesCategory;
});
displayChannels();
}
function displayChannels() {
channelCount.textContent = `${filteredChannels.length} channels`;
if (filteredChannels.length === 0) {
channelsGrid.innerHTML = `
<div class="col-span-full text-center py-12 text-gray-500">
<i data-feather="search" class="w-12 h-12 mx-auto mb-3"></i>
<p>No channels found matching your criteria</p>
</div>
`;
return;
}
channelsGrid.innerHTML = filteredChannels.map(channel => `
<div class="channel-card bg-gray-800/50 backdrop-blur-sm rounded-xl p-4 border border-gray-700 hover:border-blue-500 cursor-pointer transition-all duration-300"
onclick="playChannel('${channel.url.replace(/'/g, "\\'")}', '${channel.name ? channel.name.replace(/'/g, "\\'") : 'Unknown'}')">
<div class="flex items-center space-x-3 mb-3">
<div class="w-12 h-12 bg-gradient-to-br from-blue-500 to-purple-600 rounded-lg flex items-center justify-center">
<i data-feather="play" class="w-5 h-5 text-white"></i>
</div>
<div class="flex-1 min-w-0">
<h4 class="font-semibold text-white truncate">${channel.name || 'Unknown Channel'}</h4>
<div class="flex items-center space-x-2 mt-1">
${channel.country && channel.country !== 'Unknown' ? `
<span class="text-xs text-gray-400">${channel.country}</span>
` : ''}
</div>
</div>
<div class="text-xs text-gray-400 mt-2 flex items-center justify-between">
<span class="bg-gray-700 px-2 py-1 rounded">${channel.group || 'General'}</span>
</div>
</div>
`).join('');
feather.replace();
}
function playChannel(url, name) {
videoPlayer.src = url;
videoPlayer.play().catch(e => {
console.error('Error playing video:', e);
alert('Error playing channel. The stream might be unavailable.');
});
// Update UI to show current playing channel
document.querySelectorAll('.channel-card').forEach(card => {
card.classList.remove('border-blue-500', 'bg-blue-500/20');
});
// Find and highlight the current playing channel card
const channelCards = document.querySelectorAll('.channel-card');
for (let card of channelCards) {
if (card.querySelector('h4').textContent === name) {
card.classList.add('border-blue-500', 'bg-blue-500/20');
}
}
}
// Close modals when clicking outside
window.addEventListener('click', (e) => {
if (e.target === uploadModal) uploadModal.classList.add('hidden');
if (e.target === urlModal) urlModal.classList.add('hidden');
});
// Initialize with sample data for testing
feather.replace();
// Add sample playlist for testing
setTimeout(() => {
const samplePlaylist = `#EXTM3U
#EXTINF:-1 tvg-id="Example1" tvg-name="Example Channel 1" tvg-logo="https://example.com/logo1.png" group-title="Entertainment" tvg-country="US",Example Channel 1
http://example.com/stream1.m3u8
#EXTINF:-1 tvg-id="Example2" tvg-name="Example Channel 2" tvg-logo="https://example.com/logo2.png" group-title="News" tvg-country="UK",Example Channel 2
http://example.com/stream2.m3u8
#EXTINF:-1 tvg-id="Example3" tvg-name="Example Channel 3" tvg-logo="https://example.com/logo3.png" group-title="Sports" tvg-country="ES",Example Channel 3
http://example.com/stream3.m3u8`;
parseM3UContent(samplePlaylist, 'Sample Playlist');
}, 1000);
</script>
</body>
</html>