diff --git a/lib/DDG/Spice/Guidebox/Getid.pm b/lib/DDG/Spice/Guidebox/Getid.pm
index 28758066ea..1069f94298 100644
--- a/lib/DDG/Spice/Guidebox/Getid.pm
+++ b/lib/DDG/Spice/Guidebox/Getid.pm
@@ -20,6 +20,10 @@ spice to => 'http://api-public.guidebox.com/v1.3/json/{{ENV{DDG_SPICE_GUIDEBOX_A
spice wrap_jsonp_callback => 1;
+my %skip = map { $_ => 0 } (
+ 'watchmen'
+);
+
handle remainder => sub {
if ($loc->country_name eq "United States" || $loc->country_name eq "Canada"){
@@ -38,7 +42,8 @@ handle remainder => sub {
} else {
$show = $_;
}
- return $show if $show;
+
+ return $show if $show && !exists $skip{lc $show};
}
return;
};
diff --git a/lib/DDG/Spice/Guidebox/Lastshows.pm b/lib/DDG/Spice/Guidebox/Lastshows.pm
index 44d398c1e4..fac159c470 100644
--- a/lib/DDG/Spice/Guidebox/Lastshows.pm
+++ b/lib/DDG/Spice/Guidebox/Lastshows.pm
@@ -6,8 +6,6 @@ triggers any => "///***never_trigger***///";
spice to => 'http://api-public.guidebox.com/v1.3/json/{{ENV{DDG_SPICE_GUIDEBOX_APIKEY}}}/$1/watch/all/20';
-spice wrap_jsonp_callback => 1;
-
handle remainder => sub {
# TODO
diff --git a/share/spice/guidebox/getid/buy.handlebars b/share/spice/guidebox/getid/buy.handlebars
new file mode 100644
index 0000000000..2cde20cba6
--- /dev/null
+++ b/share/spice/guidebox/getid/buy.handlebars
@@ -0,0 +1,6 @@
+
+
+ Watch Now
+
+ {{#unless is_free_content}}
Paid Content {{/unless}}
+
\ No newline at end of file
diff --git a/share/spice/guidebox/getid/guidebox_getid.css b/share/spice/guidebox/getid/guidebox_getid.css
index 1063b1ca34..4dccd0bb75 100644
--- a/share/spice/guidebox/getid/guidebox_getid.css
+++ b/share/spice/guidebox/getid/guidebox_getid.css
@@ -1,48 +1,43 @@
-.zci--guidebox li.ddgc_item img {
- max-width: 100% !important;
- max-height: 68px !important;
+.zci__more-at__icon{
+ padding-bottom: 0.3em;
}
-.zci--guidebox div.image_wrap {
+.detail--guidebox .price{
position: relative;
+ top: -0.5em;
+ font-size: 0.9em;
+ color: #777777;
+ font-weight: normal;
}
-.zci--guidebox .gb_info {
- white-space: nowrap;
- word-wrap: break-word;
- text-overflow: ellipsis;
- overflow: hidden;
- margin: 0px !important
+.detail--guidebox .paid{
+ color: #c9481c;
+ font-weight: bold;
}
-.zci--guidebox .button {
- display: inline-block;
- border-radius: 3px;
- padding: 3px 9px;
- background: #fefefe;
- border: 1px solid #bbb;
- color: black;
- margin-right: 10px;
+.is-mobile .detail--guidebox .price{
+ display: none;
}
-.zci--guidebox .button:hover {
- border: 1px solid #80b5ff;
- cursor: pointer;
- text-decoration: none;
+.is-mobile .detail--guidebox .btn--primary{
+ position: absolute;
+ bottom: 1.1em;
}
-.zci--guidebox #ddgc_detail p {
- margin-bottom: 10px;
+.detail--guidebox .detail__body--pr{
+ border-left: 0px;
}
-.zci--guidebox .grey {
- color: grey;
+.detail--guidebox .detail__desc{
+ padding-bottom: 1.3em;
}
-.zci--guidebox .red {
- color: #B57367
+.is-mobile .detail--guidebox .paid{
+ position: absolute;
+ padding-left: 7.5em;
+ bottom: 1.8em;
}
-.zci--guidebox .small {
- font-size: 13px;
+.detail--guidebox .btn--primary{
+ margin-right: 0.75em;
}
\ No newline at end of file
diff --git a/share/spice/guidebox/getid/guidebox_getid.handlebars b/share/spice/guidebox/getid/guidebox_getid.handlebars
deleted file mode 100644
index 95dcfe064f..0000000000
--- a/share/spice/guidebox/getid/guidebox_getid.handlebars
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
- {{#checkSeason season_number episode_number}}
- Season {{season_number}}, Ep. {{episode_number}}
- {{/checkSeason}}
- {{{episode_name}}}
-
\ No newline at end of file
diff --git a/share/spice/guidebox/getid/guidebox_getid.js b/share/spice/guidebox/getid/guidebox_getid.js
index 772f600b1e..1ab8f91ef8 100644
--- a/share/spice/guidebox/getid/guidebox_getid.js
+++ b/share/spice/guidebox/getid/guidebox_getid.js
@@ -1,141 +1,115 @@
-function ddg_spice_guidebox_getid (api_result) {
- "use strict";
+(function(env){
+ "use strict";
+ env.ddg_spice_guidebox_getid = function(api_result) {
- if (!api_result.results) {
- return;
- }
-
- var SKIP_ARRAY = ["online","tv","episode","episodes","free","guidebox","watch","full"],
- results = api_result.results.result,
- relevant;
-
- // Check which show is relevant to our query.
- $.each(results, function(key, result) {
- if (DDG.isRelevant(result.title, SKIP_ARRAY, 3) && !relevant) {
- relevant = result;
+ if (!api_result || !api_result.results) {
+ return Spice.failed('guidebox');
}
- });
- // Exit if we didn't find anything relevant.
- if (!relevant) {
- return;
- }
-
- // Prevent jQuery from appending "_={timestamp}" in our url.
- $.ajaxSetup({
- cache: true
- });
+ var SKIP_ARRAY = ["online","tv","episode","episodes","free","guidebox","watch","full"],
+ results = api_result.results.result,
+ relevant;
- var script = $('[src*="/js/spice/guidebox/getid/"]')[0],
- source = decodeURIComponent($(script).attr("src")),
- matched = source.match(/\/js\/spice\/guidebox\/getid\/([a-zA-Z0-9\s]+)/),
- query = matched[1];
+ // Check which show is relevant to our query.
+ $.each(results, function(key, result) {
+ if (DDG.isRelevant(result.title, SKIP_ARRAY, 3) && !relevant) {
+ relevant = result;
+ }
+ });
- var metadata = {
- res_title : relevant.title,
- network : relevant.network,
- more : relevant.url,
- query : query,
- };
-
- ddg_spice_guidebox_getid.metadata = metadata;
- $.getScript("/js/spice/guidebox/lastshows/series/" + relevant.id);
-}
-
-function ddg_spice_guidebox_lastshows (api_result) {
- "use strict";
-
- var metadata = ddg_spice_guidebox_getid.metadata;
+ // Exit if we didn't find anything relevant.
+ if (!relevant) {
+ return;
+ }
- function toArray(obj) {
- var result = [];
- if($.isArray(obj)) {
- return obj;
- } else {
- $.each(obj, function(key, value) {
- result[key] = value;
- });
- return result;
- }
+ // Prevent jQuery from appending "_={timestamp}" in our url.
+ $.ajaxSetup({
+ cache: true
+ });
+
+ var metadata = {
+ res_title : relevant.title,
+ network : relevant.network,
+ more : relevant.url
+ };
+
+ var url = '/js/spice/guidebox/lastshows/series/' + relevant.id;
+
+ $.getJSON(url, function(api_result) {
+
+ if(!api_result){
+ return Spice.failed('guidebox');
+ }
+
+ var isMobile = $('.is-mobile').length;
+
+ Spice.add({
+ id: 'guidebox',
+ name: 'TV',
+ data: toArray(api_result.results.result),
+ meta: {
+ sourceName: "Guidebox",
+ sourceUrl: metadata.more,
+ itemType: 'episodes of ' + metadata.res_title
+ },
+ templates: {
+ group: 'media',
+ options: {
+ variant: "video",
+ price: true,
+ buy: Spice.guidebox_getid.buy
+ }
+ },
+ normalize: function(item){
+ var subtitle_tile = "Season "+ item.season_number+ ", #" + item.episode_number;
+ var subtitle_detail = "(Season "+ item.season_number+ ", #" + item.episode_number+")";
+
+ var abstract_length = (isMobile ? 175 : 500);
+ var abstract = Handlebars.helpers.ellipsis(item.overview, abstract_length);
+
+ var aired = "Originally aired "+ Handlebars.helpers.guideBox_getDate(item.first_aired)
+ + " on "+ metadata.network;
+
+ return {
+ image: item.thumbnail_304x171,
+ img: item.thumbnail_400x225,
+ title: item.episode_name,
+ ratingText: subtitle_tile,
+ heading: item.episode_name + subtitle_detail,
+ url: item.smart_url,
+ abstract: abstract,
+ price: aired
+ }
+ },
+ relevancy: {
+ primary: [
+ {required: 'episode_name'},
+ {required: 'season_number'},
+ {required: 'overview'}
+ ]
+ }
+ });
+ });
}
- Spice.add({
- data : toArray(api_result.results.result),
- header1 : metadata.res_title + " (TV - " + metadata.network + ")",
- sourceName : "Guidebox",
- sourceUrl : metadata.more,
- view: "Tiles",
- id : "guidebox",
- templates : {
- items : api_result.results.result,
- item: Spice.guidebox_getid.guidebox_getid,
- detail: Spice.guidebox_getid.guidebox_getid_details,
- li_width : 120,
- li_height : 105
+ function toArray(obj) {
+ var result = [];
+ if($.isArray(obj)) {
+ return obj;
+ } else {
+ $.each(obj, function(key, value) {
+ result[key] = value;
+ });
+ return result;
}
- });
-};
-
-Handlebars.registerHelper("checkSeason", function(season_number, episode_number, options) {
- "use strict";
-
- if(season_number !== "0") {
- return options.fn({
- season_number: season_number,
- episode_number: episode_number
- });
}
-});
-
-Handlebars.registerHelper("getQuery", function() {
- "use strict";
-
- return ddg_spice_guidebox_getid.metadata.query;
-});
-
-Handlebars.registerHelper("getTitle", function() {
- "use strict";
-
- return ddg_spice_guidebox_getid.metadata.res_title;
-});
-Handlebars.registerHelper("getDate", function(first_aired) {
- "use strict";
+ Handlebars.registerHelper("guideBox_getDate", function(first_aired) {
- var aired = DDG.getDateFromString(first_aired),
+ var aired = DDG.getDateFromString(first_aired),
days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],
months = [ 'January','February','March','April','May','June','July','August','September','October','November','December'];
- return days[aired.getDay()] + ", " + months[aired.getMonth()] + " " + aired.getDate() + ", " + aired.getFullYear()
-});
-
-Handlebars.registerHelper("pluralize", function(string, options) {
- "use strict";
-
- if (options.hash && options.hash.singular && options.hash.plural){
- var arr = string.split("|");
- return arr.length > 1 ? options.hash.plural : options.hash.singular
- }
- return "";
-});
-
-Handlebars.registerHelper("split", function(string) {
- "use strict";
-
- return string.replace(/^\||\|$/g, "").replace(/\|/g, ", ");
-});
-
-Handlebars.registerHelper("creators", function(options) {
- "use strict";
-
- if (this.writers.length || this.directors.length){
- return options.fn(this)
- }
- return "";
-});
-
-Handlebars.registerHelper("get_network", function(options) {
- "use strict";
-
- return ddg_spice_guidebox_getid.metadata.network;
-});
+ return days[aired.getDay()] + ", " + months[aired.getMonth()] + " " + aired.getDate() + ", " + aired.getFullYear()
+ });
+}(this));
\ No newline at end of file
diff --git a/share/spice/guidebox/getid/guidebox_getid_details.handlebars b/share/spice/guidebox/getid/guidebox_getid_details.handlebars
deleted file mode 100644
index 49fa403e40..0000000000
--- a/share/spice/guidebox/getid/guidebox_getid_details.handlebars
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
- Watch Now
- {{#checkSeason season_number episode_number}}
- {{{episode_name}}} (season {{season_number}}, #{{episode_number}})
- {{/checkSeason}}
- {{#unless is_free_web}} Paid Content{{/unless}}
-
-
-
- {{overview}}
-
-
-
Originally aired {{getDate first_aired}} on {{get_network}}
-
\ No newline at end of file