mirror of
https://github.com/NoCrypt/migu.git
synced 2026-04-21 08:31:58 +00:00
feat: migu own url handler and more
This commit is contained in:
parent
aa3fcdf52c
commit
893ee8804d
14 changed files with 36 additions and 36 deletions
|
|
@ -32,7 +32,7 @@
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<data android:scheme="miru" />
|
<data android:scheme="migu" />
|
||||||
|
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
|
|
||||||
|
|
@ -40,16 +40,16 @@ IPC.on('notification', noti => {
|
||||||
if (canShowNotifications) LocalNotifications.schedule({ notifications: [notification] })
|
if (canShowNotifications) LocalNotifications.schedule({ notifications: [notification] })
|
||||||
})
|
})
|
||||||
|
|
||||||
// schema: miru://key/value
|
// schema: migu://key/value
|
||||||
const protocolMap = {
|
const protocolMap = {
|
||||||
auth: token => sendToken(token),
|
auth: token => sendToken(token),
|
||||||
anime: id => IPC.emit('open-anime', id),
|
anime: id => IPC.emit('open-anime', id),
|
||||||
w2g: link => IPC.emit('w2glink', link),
|
w2g: link => IPC.emit('w2glink', link),
|
||||||
schedule: () => IPC.emit('schedule'),
|
schedule: () => IPC.emit('schedule'),
|
||||||
donate: () => Browser.open({ url: 'https://github.com/sponsors/ThaUnknown/' })
|
donate: () => Browser.open({ url: 'https://github.com/sponsors/NoCrypt/' })
|
||||||
}
|
}
|
||||||
|
|
||||||
const protocolRx = /miru:\/\/([a-z0-9]+)\/(.*)/i
|
const protocolRx = /migu:\/\/([a-z0-9]+)\/(.*)/i
|
||||||
|
|
||||||
function handleProtocol (text) {
|
function handleProtocol (text) {
|
||||||
const match = text.match(protocolRx)
|
const match = text.match(protocolRx)
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@
|
||||||
if (anilistClient.userID?.viewer?.data?.Viewer) {
|
if (anilistClient.userID?.viewer?.data?.Viewer) {
|
||||||
$logout = true
|
$logout = true
|
||||||
} else {
|
} else {
|
||||||
IPC.emit('open', 'https://anilist.co/api/v2/oauth/authorize?client_id=4254&response_type=token') // Change redirect_url to miru://auth
|
IPC.emit('open', 'https://anilist.co/api/v2/oauth/authorize?client_id=20321&response_type=token') // Change redirect_url to migu://auth
|
||||||
if (platformMap[window.version.platform] === 'Linux') {
|
if (platformMap[window.version.platform] === 'Linux') {
|
||||||
toast('Support Notification', {
|
toast('Support Notification', {
|
||||||
description: "If your linux distribution doesn't support custom protocol handlers, you can simply paste the full URL into the app.",
|
description: "If your linux distribution doesn't support custom protocol handlers, you can simply paste the full URL into the app.",
|
||||||
|
|
|
||||||
|
|
@ -238,7 +238,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Watch on Migu',
|
label: 'Watch on Migu',
|
||||||
url: `miru://anime/${np.media?.id}`
|
url: `migu://anime/${np.media?.id}`
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
IPC.emit('version')
|
IPC.emit('version')
|
||||||
|
|
||||||
const changeLog = (async () => {
|
const changeLog = (async () => {
|
||||||
const res = await fetch('https://api.github.com/repos/ThaUnknown/miru/releases')
|
const res = await fetch('https://api.github.com/repos/NoCrypt/migu/releases')
|
||||||
const json = await res.json()
|
const json = await res.json()
|
||||||
return json.map(({ body, tag_name: version, published_at: date, assets }) => ({ body, version, date, assets }))
|
return json.map(({ body, tag_name: version, published_at: date, assets }) => ({ body, version, date, assets }))
|
||||||
})()
|
})()
|
||||||
|
|
@ -74,7 +74,7 @@
|
||||||
if (anilistClient.userID?.viewer?.data?.Viewer) {
|
if (anilistClient.userID?.viewer?.data?.Viewer) {
|
||||||
$logout = true
|
$logout = true
|
||||||
} else {
|
} else {
|
||||||
IPC.emit('open', 'https://anilist.co/api/v2/oauth/authorize?client_id=4254&response_type=token') // Change redirect_url to miru://auth
|
IPC.emit('open', 'https://anilist.co/api/v2/oauth/authorize?client_id=20321&response_type=token') // Change redirect_url to migu://auth
|
||||||
if (platformMap[window.version.platform] === 'Linux') {
|
if (platformMap[window.version.platform] === 'Linux') {
|
||||||
toast('Support Notification', {
|
toast('Support Notification', {
|
||||||
description: "If your linux distribution doesn't support custom protocol handlers, you can simply paste the full URL into the app.",
|
description: "If your linux distribution doesn't support custom protocol handlers, you can simply paste the full URL into the app.",
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@
|
||||||
<span class='material-symbols-outlined mr-15 font-size-18 w-30'> open_in_new </span>
|
<span class='material-symbols-outlined mr-15 font-size-18 w-30'> open_in_new </span>
|
||||||
Open
|
Open
|
||||||
</button>
|
</button>
|
||||||
<button class='btn flex-fill font-weight-bold font-size-16 ml-5 d-flex align-items-center' use:click={() => { copyToClipboard(`https://miru.watch/anime/${media.id}`) }}>
|
<button class='btn flex-fill font-weight-bold font-size-16 ml-5 d-flex align-items-center' use:click={() => { copyToClipboard(`https://miguapp.pages.dev/anime/${media.id}`) }}>
|
||||||
<span class='material-symbols-outlined mr-15 font-size-18 w-30'> share </span>
|
<span class='material-symbols-outlined mr-15 font-size-18 w-30'> share </span>
|
||||||
Share
|
Share
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@
|
||||||
<button class='btn bg-dark btn-lg btn-square ml-10 material-symbols-outlined font-size-20 shadow-none border-0' class:filled={media.mediaListEntry} use:click={toggleStatus}>
|
<button class='btn bg-dark btn-lg btn-square ml-10 material-symbols-outlined font-size-20 shadow-none border-0' class:filled={media.mediaListEntry} use:click={toggleStatus}>
|
||||||
bookmark
|
bookmark
|
||||||
</button>
|
</button>
|
||||||
<button class='btn bg-dark btn-lg btn-square ml-10 material-symbols-outlined font-size-20 shadow-none border-0' use:click={() => copyToClipboard(`https://miru.watch/anime/${media.id}`)}>
|
<button class='btn bg-dark btn-lg btn-square ml-10 material-symbols-outlined font-size-20 shadow-none border-0' use:click={() => copyToClipboard(`https://miguapp.pages.dev/anime/${media.id}`)}>
|
||||||
share
|
share
|
||||||
</button>
|
</button>
|
||||||
<button class='btn bg-dark btn-lg btn-square ml-10 material-symbols-outlined font-size-20 shadow-none border-0' use:click={() => openInBrowser(`https://anilist.co/anime/${media.id}`)}>
|
<button class='btn bg-dark btn-lg btn-square ml-10 material-symbols-outlined font-size-20 shadow-none border-0' use:click={() => openInBrowser(`https://anilist.co/anime/${media.id}`)}>
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@
|
||||||
|
|
||||||
function invite () {
|
function invite () {
|
||||||
if (p2pt) {
|
if (p2pt) {
|
||||||
navigator.clipboard.writeText(`https://miru.watch/w2g/${p2pt.identifierString}`)
|
navigator.clipboard.writeText(`https://miguapp.pages.dev/w2g/${p2pt.identifierString}`)
|
||||||
toast('Copied to clipboard', {
|
toast('Copied to clipboard', {
|
||||||
description: 'Copied invite URL to clipboard',
|
description: 'Copied invite URL to clipboard',
|
||||||
duration: 5000
|
duration: 5000
|
||||||
|
|
|
||||||
|
|
@ -49,9 +49,9 @@
|
||||||
"customDir": "2ffc48f0b43f"
|
"customDir": "2ffc48f0b43f"
|
||||||
},
|
},
|
||||||
"protocols": {
|
"protocols": {
|
||||||
"name": "miru",
|
"name": "migu",
|
||||||
"schemes": [
|
"schemes": [
|
||||||
"miru"
|
"migu"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"publish": [
|
"publish": [
|
||||||
|
|
@ -99,7 +99,7 @@
|
||||||
"Comment": "Bittorrent streaming software for cats",
|
"Comment": "Bittorrent streaming software for cats",
|
||||||
"Keywords": "anime",
|
"Keywords": "anime",
|
||||||
"Type": "Application",
|
"Type": "Application",
|
||||||
"MimeType": "x-scheme-handler/miru;"
|
"MimeType": "x-scheme-handler/migu;"
|
||||||
},
|
},
|
||||||
"target": [
|
"target": [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ export default class App {
|
||||||
})
|
})
|
||||||
|
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
app.setAppUserModelId('com.github.thaunknown.miru')
|
app.setAppUserModelId('com.github.nocrypt.migu')
|
||||||
// this message usually fires in dev-mode from the parent process
|
// this message usually fires in dev-mode from the parent process
|
||||||
process.on('message', data => {
|
process.on('message', data => {
|
||||||
if (data === 'graceful-exit') this.destroy()
|
if (data === 'graceful-exit') this.destroy()
|
||||||
|
|
@ -117,8 +117,8 @@ export default class App {
|
||||||
this.mainWindow.webContents.on('render-process-gone', async (e, { reason }) => {
|
this.mainWindow.webContents.on('render-process-gone', async (e, { reason }) => {
|
||||||
if (reason === 'crashed') {
|
if (reason === 'crashed') {
|
||||||
if (++crashcount > 10) {
|
if (++crashcount > 10) {
|
||||||
await dialog.showMessageBox({ message: 'Crashed too many times.', title: 'Miru', detail: 'App crashed too many times. For a fix visit https://miru.watch/faq/', icon: '/renderer/public/logo_filled.png' })
|
await dialog.showMessageBox({ message: 'Crashed too many times.', title: 'Migu', detail: 'App crashed too many times. Make an issue at https://github.com/NoCrypt/migu/issues', icon: '/renderer/public/logo_filled.png' })
|
||||||
shell.openExternal('https://miru.watch/faq/')
|
shell.openExternal('https://github.com/NoCrypt/migu/issues')
|
||||||
} else {
|
} else {
|
||||||
app.relaunch()
|
app.relaunch()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,14 +4,14 @@ import path from 'path'
|
||||||
|
|
||||||
if (process.defaultApp) {
|
if (process.defaultApp) {
|
||||||
if (process.argv.length >= 2) {
|
if (process.argv.length >= 2) {
|
||||||
app.setAsDefaultProtocolClient('miru', process.execPath, [path.resolve(process.argv[1])])
|
app.setAsDefaultProtocolClient('migu', process.execPath, [path.resolve(process.argv[1])])
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
app.setAsDefaultProtocolClient('miru')
|
app.setAsDefaultProtocolClient('migu')
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Protocol {
|
export default class Protocol {
|
||||||
// schema: miru://key/value
|
// schema: migu://key/value
|
||||||
protocolMap = {
|
protocolMap = {
|
||||||
auth: token => this.sendToken(token),
|
auth: token => this.sendToken(token),
|
||||||
anime: id => this.window.webContents.send('open-anime', id),
|
anime: id => this.window.webContents.send('open-anime', id),
|
||||||
|
|
@ -20,7 +20,7 @@ export default class Protocol {
|
||||||
donate: () => shell.openExternal('https://github.com/sponsors/ThaUnknown/')
|
donate: () => shell.openExternal('https://github.com/sponsors/ThaUnknown/')
|
||||||
}
|
}
|
||||||
|
|
||||||
protocolRx = /miru:\/\/([a-z0-9]+)\/(.*)/i
|
protocolRx = /migu:\/\/([a-z0-9]+)\/(.*)/i
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import('electron').BrowserWindow} window
|
* @param {import('electron').BrowserWindow} window
|
||||||
|
|
@ -28,7 +28,7 @@ export default class Protocol {
|
||||||
constructor (window) {
|
constructor (window) {
|
||||||
this.window = window
|
this.window = window
|
||||||
|
|
||||||
protocol.registerHttpProtocol('miru', (req, cb) => {
|
protocol.registerHttpProtocol('migu', (req, cb) => {
|
||||||
const token = req.url.slice(7)
|
const token = req.url.slice(7)
|
||||||
this.window.loadURL(development ? 'http://localhost:5000/app.html' + token : `file://${path.join(__dirname, '/app.html')}${token}`)
|
this.window.loadURL(development ? 'http://localhost:5000/app.html' + token : `file://${path.join(__dirname, '/app.html')}${token}`)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -56,19 +56,19 @@ app.setJumpList?.([
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
type: 'task',
|
type: 'task',
|
||||||
program: 'miru://schedule/',
|
program: 'migu://schedule/',
|
||||||
title: 'Airing Schedule',
|
title: 'Airing Schedule',
|
||||||
description: 'Open The Airing Schedule'
|
description: 'Open The Airing Schedule'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'task',
|
type: 'task',
|
||||||
program: 'miru://w2g/',
|
program: 'migu://w2g/',
|
||||||
title: 'Watch Together',
|
title: 'Watch Together',
|
||||||
description: 'Create a New Watch Together Lobby'
|
description: 'Create a New Watch Together Lobby'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'task',
|
type: 'task',
|
||||||
program: 'miru://donate/',
|
program: 'migu://donate/',
|
||||||
title: 'Donate',
|
title: 'Donate',
|
||||||
description: 'Support This App'
|
description: 'Support This App'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,17 +9,17 @@ export function onRequest ({ params }) {
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html style=background:#000>
|
<html style=background:#000>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv=refresh content="5; url=https://miru.watch">
|
<meta http-equiv=refresh content="5; url=https://miguapp.pages.dev">
|
||||||
<meta property="og:title" content="Anime">
|
<meta property="og:title" content="Anime">
|
||||||
<meta property="og:description" content="Stream anime torrents, real-time with no waiting for downloads">
|
<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:site_name" content="Migu">
|
||||||
<meta property="og:image" content=https://miru.watch/app_original.png>
|
<meta property="og:image" content=https://miguapp.pages.dev/imgs/banner.png>
|
||||||
<meta property="og:url" content=miru://anime/${id}>
|
<meta property="og:url" content=migu://anime/${id}>
|
||||||
<meta data-vmid="twitter:card" name="twitter:card" content="summary_large_image">
|
<meta data-vmid="twitter:card" name="twitter:card" content="summary_large_image">
|
||||||
<meta name="theme-color" content="#17191C">
|
<meta name="theme-color" content="#17191C">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<iframe src=miru://anime/${id} style=border:none></iframe>Redirecting...
|
<iframe src=migu://anime/${id} style=border:none></iframe>Redirecting...
|
||||||
</body>
|
</body>
|
||||||
</html>`
|
</html>`
|
||||||
|
|
||||||
|
|
@ -30,5 +30,5 @@ export function onRequest ({ params }) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
return Response.redirect('https://miru.watch/')
|
return Response.redirect('https://miguapp.pages.dev/')
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,17 +8,17 @@ export function onRequest ({ params }) {
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html style=background:#000>
|
<html style=background:#000>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv=refresh content="5; url=https://miru.watch">
|
<meta http-equiv=refresh content="5; url=https://miguapp.pages.dev">
|
||||||
<meta property="og:title" content="Watch Together">
|
<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:description" content="Stream anime torrents, real-time with no waiting for downloads">
|
||||||
<meta property="og:site_name" content="Migu">
|
<meta property="og:site_name" content="Migu">
|
||||||
<meta property="og:image" content=https://miru.watch/app_original.png>
|
<meta property="og:image" content=https://miguapp.pages.dev/imgs/banner.png>
|
||||||
<meta property="og:url" content=miru://w2g/${id}>
|
<meta property="og:url" content=migu://w2g/${id}>
|
||||||
<meta data-vmid="twitter:card" name="twitter:card" content="summary_large_image">
|
<meta data-vmid="twitter:card" name="twitter:card" content="summary_large_image">
|
||||||
<meta name="theme-color" content="#17191C">
|
<meta name="theme-color" content="#17191C">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<iframe src=miru://w2g/${id} style=border:none></iframe>Redirecting...
|
<iframe src=migu://w2g/${id} style=border:none></iframe>Redirecting...
|
||||||
</body>
|
</body>
|
||||||
</html>`
|
</html>`
|
||||||
|
|
||||||
|
|
@ -28,6 +28,6 @@ export function onRequest ({ params }) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return Response.redirect('https://miru.watch/')
|
return Response.redirect('https://miguapp.pages.dev/')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue