Skip to content

Commit ec16122

Browse files
committed
cosmetics
1 parent 7e8c233 commit ec16122

2 files changed

Lines changed: 116 additions & 1 deletion

File tree

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,29 @@ Two requests then cover the whole catalogue:
132132
first — Pluto's own order is editorial and is not in the response, so there
133133
is nothing faithful to copy.
134134

135-
What goes into which half is asked for by name. Having seasons — or being
135+
Labelling an item a film is not the same as belonging in Movies. A handball
136+
match, a diving championship and an MTV Unplugged concert all come back typed
137+
`movie` — each with its own `seriesID`, no seasons, nothing in the item to say
138+
otherwise — and the site files them under Sport, under Musik and under the
139+
series *MTV Unplugged*. Nothing on the item separates them from a documentary
140+
or a stand-up special, which do belong in Movies.
141+
142+
The catalogue answers it indirectly. Its categories are grouped by
143+
`mainCategories` into a dozen or so sections, and one of them holds nothing
144+
but films — not a single series among them. That is where the site's own
145+
Movies rows come from, so the genres appearing in it are, by construction, the
146+
genres Pluto treats as film genres. Sports and Music are never among them;
147+
Documentary, Comedy, Drama and Horror always are.
148+
149+
So that section is read for its *genres* rather than its contents, and every
150+
film in those genres counts wherever it happens to be filed. Reading it for
151+
its contents instead would lose the documentaries and the stand-up, which live
152+
in mixed sections of their own. Nothing here is named or numbered: the section
153+
ids are regional, the genre list is whatever that section turns out to hold,
154+
and both are read afresh from every response. A catalogue with no film-only
155+
section falls back to leaving every film where it is.
156+
157+
What goes into which half is otherwise asked for by name. Having seasons — or being
136158
labelled a series — is what makes something a show; being labelled a film is
137159
what makes something a film. The catalogue holds more than the two: Sports
138160
and News are full of single items that are neither, and taking "not a series"

webapp/pluto.js

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,96 @@ var Pluto = (function () {
885885

886886
var vodIndex = null;
887887

888+
/*
889+
* Which genres are film genres.
890+
*
891+
* Labelling an item "movie" is not the same as belonging in Movies. A
892+
* handball match, a diving championship and an MTV Unplugged concert all
893+
* come back typed as films -- each with its own seriesID, no seasons,
894+
* nothing in the item to say otherwise -- and the site still files them
895+
* under Sport, under Musik and under the series MTV Unplugged. Nothing on
896+
* the item distinguishes them from a documentary or a stand-up special,
897+
* which do belong in Movies.
898+
*
899+
* The catalogue answers it indirectly. Its categories are grouped by
900+
* mainCategories into a dozen or so sections, and one of them holds
901+
* nothing but films -- not a single series among them. That section is
902+
* where the site's own Movies rows come from, so the genres appearing in
903+
* it are, by construction, the genres Pluto considers film genres. Sports
904+
* and Music are never among them; Documentary, Comedy, Drama and Horror
905+
* always are.
906+
*
907+
* So the section is read for its genres rather than its contents, and
908+
* every film in those genres counts wherever it happens to be filed. That
909+
* keeps the documentaries and the stand-up, which live in mixed sections
910+
* of their own, while still leaving out the matches and the concerts.
911+
* Nothing here is named or numbered: the ids are regional, the genre list
912+
* is whatever that section turns out to contain, and both are read afresh
913+
* from each response.
914+
*/
915+
function filmSections(list) {
916+
var known = {};
917+
var mixed = {};
918+
var sections = {};
919+
920+
list.forEach(function (c) {
921+
var holdsSeries = (c.items || []).some(isSeries);
922+
923+
(c.mainCategories || []).forEach(function (m) {
924+
var id = text(m.categoryID);
925+
if (!id) {
926+
return;
927+
}
928+
known[id] = true;
929+
if (holdsSeries) {
930+
mixed[id] = true;
931+
}
932+
});
933+
});
934+
935+
Object.keys(known).forEach(function (id) {
936+
if (!mixed[id]) {
937+
sections[id] = true;
938+
}
939+
});
940+
941+
return sections;
942+
}
943+
944+
/*
945+
* Null rather than an empty set when the catalogue has no section of its
946+
* own for films, or is arranged some way this does not recognise. The
947+
* caller then leaves every film where it is, so Movies is looser than the
948+
* site rather than empty.
949+
*/
950+
function filmGenres(list) {
951+
var sections = filmSections(list);
952+
var genres = {};
953+
var found = false;
954+
955+
list.forEach(function (c) {
956+
var filed = (c.mainCategories || []).some(function (m) {
957+
return sections[text(m.categoryID)] === true;
958+
});
959+
960+
if (!filed) {
961+
return;
962+
}
963+
964+
(c.items || []).forEach(function (item) {
965+
if (isSeries(item)) {
966+
return;
967+
}
968+
genres[text(item.genre) || "Other"] = true;
969+
found = true;
970+
});
971+
});
972+
973+
return found ? genres : null;
974+
}
975+
888976
function buildIndex(list) {
977+
var films = filmGenres(list);
889978
var seen = {};
890979
var ix = {movies: {}, shows: {}};
891980

@@ -901,6 +990,10 @@ var Pluto = (function () {
901990
seen[id] = true;
902991

903992
genre = text(item.genre) || "Other";
993+
if (kind === "movies" && films && films[genre] !== true) {
994+
return;
995+
}
996+
904997
if (!ix[kind][genre]) {
905998
ix[kind][genre] = [];
906999
}

0 commit comments

Comments
 (0)