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": {
|
"metaData": {
|
||||||
"artist": "6.prigoana.lol2.prigoana.lolPac",
|
"artist": "2Pac",
|
||||||
"title": "California Love (Original Version)"
|
"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": {
|
"metaData": {
|
||||||
"artist": "6.prigoana.lol2.prigoana.lolPac",
|
"artist": "2Pac",
|
||||||
"title": "Dear Mama (Album Version (Explicit))"
|
"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": {
|
"metaData": {
|
||||||
"artist": "6.prigoana.lol2.prigoana.lolPac",
|
"artist": "2Pac",
|
||||||
"title": "Hit 'Em Up (Single Version)"
|
"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": {
|
"metaData": {
|
||||||
|
@ -1644,7 +1644,7 @@ const webamp = new Webamp({
|
||||||
"artist": "Immortal Technique",
|
"artist": "Immortal Technique",
|
||||||
"title": "Dance With The Devil"
|
"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": {
|
"metaData": {
|
||||||
|
|
|
@ -8,6 +8,7 @@ const URLS_TO_CACHE = [
|
||||||
'https://lastfm.freetls.fastly.net/'
|
'https://lastfm.freetls.fastly.net/'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Install event: Pre-cache the static resources
|
||||||
self.addEventListener('install', function(event) {
|
self.addEventListener('install', function(event) {
|
||||||
event.waitUntil(
|
event.waitUntil(
|
||||||
caches.open(CACHE_NAME)
|
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) {
|
self.addEventListener('fetch', function(event) {
|
||||||
|
const requestUrl = new URL(event.request.url);
|
||||||
|
|
||||||
event.respondWith(
|
event.respondWith(
|
||||||
caches.match(event.request)
|
caches.match(event.request).then(function(response) {
|
||||||
.then(function(response) {
|
// If the resource is already cached, return it
|
||||||
return response || fetch(event.request);
|
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) {
|
self.addEventListener('activate', function(event) {
|
||||||
event.waitUntil(
|
event.waitUntil(
|
||||||
caches.keys().then(function(cacheNames) {
|
caches.keys().then(function(cacheNames) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue