Skip to content

Instantly share code, notes, and snippets.

@bit2shift
Created September 7, 2018 09:21
Show Gist options
  • Save bit2shift/7d066b2dfe6e5650c8b654f0c6ee56a6 to your computer and use it in GitHub Desktop.
Save bit2shift/7d066b2dfe6e5650c8b654f0c6ee56a6 to your computer and use it in GitHub Desktop.
Generates a list of filenames for each episode of a season from a series on IMDB
'use strict';
{
let _2digits = n => ('0' + n).slice(-2);
let name = document.querySelector('[itemprop=url]').text;
let season = document.querySelector('#bySeason').value;
let titles = [];
document.querySelectorAll('meta[itemprop=episodeNumber], a[itemprop=name]').forEach
(
function(e, i)
{
switch(e.tagName)
{
case 'META':
titles[i >> 1] = `${name} S${_2digits(season)}E${_2digits(e.content)} - `;
break;
case 'A':
titles[i >> 1] += `${e.title}.mkv`;
break;
}
}
);
console.log(titles.join('\n'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment