diff options
author | cglatot <[email protected]> | 2020-07-07 13:14:24 +0100 |
---|---|---|
committer | cglatot <[email protected]> | 2020-07-07 13:14:24 +0100 |
commit | 655728feacf2491c3d437b0b8368aa6a4127dc27 (patch) | |
tree | 1ad79ddac626ae5d4f9e403fe7707b2f106e3b24 /js | |
parent | d1ccf6836e660d89bf550253d73b8568e126cbbc (diff) | |
download | pasta-655728feacf2491c3d437b0b8368aa6a4127dc27.tar.gz pasta-655728feacf2491c3d437b0b8368aa6a4127dc27.zip |
Single Season Selection
Diffstat (limited to 'js')
-rw-r--r-- | js/main.js | 77 |
1 files changed, 54 insertions, 23 deletions
@@ -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); } } |