✨ Add more data from scraper
This commit is contained in:
parent
e9a6ffd2b8
commit
0b85f0b053
1 changed files with 26 additions and 17 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Trakt Scraper
|
// @name Trakt Scraper
|
||||||
// @namespace danielrayjones
|
// @namespace danielrayjones
|
||||||
// @version 0.0.7
|
// @version 0.0.8
|
||||||
// @description Scrape lists of shows/movies from Trakt and download a JSON file
|
// @description Scrape lists of shows/movies from Trakt and download a JSON file
|
||||||
// @author Dan Jones
|
// @author Dan Jones
|
||||||
// @match https://trakt.tv/*
|
// @match https://trakt.tv/*
|
||||||
|
|
@ -36,6 +36,8 @@
|
||||||
let $ep = $(that);
|
let $ep = $(that);
|
||||||
let $series = $ep.find('[itemtype="http://schema.org/TVSeries"]');
|
let $series = $ep.find('[itemtype="http://schema.org/TVSeries"]');
|
||||||
|
|
||||||
|
let this_ep = $ep.data();
|
||||||
|
|
||||||
if ($series.length < 1) {
|
if ($series.length < 1) {
|
||||||
$series = $('[itemtype="http://schema.org/TVSeries"]');
|
$series = $('[itemtype="http://schema.org/TVSeries"]');
|
||||||
}
|
}
|
||||||
|
|
@ -78,34 +80,41 @@
|
||||||
|
|
||||||
let watched = watched_shows[series] ? watched_shows[series].e[ep] : null;
|
let watched = watched_shows[series] ? watched_shows[series].e[ep] : null;
|
||||||
|
|
||||||
let this_ep = {
|
let $img = $ep.find('[itemprop="image"]');
|
||||||
series_id: series,
|
if ($img.length > 0) {
|
||||||
episode_id: ep,
|
this_ep['image'] = $img.attr('content');
|
||||||
title,
|
}
|
||||||
url,
|
|
||||||
released,
|
this_ep['series_id'] = series;
|
||||||
watches: watched ? watched[1] : 0,
|
this_ep['episode_id'] = ep;
|
||||||
last_watched: watched ? watched[0] : null,
|
this_ep['title'] = title;
|
||||||
};
|
this_ep['url'] = url;
|
||||||
|
this_ep['released'] = released;
|
||||||
|
this_ep['watches'] = watched ? watched[1] : 0;
|
||||||
|
this_ep['last_watched'] = watched ? watched[0] : null;
|
||||||
|
|
||||||
return this_ep;
|
return this_ep;
|
||||||
}
|
}
|
||||||
|
|
||||||
function processMovie(that) {
|
function processMovie(that) {
|
||||||
let $mov = $(that);
|
let $mov = $(that);
|
||||||
|
let this_mov = $mov.data();
|
||||||
let id = $mov.data('movie-id');
|
let id = $mov.data('movie-id');
|
||||||
|
|
||||||
let title = $mov.children('[itemprop="name"]').attr('content');
|
let title = $mov.children('[itemprop="name"]').attr('content');
|
||||||
let url = $mov.children('[itemprop="url"]').attr('content');
|
let url = $mov.children('[itemprop="url"]').attr('content');
|
||||||
let watched = watched_movies[id];
|
let watched = watched_movies[id];
|
||||||
|
|
||||||
let this_mov = {
|
let $img = $mov.find('[itemprop="image"]');
|
||||||
id,
|
if ($img.length > 0) {
|
||||||
title,
|
this_mov['image'] = $img.attr('content');
|
||||||
url,
|
}
|
||||||
watches: watched ? watched[1] : 0,
|
|
||||||
last_watched: watched ? watched[0] : null,
|
this_mov['id'] = id;
|
||||||
};
|
this_mov['title'] = title;
|
||||||
|
this_mov['url'] = url;
|
||||||
|
this_mov['watches'] = watched ? watched[1] : 0;
|
||||||
|
this_mov['last_watched'] = watched ? watched[0] : null;
|
||||||
|
|
||||||
return this_mov;
|
return this_mov;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue