diff --git a/app/app.html b/app/app.html
index 8c94242..d18e578 100644
--- a/app/app.html
+++ b/app/app.html
@@ -1,16 +1,21 @@
-
+
-
-
-
-
-
+
+
+
+
+
- Miru
+
+
+
+
+
+ Miru - Torrent streaming made simple!
-
+
@@ -126,7 +131,7 @@
-
+
-
+
diff --git a/app/css/player.css b/app/css/player.css
index e7c3665..3be1390 100644
--- a/app/css/player.css
+++ b/app/css/player.css
@@ -6,7 +6,6 @@
--buffer: 0%;
--height: 0;
color: #b6b6b6;
- font-size: 62.5%;
--nav-size: 19rem;
--ts: "";
}
diff --git a/app/js/animeHandler.js b/app/js/animeHandler.js
index 3d78512..da41975 100644
--- a/app/js/animeHandler.js
+++ b/app/js/animeHandler.js
@@ -292,10 +292,8 @@ async function nyaaRss(url) {
}
-let regex = /((?:\[[^\]]*\])*)?\s*((?:[^\d\[\.](?!S\d))*)?\s*((?:S\d+[^\w\[]*E?)?[\d\-]*)\s*(.*)?/,
- str = `[HorribleSubs] Black Clover - 143 [1080p].mkv`,
- m,
- store = {};
+const regex = /((?:\[[^\]]*\])*)?\s*((?:[^\d\[\.](?!S\d))*)?\s*((?:S\d+[^\w\[]*E?)?[\d\-]*)\s*(.*)?/;
+let store = {};
async function regtest() {
if ((m = regex.exec(str)) !== null) {
if (m[2].endsWith(" - ")) {
@@ -312,7 +310,7 @@ async function regtest() {
}
}
async function hsRss(url) {
- let frag = document.createDocumentFragment()
+ document.querySelector(".releases").innerHTML = ""
res = await fetch(url)
await res.text().then(async (xmlTxt) => {
try {
@@ -320,7 +318,7 @@ async function hsRss(url) {
let items = doc.querySelectorAll("item")
for (let item of items) {
let i = item.querySelector.bind(item),
- regexParse = regex.exec(i("title").textContent)
+ regexParse = regex.exec(i("title").textContent)
if (regexParse[2].endsWith(" - ")) {
regexParse[2] = regexParse[2].slice(0, -3)
}
@@ -332,10 +330,11 @@ async function hsRss(url) {
let media = store[regexParse[2]]
let template = document.createElement("div")
template.classList.add("card", "m-0", "p-0")
- template.innerHTML = `
+ if (media) {
+ template.innerHTML = `
-
@@ -357,15 +356,36 @@ async function hsRss(url) {
`
+ } else {
+ template.innerHTML = `
+
+
+
![]()
+
+
+
+
${regexParse[2]} - ${regexParse[3]}
+
+
+
+
+
+
+
+ `
+ }
template.onclick = function () {
selected = [store[regexParse[2]], regexParse[3]]
addTorrent(i('link').textContent)
}
- frag.appendChild(template)
+ document.querySelector(".releases").appendChild(template)
}
} catch (e) {
console.error(e)
}
})
- document.querySelector(".releases").appendChild(frag)
-}
\ No newline at end of file
+}
+// setTimeout(() => {
+// hsRss("http://www.horriblesubs.info/rss.php?res=1080")
+// }, 4000);
\ No newline at end of file
diff --git a/app/js/playerHandler.js b/app/js/playerHandler.js
index aa72223..3b0cff5 100644
--- a/app/js/playerHandler.js
+++ b/app/js/playerHandler.js
@@ -208,7 +208,7 @@ function bpp() {
}
function bnext() {
- nyaaSearch(nowPlaying[0], nowPlaying[1] + 1)
+ nyaaSearch(nowPlaying[0], parseInt(nowPlaying[1]) + 1)
}
// volume shit
diff --git a/app/js/subtitleHandler.js b/app/js/subtitleHandler.js
index b995fbd..f2801b2 100644
--- a/app/js/subtitleHandler.js
+++ b/app/js/subtitleHandler.js
@@ -1,15 +1,12 @@
let tracks = [],
parser
-
function parseSubs(range, stream) {
if (video.src.endsWith(".mkv")) {
- console.log('set parser', range)
-
parser = new MatroskaSubtitles({ prevInstance: parser, offset: range.start })
-
parser.once('tracks', function (pTracks) {
tracks = []
+ video.textTracks = {}
pTracks.forEach(track => {
tracks[track.number] = video.addTextTrack('captions', track.type, track.language || track.number)
})
@@ -17,11 +14,9 @@ function parseSubs(range, stream) {
video.textTracks[0].mode = "showing"
}
})
-
parser.once('cues', function () {
console.log('seeking ready')
})
-
parser.on('subtitle', function (subtitle, trackNumber) {
subConvt(subtitle, trackNumber)
})
@@ -58,10 +53,10 @@ function subConvt(result, trackNumber) {
cue.line = 0.5;
} else if (Math.floor((posNum - 1) / 3) == 2) {
cue.line = 0;
+ cue.text = " \r\n"
}
if (posNum % 3 == 1) {
cue.align = "start";
- cue.text = " \r\n"
} else if (posNum % 3 == 0) {
cue.align = "end";
}
@@ -72,10 +67,10 @@ function subConvt(result, trackNumber) {
cue.line = 0.5;
} else if (posNum > 4) {
cue.line = 0;
+ cue.text = " \r\n"
}
if ((posNum - 1) % 4 == 0) {
cue.align = "start";
- cue.text = " \r\n"
} else if ((posNum - 1) % 4 == 2) {
cue.align = "end";
}
diff --git a/app/js/sw.js b/app/js/sw.js
deleted file mode 100644
index 470e556..0000000
--- a/app/js/sw.js
+++ /dev/null
@@ -1,55 +0,0 @@
-self.addEventListener('activate', evt => {
- return self.clients.claim()
-})
-
-self.addEventListener('fetch', evt => {
- const { request } = evt
- const { url, method, headers } = request
- if (!url.includes(self.registration.scope + 'webtorrent/')) return null
-
- function getConsumer(clients) {
- return new Promise(rs => {
- // Use race condition for whoever controls the response stream
- for (const client of clients) {
- const mc = new MessageChannel()
- const {port1, port2} = mc
- port1.onmessage = evt => {
- rs([evt.data, mc])
- }
- client.postMessage({
- url,
- method,
- headers: [...headers],
- scope: self.registration.scope
- }, [port2])
- }
- })
- }
-
- evt.respondWith(
- clients.matchAll({ type: 'window', includeUncontrolled: true })
- .then(getConsumer)
- .then(([data, mc]) => {
- const body = data.body === 'stream' ? new ReadableStream({
- pull(controller) {
- return new Promise(rs => {
- mc.port1.onmessage = evt => {
- evt.data
- ? controller.enqueue(evt.data) // evt.data is Uint8Array
- : controller.close() // evt.data is null, means the stream ended
- rs()
- }
- mc.port1.postMessage(true) // send a pull request
- })
- },
- cancel() {
- // This event is never executed
- mc.port1.postMessage(false) // send a cancel request
- }
- }) : data.body
-
- return new Response(body, data)
- })
- .catch(console.error)
- )
-})
\ No newline at end of file
diff --git a/app/js/torrentHandler.js b/app/js/torrentHandler.js
index 22b7fca..dee20fa 100644
--- a/app/js/torrentHandler.js
+++ b/app/js/torrentHandler.js
@@ -48,15 +48,15 @@ WEBTORRENT_ANNOUNCE = announceList
var nowPlaying,
maxTorrents = 1,
subStream
-function addTorrent(magnet) {
+async function addTorrent(magnet) {
if (client.torrents.length >= maxTorrents) {
client.remove(client.torrents[0].infoHash)
}
halfmoon.hideModal("tsearch")
document.location.href = "#player"
+ video.src = ""
+ await sw
client.add(magnet, async function (torrent) {
- video.src = ""
- await sw
function onProgress() {
peers.textContent = torrent.numPeers
downSpeed.textContent = prettyBytes(torrent.downloadSpeed) + '/s'
diff --git a/app/offline.html b/app/offline.html
new file mode 100644
index 0000000..e69de29
diff --git a/app/sw.js b/app/sw.js
new file mode 100644
index 0000000..bd3f81f
--- /dev/null
+++ b/app/sw.js
@@ -0,0 +1,104 @@
+'use strict';
+
+const CACHE_NAME = 'static-cache-v1';
+
+const FILES_TO_CACHE = [
+ 'offline.html',
+ 'app.html',
+ 'js/animeHandler.js',
+ 'js/bundle.js',
+ 'js/playerHandler.js',
+ 'js/subtitleHandler.js',
+ 'js/torrentHandler.js',
+ 'js/util.js',
+ 'css/misc.css',
+ 'css/player.css',
+ 'logo.png'
+];
+
+self.addEventListener('install', (evt) => {
+ evt.waitUntil(
+ caches.open(CACHE_NAME).then((cache) => {
+ return cache.addAll(FILES_TO_CACHE);
+ })
+ );
+ self.skipWaiting();
+});
+
+self.addEventListener('activate', (evt) => {
+ evt.waitUntil(
+ caches.keys().then((keyList) => {
+ return Promise.all(keyList.map((key) => {
+ if (key !== CACHE_NAME) {
+ return caches.delete(key);
+ }
+ }));
+ })
+ );
+ self.clients.claim();
+});
+
+self.addEventListener('fetch', evt => {
+ const { request } = evt
+ const { url, method, headers } = request
+ if (!url.includes(self.registration.scope + 'webtorrent/')) return null
+
+ function getConsumer(clients) {
+ return new Promise(rs => {
+ // Use race condition for whoever controls the response stream
+ for (const client of clients) {
+ const mc = new MessageChannel()
+ const { port1, port2 } = mc
+ port1.onmessage = evt => {
+ rs([evt.data, mc])
+ }
+ client.postMessage({
+ url,
+ method,
+ headers: [...headers],
+ scope: self.registration.scope
+ }, [port2])
+ }
+ })
+ }
+
+ evt.respondWith(
+ clients.matchAll({ type: 'window', includeUncontrolled: true })
+ .then(getConsumer)
+ .then(([data, mc]) => {
+ const body = data.body === 'stream' ? new ReadableStream({
+ pull(controller) {
+ return new Promise(rs => {
+ mc.port1.onmessage = evt => {
+ evt.data
+ ? controller.enqueue(evt.data) // evt.data is Uint8Array
+ : controller.close() // evt.data is null, means the stream ended
+ rs()
+ }
+ mc.port1.postMessage(true) // send a pull request
+ })
+ },
+ cancel() {
+ // This event is never executed
+ mc.port1.postMessage(false) // send a cancel request
+ }
+ }) : data.body
+
+ return new Response(body, data)
+ })
+ .catch(console.error)
+ )
+})
+
+// self.addEventListener('fetch', (evt) => {
+// if (evt.request.mode !== 'navigate') {
+// return;
+// }
+// evt.respondWith(
+// fetch(evt.request)
+// .catch(async () => {
+// const cache = await caches.open(CACHE_NAME);
+// return cache.match('offline.html');
+// })
+// );
+// });
diff --git a/index.html b/index.html
index afa728f..11252cf 100644
--- a/index.html
+++ b/index.html
@@ -1,34 +1,36 @@
-
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
+
+
+
+
+
-
-
-
-
-
+
+ Miru - Torrent streaming made simple!
+
+
-
-
- test
+
+
+
-
\ No newline at end of file
diff --git a/manifest.json b/manifest.json
index 30783b5..319559f 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,5 +1,5 @@
{
- "name": "Miru",
+ "name": "Miru - Torrent streaming made simple!",
"short_name": "Miru",
"start_url": "/app/app.html",
"display": "standalone",
@@ -8,15 +8,20 @@
],
"lang": "en-US",
"orientation": "landscape",
- "background_color": "#25282c",
- "theme_color": "#25282c",
+ "background_color": "#111417",
+ "theme_color": "#111417",
"scope": "/app/",
- "description": "Way too high quality anime for streaming, ad free in a simple solution.",
+ "description": "Anime torrent streaming, ad free in a simple solution.",
"icons": [
{
"src": "/logo.png",
"sizes": "768x768",
"type": "image/png"
}
- ]
+ ],
+ "intent_filters": {
+ "scope_url_scheme": "https",
+ "scope_url_host": "miru.moe",
+ "scope_url_path": "/app/"
+ }
}
\ No newline at end of file
diff --git a/sw.js b/sw.js
index 054c3d6..9b4011c 100644
--- a/sw.js
+++ b/sw.js
@@ -1,53 +1 @@
-'use strict';
-
-const CACHE_NAME = 'static-cache-v1';
-
-const FILES_TO_CACHE = [
- '/offline.html',
-];
-
-self.addEventListener('install', (evt) => {
- console.log('[ServiceWorker] Install');
- // CODELAB: Precache static resources here.
- evt.waitUntil(
- caches.open(CACHE_NAME).then((cache) => {
- console.log('[ServiceWorker] Pre-caching offline page');
- return cache.addAll(FILES_TO_CACHE);
- })
- );
- self.skipWaiting();
-});
-
-self.addEventListener('activate', (evt) => {
- console.log('[ServiceWorker] Activate');
- // CODELAB: Remove previous cached data from disk.
- evt.waitUntil(
- caches.keys().then((keyList) => {
- return Promise.all(keyList.map((key) => {
- if (key !== CACHE_NAME) {
- console.log('[ServiceWorker] Removing old cache', key);
- return caches.delete(key);
- }
- }));
- })
- );
- self.clients.claim();
-});
-
-self.addEventListener('fetch', (evt) => {
- console.log('[ServiceWorker] Fetch', evt.request.url);
- // CODELAB: Add fetch event handler here.
- if (evt.request.mode !== 'navigate') {
- // Not a page navigation, bail.
- return;
- }
- evt.respondWith(
- fetch(evt.request)
- .catch(() => {
- return caches.open(CACHE_NAME)
- .then((cache) => {
- return cache.match('offline.html');
- });
- })
- );
-});
+self.addEventListener('fetch',(event)=>{});
\ No newline at end of file