Skip to content

Instantly share code, notes, and snippets.

@assafmo
Last active March 21, 2022 06:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save assafmo/c09be989ec2014fea9ceb2e293b3aeb1 to your computer and use it in GitHub Desktop.
Save assafmo/c09be989ec2014fea9ceb2e293b3aeb1 to your computer and use it in GitHub Desktop.
Donwload english subs from addic7ed
#!/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);
}
})();
@assafmo
Copy link
Author

assafmo commented Dec 19, 2017

Newest version is in https://github.com/assafmo/ad7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment