Skip to content

Commit

Permalink
fix: w2g and anime redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaUnknown committed Dec 8, 2023
1 parent e09053b commit 4e26877
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 6 deletions.
15 changes: 11 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"target": "ESNext",
"moduleResolution": "node",
"module": "ESNext",
"types": ["./types.d.ts"],
"types": ["./types.d.ts", "@cloudflare/workers-types"],
"allowSyntheticDefaultImports": true
},
"exclude": ["node_modules", "dist", "build", "git_modules", "**/node_modules", "**/dist", "**/build", "**/git_modules",]
Expand Down
1 change: 1 addition & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20231121.0",
"@sveltejs/adapter-auto": "^2.1.1",
"@sveltejs/adapter-static": "^2.0.3",
"@sveltejs/kit": "^1.27.6",
Expand Down
18 changes: 18 additions & 0 deletions web/static/functions/anime/[id].js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/** @type {PagesFunction} */
export function onRequest ({ params }) {
try {
const id = Number(params.id)
if (Number.isSafeInteger(id)) {
const html = /* html */`<!DOCTYPE html><html style=background:#000><head><meta http-equiv=refresh content="5; url=https://miru.watch"><meta property="og:title" content="Watch Together"><meta property="og:description" content="Stream anime torrents, real-time with no waiting for downloads"><meta property="og:site_name" content="Miru"><meta property="og:image" content=https://github.com/ThaUnknown/miru/blob/master/docs/show.gif?raw=true><meta property="og:url" content=miru://anime/${id}><meta data-vmid="twitter:card" name="twitter:card" content="summary_large_image"><meta name="theme-color" content="#23a559"></head><body><iframe src=miru://w2g/${id} style=border:none></iframe>Redirecting...</body></html>`

return new Response(html, {
headers: {
'content-type': 'text/html;charset=UTF-8'
}
})
}
} catch (e) {
return Response.redirect('https://miru.watch/')
}
return Response.redirect('https://miru.watch/')
}
18 changes: 18 additions & 0 deletions web/static/functions/w2g/[id].js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/** @type {PagesFunction} */
export function onRequest ({ params }) {
try {
const id = Number(params.id)
if (Number.isSafeInteger(id)) {
const html = /* html */`<!DOCTYPE html><html style=background:#000><head><meta http-equiv=refresh content="5; url=https://miru.watch"><meta property="og:title" content="Watch Together"><meta property="og:description" content="Stream anime torrents, real-time with no waiting for downloads"><meta property="og:site_name" content="Miru"><meta property="og:image" content=https://github.com/ThaUnknown/miru/blob/master/docs/show.gif?raw=true><meta property="og:url" content=miru://w2g/${id}><meta data-vmid="twitter:card" name="twitter:card" content="summary_large_image"><meta name="theme-color" content="#23a559"></head><body><iframe src=miru://w2g/${id} style=border:none></iframe>Redirecting...</body></html>`

return new Response(html, {
headers: {
'content-type': 'text/html;charset=UTF-8'
}
})
}
} catch (e) {
return Response.redirect('https://miru.watch/')
}
return Response.redirect('https://miru.watch/')
}
2 changes: 1 addition & 1 deletion web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"target": "ESNext",
"moduleResolution": "node",
"module": "ESNext",
"types": ["./types.d.ts"],
"types": ["./types.d.ts", "@cloudflare/workers-types"],
"allowSyntheticDefaultImports": true
},
"exclude": ["node_modules", "dist", "build", "git_modules", "**/node_modules", "**/dist", "**/build", "**/git_modules",]
Expand Down

0 comments on commit 4e26877

Please sign in to comment.