This commit is contained in:
kuekhaoyang
2025-12-24 23:53:24 +08:00
commit 43a35e3f47
229 changed files with 28007 additions and 0 deletions
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 598 KiB

+42
View File
@@ -0,0 +1,42 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 450" fill="none">
<defs>
<linearGradient id="bg-gradient" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" style="stop-color:#f0f2f5;stop-opacity:1" />
<stop offset="100%" style="stop-color:#e0e4e8;stop-opacity:1" />
</linearGradient>
</defs>
<!-- Background -->
<rect width="300" height="450" fill="url(#bg-gradient)" rx="24"/>
<!-- Glass effect overlay -->
<rect width="300" height="450" fill="rgba(255, 255, 255, 0.5)" rx="24"/>
<!-- Film icon -->
<g transform="translate(150, 225)">
<!-- Film reel -->
<rect x="-60" y="-80" width="120" height="160" rx="8" fill="none" stroke="#6e6e73" stroke-width="4"/>
<!-- Film strip holes -->
<rect x="-60" y="-70" width="15" height="15" rx="3" fill="#6e6e73"/>
<rect x="-60" y="-40" width="15" height="15" rx="3" fill="#6e6e73"/>
<rect x="-60" y="-10" width="15" height="15" rx="3" fill="#6e6e73"/>
<rect x="-60" y="20" width="15" height="15" rx="3" fill="#6e6e73"/>
<rect x="-60" y="50" width="15" height="15" rx="3" fill="#6e6e73"/>
<rect x="45" y="-70" width="15" height="15" rx="3" fill="#6e6e73"/>
<rect x="45" y="-40" width="15" height="15" rx="3" fill="#6e6e73"/>
<rect x="45" y="-10" width="15" height="15" rx="3" fill="#6e6e73"/>
<rect x="45" y="20" width="15" height="15" rx="3" fill="#6e6e73"/>
<rect x="45" y="50" width="15" height="15" rx="3" fill="#6e6e73"/>
<!-- Play icon in center -->
<circle cx="0" cy="0" r="35" fill="#007aff" opacity="0.9"/>
<path d="M -10,-15 L -10,15 L 15,0 Z" fill="white"/>
</g>
<!-- "Image Not Available" text -->
<text x="150" y="330" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif" font-size="16" font-weight="600" fill="#6e6e73" text-anchor="middle">
Image Not Available
</text>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

+99
View File
@@ -0,0 +1,99 @@
const CACHE_NAME = 'video-cache-v2';
self.addEventListener('install', (event) => {
self.skipWaiting();
});
self.addEventListener('activate', (event) => {
event.waitUntil(
caches.keys().then((cacheNames) => {
return Promise.all(
cacheNames.map((cacheName) => {
if (cacheName !== CACHE_NAME) {
return caches.delete(cacheName);
}
})
);
}).then(() => self.clients.claim())
);
});
self.addEventListener('fetch', (event) => {
const url = new URL(event.request.url);
// Skip proxy API routes - they handle their own caching and URL rewriting
if (url.pathname.startsWith('/api/proxy')) {
return; // Let the request pass through without Service Worker intervention
}
// Intercept HLS manifest files (.m3u8)
if (url.pathname.endsWith('.m3u8')) {
event.respondWith(
caches.open(CACHE_NAME).then((cache) => {
return cache.match(event.request, { ignoreSearch: true }).then((cachedResponse) => {
// Always fetch fresh manifest but return cached while fetching
const fetchPromise = fetch(event.request).then((networkResponse) => {
// Check if network response is valid
if (!networkResponse || networkResponse.status !== 200) {
// Return the response as-is so client can see the error status
if (networkResponse) return networkResponse;
// If no response at all, throw to trigger catch block
throw new Error('Network response was not ok');
}
cache.put(event.request, networkResponse.clone());
return networkResponse;
}).catch((err) => {
console.error('[SW] Fetch failed for manifest:', err);
// If network fails, return cached response if available
if (cachedResponse) {
return cachedResponse;
}
// If no cache, return a proper error Response instead of throwing
// This prevents "Load failed" and lets the client handle it
return new Response('Network error', {
status: 503,
statusText: 'Service Worker: Network Unavailable'
});
});
// Return cache immediately if available, otherwise wait for network
return cachedResponse || fetchPromise;
});
})
);
}
// Intercept video segment files (.ts)
if (url.pathname.endsWith('.ts')) {
event.respondWith(
caches.open(CACHE_NAME).then((cache) => {
return cache.match(event.request, { ignoreSearch: true }).then((cachedResponse) => {
// Cache hit - return immediately for instant playback
if (cachedResponse) {
return cachedResponse;
}
// Cache miss - fetch from network
return fetch(event.request).then((response) => {
// Only cache valid responses
if (response && response.status === 200) {
cache.put(event.request, response.clone());
return response;
}
// If response is not valid (e.g. 403, 404), return it as is
// so the browser/player can handle the error status
return response;
}).catch((error) => {
console.error('[SW] Failed to fetch segment:', error);
// Return a proper error Response instead of throwing
// This prevents "Load failed" and lets the client handle it
return new Response('Network error', {
status: 503,
statusText: 'Service Worker: Network Unavailable'
});
});
});
})
);
}
});