Skip to content

Commit

Permalink
Fix so it parses items for scrobbling again.
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMamen committed Oct 12, 2019
1 parent 5c77042 commit 55b4322
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 40 deletions.
2 changes: 1 addition & 1 deletion app/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "__MSG_appName__",
"short_name": "__MSG_appShortName__",
"version": "2.2.6",
"version": "2.3.0",
"manifest_version": 2,
"description": "__MSG_appDescription__",
"icons": {
Expand Down
58 changes: 21 additions & 37 deletions app/scripts/src/content/item-parser.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
var Rollbar = require('../rollbar.js');
const Rollbar = require('../rollbar.js');

var Item = require('./item.js');
const Item = require('./item.js');

function ItemParser() {}

Expand All @@ -10,48 +10,30 @@ ItemParser.isEpisodeOrMovie = function () {
};

ItemParser.isReady = function checkPage() {
var type = document.querySelector("meta[name=type]");
if (!type) {
return document.querySelector("a.tv-series-episodes__episode-link--active") !== null;
}
return true;
return document.querySelector("a.tv-series-episode-list-item--active") !== null || document.querySelector("h1.tv-program-header__title") !== null;
};

ItemParser.parse = function parse(callback) {
var item;
var type;
var mainTitle;
var typeElement = document.querySelector("meta[name=type]");
if (typeElement) {
switch(typeElement.getAttribute("content")) {
//Old format
case 'program':
type = "movie";
mainTitle = document.querySelector("meta[name=title]").getAttribute("content");
item = new Item({ title: mainTitle, type: type });
break;
case 'episode':
type = "show";
mainTitle = document.querySelector("meta[name=title]").getAttribute("content");
Rollbar.info("Seems to not be a season based series", mainTitle);
return;
default:
Rollbar.error("Unknown series/movie type", typeElement.getAttribute("content"));
return;
}
} else {
//new format as of july 2018 "/serie/narvestad-tar-ferie/sesong/1/episode/6"
let item;
let type;
let mainTitle;
const movieTitleElement = document.querySelector(".tv-program-header__title");
const seriesTitleElement = document.querySelector(".tv-series-hero__title");
if (movieTitleElement) {
type = "movie";
const movieTitle = movieTitleElement.textContent
item = new Item({ title: movieTitle, type: type });
} else if (seriesTitleElement) {
type = "show";
mainTitle = document.querySelector(".tv-series-hero__title").textContent;
var uri = document.querySelector("a.tv-series-episodes__episode-link--active").getAttribute("href");
mainTitle = seriesTitleElement.textContent;
const uri = document.querySelector("a.tv-series-episode-list-item--active").getAttribute("href");
if (!uri.split('/')[3] || uri.split('/')[3] !== 'sesong') {
Rollbar.error("Unexpected URL-format", uri);
return;
}
var nrkSeriesId = uri.split("/")[2];
var season = uri.split("/")[4];
var number = uri.split("/")[6];
// var epTitle = document.querySelector('a[itemprop="name"]').innerHTML;
const nrkSeriesId = uri.split("/")[2];
const season = uri.split("/")[4];
const number = uri.split("/")[6];

item = new Item({
title: mainTitle,
Expand All @@ -60,6 +42,8 @@ ItemParser.parse = function parse(callback) {
type: type,
nrkId: nrkSeriesId
});
} else {
Rollbar.error("Unknown series/movie type", typeElement.getAttribute("content"));
}
callback.call(this, item);
};
Expand All @@ -70,7 +54,7 @@ ItemParser.start = function start(callback) {
callback.call(this, null);
return;
}
var readyTimeout;
let readyTimeout;

if (ItemParser.isReady()) {
ItemParser.parse(callback);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
"fetch-polyfill": "^0.8.2",
"grunt": "0.4.5",
"grunt-karma": "0.12.0",
"gulp": "3.9.0",
"gulp": "^3.9.1",
"gulp-autoprefixer": "2.3.1",
"gulp-concat": "2.6.0",
"gulp-if": "1.2.5",
"gulp-minify-css": "1.2.0",
"gulp-replace-task": "0.11.0",
"gulp-uglify": "3.0.0",
"gulp-zip": "3.0.2",
"gulp-zip": "^4.2.0",
"istanbul": "0.3.17",
"karma-browserify": "4.2.1",
"karma-chrome-launcher": "0.2.0",
Expand Down

0 comments on commit 55b4322

Please sign in to comment.