mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-14 23:57:27 +00:00
Sponsor preference dict
This commit is contained in:
parent
601da0d460
commit
fbc16e7d15
3 changed files with 80 additions and 61 deletions
|
@ -185,63 +185,75 @@
|
||||||
</label>
|
</label>
|
||||||
<label class="pref" for="chkSkipSponsors">
|
<label class="pref" for="chkSkipSponsors">
|
||||||
<strong v-t="'actions.skip_sponsors'" />
|
<strong v-t="'actions.skip_sponsors'" />
|
||||||
<input id="chkSkipSponsors" v-model="skipSponsor" class="checkbox" type="checkbox" @change="onChange($event)" />
|
<select id="chkSkipSponsors" v-model="skipSponsor" @change="onChange($event)">
|
||||||
|
<option value="off">Disable</option>
|
||||||
|
<option value="skip">Auto Skip</option>
|
||||||
|
<option value="show">Show</option>
|
||||||
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<label class="pref" for="chkSkipIntro">
|
<label class="pref" for="chkSkipIntro">
|
||||||
<strong v-t="'actions.skip_intro'" />
|
<strong v-t="'actions.skip_intro'" />
|
||||||
<input id="chkSkipIntro" v-model="skipIntro" class="checkbox" type="checkbox" @change="onChange($event)" />
|
<select id="chkSkipIntro" v-model="skipIntro" @change="onChange($event)">
|
||||||
|
<option value="off">Disable</option>
|
||||||
|
<option value="skip">Auto Skip</option>
|
||||||
|
<option value="show">Show</option>
|
||||||
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<label class="pref" for="chkSkipOutro">
|
<label class="pref" for="chkSkipOutro">
|
||||||
<strong v-t="'actions.skip_outro'" />
|
<strong v-t="'actions.skip_outro'" />
|
||||||
<input id="chkSkipOutro" v-model="skipOutro" class="checkbox" type="checkbox" @change="onChange($event)" />
|
<select id="chkSkipOutro" v-model="skipOutro" @change="onChange($event)">
|
||||||
|
<option value="off">Disable</option>
|
||||||
|
<option value="skip">Auto Skip</option>
|
||||||
|
<option value="show">Show</option>
|
||||||
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<label class="pref" for="chkSkipPreview">
|
<label class="pref" for="chkSkipPreview">
|
||||||
<strong v-t="'actions.skip_preview'" />
|
<strong v-t="'actions.skip_preview'" />
|
||||||
<input id="chkSkipPreview" v-model="skipPreview" class="checkbox" type="checkbox" @change="onChange($event)" />
|
<select id="chkSkipPreview" v-model="skipPreview" @change="onChange($event)">
|
||||||
|
<option value="off">Disable</option>
|
||||||
|
<option value="skip">Auto Skip</option>
|
||||||
|
<option value="show">Show</option>
|
||||||
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<label class="pref" for="chkSkipInteraction">
|
<label class="pref" for="chkSkipInteraction">
|
||||||
<strong v-t="'actions.skip_interaction'" />
|
<strong v-t="'actions.skip_interaction'" />
|
||||||
<input
|
<select id="chkSkipInteraction" v-model="skipInteraction" @change="onChange($event)">
|
||||||
id="chkSkipInteraction"
|
<option value="off">Disable</option>
|
||||||
v-model="skipInteraction"
|
<option value="skip">Auto Skip</option>
|
||||||
class="checkbox"
|
<option value="show">Show</option>
|
||||||
type="checkbox"
|
</select>
|
||||||
@change="onChange($event)"
|
|
||||||
/>
|
|
||||||
</label>
|
</label>
|
||||||
<label class="pref" for="chkSkipSelfPromo">
|
<label class="pref" for="chkSkipSelfPromo">
|
||||||
<strong v-t="'actions.skip_self_promo'" />
|
<strong v-t="'actions.skip_self_promo'" />
|
||||||
<input
|
<select id="chkSkipSelfPromo" v-model="skipSelfPromo" @change="onChange($event)">
|
||||||
id="chkSkipSelfPromo"
|
<option value="off">Disable</option>
|
||||||
v-model="skipSelfPromo"
|
<option value="skip">Auto Skip</option>
|
||||||
class="checkbox"
|
<option value="show">Show</option>
|
||||||
type="checkbox"
|
</select>
|
||||||
@change="onChange($event)"
|
|
||||||
/>
|
|
||||||
</label>
|
</label>
|
||||||
<label class="pref" for="chkSkipNonMusic">
|
<label class="pref" for="chkSkipNonMusic">
|
||||||
<strong v-t="'actions.skip_non_music'" />
|
<strong v-t="'actions.skip_non_music'" />
|
||||||
<input
|
<select id="chkSkipNonMusic" v-model="skipMusicOffTopic" @change="onChange($event)">
|
||||||
id="chkSkipNonMusic"
|
<option value="off">Disable</option>
|
||||||
v-model="skipMusicOffTopic"
|
<option value="skip">Auto Skip</option>
|
||||||
class="checkbox"
|
<option value="show">Show</option>
|
||||||
type="checkbox"
|
</select>
|
||||||
@change="onChange($event)"
|
|
||||||
/>
|
|
||||||
</label>
|
</label>
|
||||||
<label class="pref" for="chkSkipHighlight">
|
<label class="pref" for="chkSkipHighlight">
|
||||||
<strong v-t="'actions.skip_highlight'" />
|
<strong v-t="'actions.skip_highlight'" />
|
||||||
<input
|
<select id="chkSkipHighlight" v-model="skipHighlight" @change="onChange($event)">
|
||||||
id="chkSkipHighlight"
|
<option value="off">Disable</option>
|
||||||
v-model="skipHighlight"
|
<option value="skip">Auto Skip</option>
|
||||||
class="checkbox"
|
<option value="show">Show</option>
|
||||||
type="checkbox"
|
</select>
|
||||||
@change="onChange($event)"
|
|
||||||
/>
|
|
||||||
</label>
|
</label>
|
||||||
<label class="pref" for="chkSkipFiller">
|
<label class="pref" for="chkSkipFiller">
|
||||||
<strong v-t="'actions.skip_filler_tangent'" />
|
<strong v-t="'actions.skip_filler_tangent'" />
|
||||||
<input id="chkSkipFiller" v-model="skipFiller" class="checkbox" type="checkbox" @change="onChange($event)" />
|
<select id="chkSkipFiller" v-model="skipFiller" @change="onChange($event)">
|
||||||
|
<option value="off">Disable</option>
|
||||||
|
<option value="skip">Auto Skip</option>
|
||||||
|
<option value="show">Show</option>
|
||||||
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<label class="pref" for="chkShowMarkers">
|
<label class="pref" for="chkShowMarkers">
|
||||||
<strong v-t="'actions.show_markers'" />
|
<strong v-t="'actions.show_markers'" />
|
||||||
|
@ -470,7 +482,7 @@ export default {
|
||||||
|
|
||||||
this.sponsorBlock = this.getPreferenceBoolean("sponsorblock", true);
|
this.sponsorBlock = this.getPreferenceBoolean("sponsorblock", true);
|
||||||
if (localStorage.getItem("selectedSkip") !== null) {
|
if (localStorage.getItem("selectedSkip") !== null) {
|
||||||
var skipList = localStorage.getItem("selectedSkip").split(",");
|
var skipList = JSON.parse(localStorage.getItem("selectedSkip"));
|
||||||
this.skipSponsor =
|
this.skipSponsor =
|
||||||
this.skipIntro =
|
this.skipIntro =
|
||||||
this.skipOutro =
|
this.skipOutro =
|
||||||
|
@ -480,41 +492,41 @@ export default {
|
||||||
this.skipMusicOffTopic =
|
this.skipMusicOffTopic =
|
||||||
this.skipHighlight =
|
this.skipHighlight =
|
||||||
this.skipFiller =
|
this.skipFiller =
|
||||||
false;
|
"off";
|
||||||
skipList.forEach(skip => {
|
for (const skip in skipList) {
|
||||||
switch (skip) {
|
switch (skip) {
|
||||||
case "sponsor":
|
case "sponsor":
|
||||||
this.skipSponsor = true;
|
this.skipSponsor = skipList[skip];
|
||||||
break;
|
break;
|
||||||
case "intro":
|
case "intro":
|
||||||
this.skipIntro = true;
|
this.skipIntro = skipList[skip];
|
||||||
break;
|
break;
|
||||||
case "outro":
|
case "outro":
|
||||||
this.skipOutro = true;
|
this.skipOutro = skipList[skip];
|
||||||
break;
|
break;
|
||||||
case "preview":
|
case "preview":
|
||||||
this.skipPreview = true;
|
this.skipPreview = skipList[skip];
|
||||||
break;
|
break;
|
||||||
case "interaction":
|
case "interaction":
|
||||||
this.skipInteraction = true;
|
this.skipInteraction = skipList[skip];
|
||||||
break;
|
break;
|
||||||
case "selfpromo":
|
case "selfpromo":
|
||||||
this.skipSelfPromo = true;
|
this.skipSelfPromo = skipList[skip];
|
||||||
break;
|
break;
|
||||||
case "music_offtopic":
|
case "music_offtopic":
|
||||||
this.skipMusicOffTopic = true;
|
this.skipMusicOffTopic = skipList[skip];
|
||||||
break;
|
break;
|
||||||
case "poi_highlight":
|
case "poi_highlight":
|
||||||
this.skipHighlight = true;
|
this.skipHighlight = skipList[skip];
|
||||||
break;
|
break;
|
||||||
case "filler":
|
case "filler":
|
||||||
this.skipFiller = true;
|
this.skipFiller = skipList[skip];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.log("Unknown sponsor type: " + skip);
|
console.log("Unknown sponsor type: " + skip);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.showMarkers = this.getPreferenceBoolean("showMarkers", true);
|
this.showMarkers = this.getPreferenceBoolean("showMarkers", true);
|
||||||
|
@ -566,17 +578,17 @@ export default {
|
||||||
localStorage.setItem("auth_instance_url", this.selectedAuthInstance);
|
localStorage.setItem("auth_instance_url", this.selectedAuthInstance);
|
||||||
localStorage.setItem("sponsorblock", this.sponsorBlock);
|
localStorage.setItem("sponsorblock", this.sponsorBlock);
|
||||||
|
|
||||||
var sponsorSelected = [];
|
var sponsorSelected = {};
|
||||||
if (this.skipSponsor) sponsorSelected.push("sponsor");
|
if (this.skipSponsor !== "off") sponsorSelected["sponsor"] = this.skipSponsor;
|
||||||
if (this.skipIntro) sponsorSelected.push("intro");
|
if (this.skipIntro !== "off") sponsorSelected["intro"] = this.skipIntro;
|
||||||
if (this.skipOutro) sponsorSelected.push("outro");
|
if (this.skipOutro !== "off") sponsorSelected["outro"] = this.skipOutro;
|
||||||
if (this.skipPreview) sponsorSelected.push("preview");
|
if (this.skipPreview !== "off") sponsorSelected["preview"] = this.skipPreview;
|
||||||
if (this.skipInteraction) sponsorSelected.push("interaction");
|
if (this.skipInteraction !== "off") sponsorSelected["interaction"] = this.skipInteraction;
|
||||||
if (this.skipSelfPromo) sponsorSelected.push("selfpromo");
|
if (this.skipSelfPromo !== "off") sponsorSelected["selfpromo"] = this.skipSelfPromo;
|
||||||
if (this.skipMusicOffTopic) sponsorSelected.push("music_offtopic");
|
if (this.skipMusicOffTopic !== "off") sponsorSelected["music_offtopic"] = this.skipMusicOffTopic;
|
||||||
if (this.skipHighlight) sponsorSelected.push("poi_highlight");
|
if (this.skipHighlight !== "off") sponsorSelected["poi_highlight"] = this.skipHighlight;
|
||||||
if (this.skipFiller) sponsorSelected.push("filler");
|
if (this.skipFiller !== "off") sponsorSelected["filler"] = this.skipFiller;
|
||||||
localStorage.setItem("selectedSkip", sponsorSelected);
|
localStorage.setItem("selectedSkip", JSON.stringify(sponsorSelected));
|
||||||
|
|
||||||
localStorage.setItem("showMarkers", this.showMarkers);
|
localStorage.setItem("showMarkers", this.showMarkers);
|
||||||
localStorage.setItem("theme", this.selectedTheme);
|
localStorage.setItem("theme", this.selectedTheme);
|
||||||
|
|
|
@ -363,13 +363,11 @@ export default {
|
||||||
return this.fetchJson(this.apiUrl() + "/streams/" + this.getVideoId());
|
return this.fetchJson(this.apiUrl() + "/streams/" + this.getVideoId());
|
||||||
},
|
},
|
||||||
async fetchSponsors() {
|
async fetchSponsors() {
|
||||||
|
const skips = this.getPreferenceDict("selectedSkip", null);
|
||||||
return await this.fetchJson(this.apiUrl() + "/sponsors/" + this.getVideoId(), {
|
return await this.fetchJson(this.apiUrl() + "/sponsors/" + this.getVideoId(), {
|
||||||
category:
|
category:
|
||||||
'["' +
|
'["' +
|
||||||
this.getPreferenceString("selectedSkip", "sponsor,interaction,selfpromo,music_offtopic").replaceAll(
|
(skips === null ? "sponsor,interaction,selfpromo,music_offtopic" : Object.keys(skips).join('","')) +
|
||||||
",",
|
|
||||||
'","',
|
|
||||||
) +
|
|
||||||
'"]',
|
'"]',
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -156,6 +156,15 @@ const mixin = {
|
||||||
return Number(value);
|
return Number(value);
|
||||||
} else return defaultVal;
|
} else return defaultVal;
|
||||||
},
|
},
|
||||||
|
getPreferenceDict(key, defaultVal) {
|
||||||
|
var value;
|
||||||
|
if (
|
||||||
|
(value = new URLSearchParams(window.location.search).get(key)) !== null ||
|
||||||
|
(this.testLocalStorage && (value = localStorage.getItem(key)) !== null)
|
||||||
|
) {
|
||||||
|
return JSON.parse(value);
|
||||||
|
} else return defaultVal;
|
||||||
|
},
|
||||||
apiUrl() {
|
apiUrl() {
|
||||||
return this.getPreferenceString("instance", "https://pipedapi.kavin.rocks");
|
return this.getPreferenceString("instance", "https://pipedapi.kavin.rocks");
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue