sgdfj
This commit is contained in:
parent
7b51a92c48
commit
34ffa32571
2 changed files with 33 additions and 11 deletions
14
index.js
14
index.js
|
@ -1011,24 +1011,24 @@ const webamp = new Webamp({
|
|||
},
|
||||
{
|
||||
"metaData": {
|
||||
"artist": "6.prigoana.lol2.prigoana.lolPac",
|
||||
"artist": "2Pac",
|
||||
"title": "California Love (Original Version)"
|
||||
},
|
||||
"url": "https://6.prigoana.lol2.prigoana.lolPac - California Love (Original Version).flac"
|
||||
"url": "https://6.prigoana.lol/2Pac%20-%20California%20Love%20(Original%20Version).flac"
|
||||
},
|
||||
{
|
||||
"metaData": {
|
||||
"artist": "6.prigoana.lol2.prigoana.lolPac",
|
||||
"artist": "2Pac",
|
||||
"title": "Dear Mama (Album Version (Explicit))"
|
||||
},
|
||||
"url": "https://6.prigoana.lol2.prigoana.lolPac - Dear Mama (Album Version (Explicit)).flac"
|
||||
"url": "https://6.prigoana.lol/2Pac - Dear Mama (Album Version (Explicit)).flac"
|
||||
},
|
||||
{
|
||||
"metaData": {
|
||||
"artist": "6.prigoana.lol2.prigoana.lolPac",
|
||||
"artist": "2Pac",
|
||||
"title": "Hit 'Em Up (Single Version)"
|
||||
},
|
||||
"url": "https://6.prigoana.lol2.prigoana.lolPac - Hit 'Em Up (Single Version).flac"
|
||||
"url": "https://6.prigoana.lol/2Pac - Hit 'Em Up (Single Version).flac"
|
||||
},
|
||||
{
|
||||
"metaData": {
|
||||
|
@ -1644,7 +1644,7 @@ const webamp = new Webamp({
|
|||
"artist": "Immortal Technique",
|
||||
"title": "Dance With The Devil"
|
||||
},
|
||||
"url": "https://9.prigoana.lol/Immortal Technique - Dance with the Devil"
|
||||
"url": "https://9.prigoana.lol/Immortal Technique - Dance with the Devil.flac"
|
||||
},
|
||||
{
|
||||
"metaData": {
|
||||
|
|
|
@ -8,6 +8,7 @@ const URLS_TO_CACHE = [
|
|||
'https://lastfm.freetls.fastly.net/'
|
||||
];
|
||||
|
||||
// Install event: Pre-cache the static resources
|
||||
self.addEventListener('install', function(event) {
|
||||
event.waitUntil(
|
||||
caches.open(CACHE_NAME)
|
||||
|
@ -17,15 +18,36 @@ self.addEventListener('install', function(event) {
|
|||
);
|
||||
});
|
||||
|
||||
// Fetch event: Serve cached files and dynamically cache .mp3 or .flac files
|
||||
self.addEventListener('fetch', function(event) {
|
||||
const requestUrl = new URL(event.request.url);
|
||||
|
||||
event.respondWith(
|
||||
caches.match(event.request)
|
||||
.then(function(response) {
|
||||
return response || fetch(event.request);
|
||||
})
|
||||
caches.match(event.request).then(function(response) {
|
||||
// If the resource is already cached, return it
|
||||
if (response) {
|
||||
return response;
|
||||
}
|
||||
|
||||
// Otherwise, fetch the resource and check if it's an audio file
|
||||
return fetch(event.request).then(function(fetchResponse) {
|
||||
// Clone the response (responses can only be used once)
|
||||
const fetchResponseClone = fetchResponse.clone();
|
||||
|
||||
// Check if the file ends with .mp3 or .flac
|
||||
if (requestUrl.pathname.endsWith('.mp3') || requestUrl.pathname.endsWith('.flac')) {
|
||||
caches.open(CACHE_NAME).then(function(cache) {
|
||||
cache.put(event.request, fetchResponseClone);
|
||||
});
|
||||
}
|
||||
|
||||
return fetchResponse;
|
||||
});
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
// Activate event: Clean up old caches
|
||||
self.addEventListener('activate', function(event) {
|
||||
event.waitUntil(
|
||||
caches.keys().then(function(cacheNames) {
|
||||
|
|
Loading…
Add table
Reference in a new issue