Skip to content

Instantly share code, notes, and snippets.

@MrMamen
Created May 26, 2016 13:04
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 MrMamen/8a46e1567cf37c54b2f8279ba2641732 to your computer and use it in GitHub Desktop.
Save MrMamen/8a46e1567cf37c54b2f8279ba2641732 to your computer and use it in GitHub Desktop.
ItemParser.parse = function parse(callback) {
var item;
var type = document.querySelector("meta[name=type]").getAttribute("content") == 'episode' ? 'show' : 'movie';
var mainTitle = document.querySelector("meta[name=title]").getAttribute("content");
if (type === 'show') {
var uri = document.querySelector("li.episode-item.active a").getAttribute("href");
if (uri.split("/")[4].substring(0, 6) !== "sesong") {
return;
}
var season = uri.split("/")[4].slice(7);
var number = document.querySelector("meta[name=episodenumber]").getAttribute("content");
var title = document.querySelector("meta[name=seriestitle]").getAttribute("content");
item = new Item({
epTitle: mainTitle,
title: title,
season: season,
episode: number,
type: type
});
} else {
item = new Item({ title: mainTitle, type: type });
}
callback.call(this, item);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment