aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorcglatot <[email protected]>2020-07-07 13:14:24 +0100
committercglatot <[email protected]>2020-07-07 13:14:24 +0100
commit655728feacf2491c3d437b0b8368aa6a4127dc27 (patch)
tree1ad79ddac626ae5d4f9e403fe7707b2f106e3b24
parentd1ccf6836e660d89bf550253d73b8568e126cbbc (diff)
downloadpasta-655728feacf2491c3d437b0b8368aa6a4127dc27.tar.gz
pasta-655728feacf2491c3d437b0b8368aa6a4127dc27.zip
Single Season Selection
-rw-r--r--index.html4
-rw-r--r--js/main.js77
2 files changed, 58 insertions, 23 deletions
diff --git a/index.html b/index.html
index 1e18d1d..f744b66 100644
--- a/index.html
+++ b/index.html
@@ -459,6 +459,10 @@
checked> Single Episode
</label>
<label class="btn btn-secondary">
+ <input type="radio" name="episodeOrSeries" id="singleSeason" autocomplete="off">
+ Single Season
+ </label>
+ <label class="btn btn-secondary">
<input type="radio" name="episodeOrSeries" id="entireSeries" autocomplete="off">
Entire Series
</label>
diff --git a/js/main.js b/js/main.js
index 12a2368..0025137 100644
--- a/js/main.js
+++ b/js/main.js
@@ -118,7 +118,7 @@ $(document).ready(() => {
listenForValidPincode(pinId);
},
"error": (data) => {
- console.log("ERROR L59");
+ console.log("ERROR L121");
console.log(data);
}
});
@@ -183,7 +183,7 @@ function listenForValidPincode (pinId) {
}
},
"error": (data) => {
- console.log("ERROR L73");
+ console.log("ERROR L186");
console.log(data);
return;
}
@@ -221,7 +221,7 @@ function getServers () {
}
},
"error": (data) => {
- console.log("ERROR L59");
+ console.log("ERROR L224");
console.log(data);
if (data.status == 401) {
console.log("Unauthorized");
@@ -425,7 +425,7 @@ function getAlphabet(uid, row) {
$('#series-tab').tab('show');
},
"error": (data) => {
- console.log("ERROR L131");
+ console.log("ERROR L428");
console.log(data);
}
});
@@ -470,7 +470,7 @@ function getLibraryByLetter(element) {
},
"success": (data) => displayTitles(data),
"error": (data) => {
- console.log("ERROR L178");
+ console.log("ERROR L473");
console.log(data);
}
});
@@ -507,7 +507,7 @@ function getTitleInfo(uid, row) {
$('#episodes-tab').tab('show');
},
"error": (data) => {
- console.log("ERROR L143");
+ console.log("ERROR L510");
console.log(data);
if (data.status == 400) {
// This is a "bad request" - this usually means a Movie was selected
@@ -558,7 +558,7 @@ function getSeasonInfo(uid, row) {
},
"success": (data) => showSeasonInfo(data, row),
"error": (data) => {
- console.log("ERROR L183");
+ console.log("ERROR L561");
console.log(data);
}
});
@@ -593,7 +593,7 @@ function getEpisodeInfo(uid, row) {
},
"success": (data) => showEpisodeInfo(data, row),
"error": (data) => {
- console.log("ERROR L220");
+ console.log("ERROR L596");
console.log(data);
}
});
@@ -646,6 +646,7 @@ function showEpisodeInfo(data, row) {
async function setAudioStream(partsId, streamId, row) {
let singleEpisode = $("#singleEpisode").prop("checked");
+ let singleSeason = $("#singleSeason").prop("checked");
// Need these 2 variables and function for progress bar
let currentProgress = 0;
let maxProgress = 0;
@@ -666,7 +667,7 @@ async function setAudioStream(partsId, streamId, row) {
}, 1750);
},
"error": (data) => {
- console.log("ERROR L283");
+ console.log("ERROR L670");
console.log(data);
}
});
@@ -695,17 +696,33 @@ async function setAudioStream(partsId, streamId, row) {
// We have the Seasons Ids stored in seasonsList, so iterate over them to get all the episodes
let episodeList = [];
- for (let i = 0; i < seasonsList.length; i++) {
+ if (singleSeason) {
+ // If the "Single Season" button is selected, we only want to change the current season's episodes
let seasonEpisodes = await $.ajax({
- "url": `${plexUrl}/library/metadata/${seasonsList[i]}/children`,
+ "url": `${plexUrl}/library/metadata/${seasonId}/children`,
"method": "GET",
"headers": {
"X-Plex-Token": plexToken,
"Accept": "application/json"
}
});
- for (let j = 0; j < seasonEpisodes.MediaContainer.Metadata.length; j++) {
- episodeList.push(seasonEpisodes.MediaContainer.Metadata[j].ratingKey);
+ for (let k = 0; k < seasonEpisodes.MediaContainer.Metadata.length; k++) {
+ episodeList.push(seasonEpisodes.MediaContainer.Metadata[k].ratingKey);
+ }
+ } else {
+ // Else we want to get all the episodes from every season
+ for (let i = 0; i < seasonsList.length; i++) {
+ let seasonEpisodes = await $.ajax({
+ "url": `${plexUrl}/library/metadata/${seasonsList[i]}/children`,
+ "method": "GET",
+ "headers": {
+ "X-Plex-Token": plexToken,
+ "Accept": "application/json"
+ }
+ });
+ for (let j = 0; j < seasonEpisodes.MediaContainer.Metadata.length; j++) {
+ episodeList.push(seasonEpisodes.MediaContainer.Metadata[j].ratingKey);
+ }
}
}
@@ -717,7 +734,6 @@ async function setAudioStream(partsId, streamId, row) {
// Update the progressbar
currentProgress++;
const calculatedWidth = (currentProgress / maxProgress) * 100;
- console.log(calculatedWidth);
$('#progressBar').width(`${calculatedWidth}%`);
$('#progressBar').attr('aria-valuenow', currentProgress);
@@ -917,7 +933,7 @@ async function setAudioStream(partsId, streamId, row) {
});
}
catch (e) {
- console.log("ERROR L419");
+ console.log("ERROR L936");
console.log(e);
}
}
@@ -925,6 +941,7 @@ async function setAudioStream(partsId, streamId, row) {
async function setSubtitleStream(partsId, streamId, row) {
let singleEpisode = $("#singleEpisode").prop("checked");
+ let singleSeason = $("#singleSeason").prop("checked");
// Need these 2 variables and function for progress bar
let currentProgress = 0;
let maxProgress = 0;
@@ -945,7 +962,7 @@ async function setSubtitleStream(partsId, streamId, row) {
}, 1750);
},
"error": (data) => {
- console.log("ERROR L449");
+ console.log("ERROR L965");
console.log(data);
}
});
@@ -974,17 +991,33 @@ async function setSubtitleStream(partsId, streamId, row) {
// We have the Seasons Ids stored in seasonsList, so iterate over them to get all the episodes
let episodeList = [];
- for (let i = 0; i < seasonsList.length; i++) {
+ if (singleSeason) {
+ // If the "Single Season" button is selected, we only want to change the current season's episodes
let seasonEpisodes = await $.ajax({
- "url": `${plexUrl}/library/metadata/${seasonsList[i]}/children`,
+ "url": `${plexUrl}/library/metadata/${seasonId}/children`,
"method": "GET",
"headers": {
"X-Plex-Token": plexToken,
"Accept": "application/json"
}
});
- for (let j = 0; j < seasonEpisodes.MediaContainer.Metadata.length; j++) {
- episodeList.push(seasonEpisodes.MediaContainer.Metadata[j].ratingKey);
+ for (let k = 0; k < seasonEpisodes.MediaContainer.Metadata.length; k++) {
+ episodeList.push(seasonEpisodes.MediaContainer.Metadata[k].ratingKey);
+ }
+ } else {
+ // Else we want to get all the episodes from every season
+ for (let i = 0; i < seasonsList.length; i++) {
+ let seasonEpisodes = await $.ajax({
+ "url": `${plexUrl}/library/metadata/${seasonsList[i]}/children`,
+ "method": "GET",
+ "headers": {
+ "X-Plex-Token": plexToken,
+ "Accept": "application/json"
+ }
+ });
+ for (let j = 0; j < seasonEpisodes.MediaContainer.Metadata.length; j++) {
+ episodeList.push(seasonEpisodes.MediaContainer.Metadata[j].ratingKey);
+ }
}
}
@@ -996,7 +1029,6 @@ async function setSubtitleStream(partsId, streamId, row) {
// Update the progressbar
currentProgress++;
const calculatedWidth = (currentProgress / maxProgress) * 100;
- console.log(calculatedWidth);
$('#progressBar').width(`${calculatedWidth}%`);
$('#progressBar').attr('aria-valuenow', currentProgress);
@@ -1194,7 +1226,6 @@ async function setSubtitleStream(partsId, streamId, row) {
function handleProgress() {
currentProgress++;
const calculatedWidth = (currentProgress / maxProgress) * 100;
- console.log(calculatedWidth);
$('#progressBar').width(`${calculatedWidth}%`);
$('#progressBar').attr('aria-valuenow', currentProgress);
};
@@ -1207,7 +1238,7 @@ async function setSubtitleStream(partsId, streamId, row) {
});
}
catch (e) {
- console.log("ERROR L419");
+ console.log("ERROR L1241");
console.log(e);
}
}