Last active
December 18, 2022 20:12
-
-
Save kirill578/0ecaf6e205bffb01ef8806bece67298f to your computer and use it in GitHub Desktop.
Revisions
-
kirill578 revised this gist
Dec 18, 2022 . 1 changed file with 77 additions and 33 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,23 @@ (async () => { const getResolutions = async (m3u8url) => { const options = {}; try { const breakdown = await fetch(m3u8url).then(res => res.text()); const matches = breakdown.matchAll(/RESOLUTION=(\d+x\d+)\n(https:\/\/.*?m3u8)/g); for (const match of matches) { const [_, reso, url] = match; options[reso] = url; } } catch (e) { console.error(e); } return options; } const urlsSet = new Set(); const catId = new URLSearchParams(window.location.search).get('catId') ?? new URLSearchParams(window.location.search).get('catid'); if (catId) { urlsSet.add('https://www.kan.org.il/AppKan/itemJson.ashx?catId=' + catId); } @@ -14,6 +28,38 @@ urlsSet.add(url); } const getm3u8inHtml = async (html) => [...html.matchAll(/(https:\/\/.*?m3u8)/g)].map(a => a[1]) const pageHtml = await fetch(window.location.href).then((response) => response.text()); const m3u8onPage = await getm3u8inHtml(pageHtml); let html = ''; const all = []; for (let index = 0; index < m3u8onPage.length; index++) { const url = m3u8onPage[index]; all.push({ title: `on page ${index}`, ...await getResolutions(url) }) } const linkedPages = [...pageHtml.matchAll(/mailto:.*?(https:\/\/.*?)['"]/g)].map(a => a[1]); for (let index = 0; index < linkedPages.length; index++) { const linkedPage = linkedPages[index]; const pageHtml = await fetch(linkedPage).then((response) => response.text()); let title = linkedPage try { title = /<title>(.*?)<\/title>/g.exec(pageHtml)[1] } catch (e) { } const m3u8onPage = await getm3u8inHtml(pageHtml); for (let index = 0; index < m3u8onPage.length; index++) { const url = m3u8onPage[index]; all.push({ title, ...await getResolutions(url) }); } } const urls = [...urlsSet]; for (let index = 0; index < urls.length; index++) { const url = urls[index]; @@ -23,46 +69,44 @@ } catch (e) { continue; } all = [ ...all, ...await Promise.all(response.entry.map(async (ep) => { const options = { title: ep.extensions?.on_demand?.title ?? ep.title } if (ep.content.src.includes('m3u8')) { options = { ...options, ...await getResolutions(ep.content.src) } } return options }))]; } let didAddAnything = false all.forEach(({ title, ...other }) => { console.log(title) if (Object.keys(other).length > 0) { html += `<div>${title}</div>` } Object.entries(other).forEach(([res, url]) => { didAddAnything = true; const downloadUrl = `https://m3u8.dev/?source=${encodeURI(url)}`; html += `<a target="_blank" style="padding: 5px" href="${downloadUrl}">${res}</a>` }); if (didAddAnything) { html += `<br />` } }); if (didAddAnything) { document.documentElement.innerHTML = "<html><body>" + html; } })(); -
kirill578 revised this gist
Dec 18, 2022 . 1 changed file with 24 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,28 @@ (async () => { let html = "<html><body>"; const urlsSet = new Set(); const catId = new URLSearchParams(window.location.search).get('catId'); if (catId) { urlsSet.add('https://www.kan.org.il/AppKan/itemJson.ashx?catId=' + catId); } for (const match of document.documentElement.innerHTML.matchAll(/(itemJson.ashx.*?)['"]/g)) { const itemJsonPart = match[1]; const url = `https://www.kan.org.il/AppKan/${itemJsonPart}`; urlsSet.add(url); } const urls = [...urlsSet]; for (let index = 0; index < urls.length; index++) { const url = urls[index]; let response; try { response = await fetch(url).then(a => a.json()); } catch (e) { continue; } const all = await Promise.all(response.entry.map(async (ep) => { const options = { title: ep.extensions?.on_demand?.title ?? ep.title } try { @@ -32,6 +52,7 @@ html += `<a target="_blank" style="padding: 5px" href="${downloadUrl}">${res}</a>` }); if (didAddAnything) { html += `<br />` } @@ -41,5 +62,7 @@ html += `<br /><br /><br /><br />` } } document.documentElement.innerHTML = html })(); -
kirill578 revised this gist
Dec 18, 2022 . 1 changed file with 23 additions and 25 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,47 +1,45 @@ (async () => { let html = "<html><body>"; for (const match of document.documentElement.innerHTML.matchAll(/(itemJson.ashx.*?)['"]/g)) { const itemJsonPart = match[1]; const response = await fetch(`https://www.kan.org.il/AppKan/${itemJsonPart}`).then(a => a.json()); const all = await Promise.all(response.entry.map(async (ep) => { const options = { title: ep.extensions?.on_demand?.title ?? ep.title } try { if (ep.content.src.includes('m3u8')) { const breakdown = await fetch(ep.content.src).then(res => res.text()); const matches = breakdown.matchAll(/RESOLUTION=(\d+x\d+)\n(https:\/\/.*?m3u8)/g); for (const match of matches) { const [_, reso, url] = match; options[reso] = url; } } } catch (e) { console.log(e) } return options })); let didAddAnything = false all.forEach(({ title, ...other }) => { console.log(title) if (Object.keys(other).length > 0) { html += `<div>${title}</div>` } Object.entries(other).forEach(([res, url]) => { didAddAnything = true; const downloadUrl = `https://m3u8.dev/?source=${encodeURI(url)}`; html += `<a target="_blank" style="padding: 5px" href="${downloadUrl}">${res}</a>` }); if (didAddAnything) { html += `<br />` } }); if (didAddAnything) { html += `<br /><br /><br /><br />` } } document.documentElement.innerHTML = html })(); -
kirill578 created this gist
Dec 18, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ (async () => { let html = "<html><body>"; for (const match of document.documentElement.innerHTML.matchAll(/(itemJson.ashx.*?)['"]/g)) { const itemJsonPart = match[1]; const response = await fetch(`https://www.kan.org.il/AppKan/${itemJsonPart}`).then(a => a.json()); const all = await Promise.all(response.entry.map(async (ep) => { const breakdown = await fetch(ep.content.src).then(res => res.text()); const matches = breakdown.matchAll(/RESOLUTION=(\d+x\d+)\n(https:\/\/.*?m3u8)/g); const options = { title: ep.extensions?.on_demand?.title ?? ep.title } for (const match of matches) { const [_, reso, url] = match; options[reso] = url; } return options })); all.forEach(({ title, ...other }) => { console.log(title) html += `<div>${title}</div>` Object.entries(other).forEach(([res, url]) => { const downloadUrl = `https://m3u8.dev/?source=${encodeURI(url)}`; html += `<a target="_blank" style="padding: 5px" href="${downloadUrl}">${res}</a>` }); html += `<br />` console.log(" "); }); html += `<br /><br /><br /><br />` } document.documentElement.innerHTML = html })()