Last active
June 22, 2019 17:08
-
-
Save seeya/68340bc253dd5c1996ff02c8aef354cc to your computer and use it in GitHub Desktop.
icdrama.to script to extract download link and download with aria2c
This file contains 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 characters
// Prepare your links in the array | |
// To download the file use aria2c using the command | |
// aria2c -x8 -j8 --input-file=dl.txt | |
const puppeteer = require("puppeteer"); | |
const fs = require("fs"); | |
const links = [ | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-12-149928.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-13-150136.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-14-150140.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-15-150188.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-16-150192.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-17-150712.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-18-150716.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-19-148624.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-20-148964.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-21-148972.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-22-148956.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-23-148244.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-24-150280.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-25-147412.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-26-147416.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-27-150340.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-28-150336.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-29-152140.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-30-152144.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-31-152492.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-32-152496.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-33-153200.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-34-153204.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-35-153408.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-36-153412.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-37-153612.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-38-153616.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-39-154152.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-40-154156.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-41-154524.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-42-154528.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-43-154764.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-44-154768.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-45-154856.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-46-152588.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-47-152612.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-48-152604.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-49-155656.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-50-155660.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-51-155920.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-52-155924.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-53-154564.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-54-154560.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-55-156432.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-56-156436.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-57-156828.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-58-155444.html", | |
"http://www1.icdrama.to/watch-online-the-great-craftsman-episode-59-end-157252.html" | |
]; | |
async function getLink(page) { | |
page.goto(links[0]); | |
console.log("Waiting"); | |
await page.waitFor(8000); | |
/* | |
const f = await page.frames(); | |
for (let i = 0; i < f.length; i++) { | |
console.log(f[i].name()); | |
} | |
*/ | |
// The 720p button is in the iframe | |
const frame = await page.frames().find(f => f.name() === "iframeplayer"); | |
const button = await frame.$("#vb_sv_5"); | |
await button.click(); | |
} | |
(async () => { | |
const browser = await puppeteer.launch({ | |
headless: false, | |
args: ["--disable-features=site-per-process"], | |
executablePath: | |
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" | |
//executablePath: "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe" | |
}); | |
const page = await browser.newPage(); | |
await page.setRequestInterception(true); | |
await page.setViewport({ width: 1440, height: 798 }); | |
page.on("request", async request => { | |
let link = request.url(); | |
if ( | |
request.resourceType() === "image" || | |
link.indexOf("facebook") > -1 || | |
link.indexOf("twitter") > -1 || | |
link.indexOf("addthis.com") > -1 || | |
link.indexOf("gstatic.com") > -1 || | |
link.indexOf(".css") > -1 | |
) | |
request.abort(); | |
else { | |
//console.log(link); | |
if ( | |
link.indexOf("googleusercontent.com/docs/securesc/") !== -1 || | |
(link.indexOf("googlevideo.com") !== -1 && | |
link.indexOf("itag=22") !== -1) | |
) { | |
let title = await page.title(); | |
title = title.split("Episode ")[1]; | |
title = title.split(" ")[0]; | |
fs.appendFileSync("dl.txt", `${link}\n out=E${title}.mp4\n`); | |
console.log(title); | |
console.log(link); | |
links.splice(0, 1); | |
if (links.length > 0) { | |
getLink(page); | |
request.continue(); | |
} else { | |
browser.close(); | |
} | |
} else { | |
request.continue(); | |
} | |
} | |
}); | |
try { | |
getLink(page); | |
} catch (err) {} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment