Last active
March 21, 2022 06:31
-
-
Save assafmo/c09be989ec2014fea9ceb2e293b3aeb1 to your computer and use it in GitHub Desktop.
Donwload english subs from addic7ed
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
#!/usr/bin/env node | |
// Newest version is in https://github.com/assafmo/ad7 | |
// Install: sudo npm install -g addic7ed-api | |
// Usage: node ad7.js "the flash" 4 8 | |
// Usage 2: chmod +x ad7.js; ./ad7.js "the flash" 4 8 | |
// Usage 3: chmod +x ad7.js; mv ad7.js /usr/local/bin/ad7; ad7 "the flash" 4 8 | |
// Usage 4: seq 1 4 | xargs -n 1 ad7 "the flash" 4 | |
const addic7edApi = require("addic7ed-api"); | |
const show = process.argv[2]; | |
const season = process.argv[3]; | |
const episode = process.argv[4]; | |
(async () => { | |
let subs = await addic7edApi.search(show, season, episode); | |
subs.sort((a, b) => b.link > a.link); // Newest versions first | |
const alreadyDownloaded = new Set(); | |
for (let subInfo of subs) { | |
if (subInfo.langId != "eng") { | |
continue; | |
} | |
let fileName = `${show.replace(/ /g, ".")}.`; | |
fileName += `S${season.length == 1 ? `0${season}` : season}`; | |
fileName += `E${episode.length == 1 ? `0${episode}` : episode}.`; | |
fileName += `${subInfo.distribution}.`; | |
fileName += `${subInfo.version}.`; | |
fileName += `${subInfo.team}.srt`; | |
fileName = fileName.replace(/\//g, "-"); | |
if (alreadyDownloaded.has(fileName)) { | |
continue; | |
} | |
console.log("Downloading", fileName); | |
await addic7edApi.download(subInfo, "./" + fileName); | |
alreadyDownloaded.add(fileName); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Newest version is in https://github.com/assafmo/ad7