1
0
mirror of https://github.com/TeamPiped/Piped.git synced 2024-12-17 07:40:27 +05:30
Piped/src/components/Preferences.vue

319 lines
14 KiB
Vue
Raw Normal View History

2020-11-17 10:45:35 +05:30
<template>
<div class="uk-flex uk-flex-between uk-flex-middle">
<button class="uk-button uk-button-text" @click="$router.go(-1) || $router.push('/')">
2021-08-26 01:25:30 +05:30
<font-awesome-icon icon="chevron-left" /> &nbsp;{{ $t("actions.back") }}
</button>
<span><h1 class="uk-text-bold uk-text-center" v-t="'titles.preferences'"/></span>
<span />
</div>
2020-11-22 10:04:27 +05:30
<hr />
2021-02-25 20:10:40 +05:30
<h2>SponsorBlock</h2>
2021-08-26 01:25:30 +05:30
<p>{{ $t("actions.uses_api_from") }}<a href="https://sponsor.ajay.app/">sponsor.ajay.app</a></p>
<b v-t="'actions.enable_sponsorblock'" />
2021-02-25 20:10:40 +05:30
<br />
<input class="uk-checkbox" v-model="sponsorBlock" @change="onChange($event)" type="checkbox" />
2021-02-25 20:48:59 +05:30
<br />
2021-08-26 01:25:30 +05:30
<b v-t="'actions.skip_sponsors'" />
2021-02-25 20:48:59 +05:30
<br />
<input class="uk-checkbox" v-model="skipSponsor" @change="onChange($event)" type="checkbox" />
2021-02-25 20:48:59 +05:30
<br />
2021-08-26 01:25:30 +05:30
<b v-t="'actions.skip_intro'" />
2021-02-25 20:48:59 +05:30
<br />
<input class="uk-checkbox" v-model="skipIntro" @change="onChange($event)" type="checkbox" />
2021-02-25 20:48:59 +05:30
<br />
2021-08-26 01:25:30 +05:30
<b v-t="'actions.skip_outro'" />
2021-02-25 20:48:59 +05:30
<br />
<input class="uk-checkbox" v-model="skipOutro" @change="onChange($event)" type="checkbox" />
2021-02-25 20:48:59 +05:30
<br />
2021-08-26 01:25:30 +05:30
<b v-t="'actions.skip_preview'" />
<br />
<input class="uk-checkbox" v-model="skipPreview" @change="onChange($event)" type="checkbox" />
<br />
2021-08-26 01:25:30 +05:30
<b v-t="'actions.skip_interaction'" />
2021-02-25 20:48:59 +05:30
<br />
<input class="uk-checkbox" v-model="skipInteraction" @change="onChange($event)" type="checkbox" />
2021-02-25 20:48:59 +05:30
<br />
2021-08-26 01:25:30 +05:30
<b v-t="'actions.skip_self_promo'" />
2021-02-25 20:48:59 +05:30
<br />
<input class="uk-checkbox" v-model="skipSelfPromo" @change="onChange($event)" type="checkbox" />
2021-02-25 20:48:59 +05:30
<br />
2021-08-26 01:25:30 +05:30
<b v-t="'actions.skip_non_music'" />
2021-02-25 20:48:59 +05:30
<br />
<input class="uk-checkbox" v-model="skipMusicOffTopic" @change="onChange($event)" type="checkbox" />
<br />
2021-08-26 01:25:30 +05:30
<b v-t="'actions.theme'" />
<br />
<select class="uk-select uk-width-auto" v-model="selectedTheme" @change="onChange($event)">
2021-08-26 01:25:30 +05:30
<option value="auto" v-t="'actions.auto'" />
<option value="dark" v-t="'actions.dark'" />
<option value="light" v-t="'actions.light'" />
</select>
<br />
2021-08-26 01:25:30 +05:30
<b v-t="'actions.autoplay_video'" />
<br />
<input class="uk-checkbox" v-model="autoPlayVideo" @change="onChange($event)" type="checkbox" />
2021-06-08 02:05:45 +05:30
<br />
2021-08-26 01:25:30 +05:30
<b v-t="'actions.audio_only'" />
2021-06-08 02:05:45 +05:30
<br />
<input class="uk-checkbox" v-model="listen" @change="onChange($event)" type="checkbox" />
2021-06-22 01:33:11 +05:30
<br />
2021-08-26 01:25:30 +05:30
<b v-t="'actions.default_quality'" />
2021-06-22 01:33:11 +05:30
<br />
<select class="uk-select uk-width-auto" v-model="defaultQuality" @change="onChange($event)">
2021-08-26 01:25:30 +05:30
<option value="0" v-t="'actions.auto'" />
<option :key="resolution" v-for="resolution in resolutions" :value="resolution">{{ resolution }}p</option>
2021-06-22 01:33:11 +05:30
</select>
2021-06-22 16:24:20 +05:30
<br />
2021-08-26 01:25:30 +05:30
<b v-t="'actions.buffering_goal'" />
2021-06-22 16:24:20 +05:30
<br />
<input class="uk-input uk-width-auto" v-model="bufferingGoal" @change="onChange($event)" type="text" />
<br />
2021-08-26 01:25:30 +05:30
<b v-t="'actions.country_selection'" />
<br />
<select class="uk-select uk-width-auto" v-model="country" @change="onChange($event)">
<option :key="country.code" v-for="country in countryMap" :value="country.code">{{ country.name }}</option>
</select>
<br />
2021-08-26 01:25:30 +05:30
<b v-t="'actions.default_homepage'" />
<br />
<select class="uk-select uk-width-auto" v-model="defaultHomepage" @change="onChange($event)">
2021-08-26 01:25:30 +05:30
<option value="trending" v-t="'titles.trending'" />
<option value="feed" v-t="'titles.feed'" />
</select>
<br />
2021-08-26 01:25:30 +05:30
<b v-t="'actions.show_comments'" />
<br />
<input class="uk-checkbox" v-model="showComments" @change="onChange($event)" type="checkbox" />
<br />
2021-08-26 01:25:30 +05:30
<b v-t="'actions.minimize_description'" />
<br />
<input class="uk-checkbox" v-model="minimizeDescription" @change="onChange($event)" type="checkbox" />
<br />
2021-08-26 01:25:30 +05:30
<b v-t="'actions.store_watch_history'" />
<br />
<input class="uk-checkbox" v-model="watchHistory" @change="onChange($event)" type="checkbox" />
<br />
2021-08-26 01:25:30 +05:30
<b v-t="'actions.language_selection'" />
<br />
<select class="uk-select uk-width-auto" v-model="selectedLanguage" @change="onChange($event)">
<option :key="language.code" v-for="language in languages" :value="language.code">{{ language.name }}</option>
</select>
<br />
<b v-t="'actions.enabled_codecs'" />
<br />
<select class="uk-select uk-width-auto" v-model="enabledCodecs" @change="onChange($event)" multiple>
<option value="av1">AV1</option>
<option value="vp9">VP9</option>
<option value="avc">AVC (h.264)</option>
</select>
2021-08-26 01:25:30 +05:30
<h2 v-t="'actions.instances_list'" />
2020-11-17 10:45:35 +05:30
<table class="uk-table">
<thead>
<tr>
<th>Instance Name</th>
<th>Instance Locations</th>
<th>Has CDN?</th>
2020-11-30 12:09:40 +05:30
<th>SSL Score</th>
2020-11-17 10:45:35 +05:30
</tr>
</thead>
<tbody v-bind:key="instance.name" v-for="instance in instances">
<tr>
<td>{{ instance.name }}</td>
<td>{{ instance.locations }}</td>
<td>{{ instance.cdn }}</td>
2020-11-30 12:09:40 +05:30
<td>
<a :href="sslScore(instance.apiurl)" target="_blank">Click Here</a>
2020-11-30 12:09:40 +05:30
</td>
2020-11-17 10:45:35 +05:30
</tr>
</tbody>
</table>
2020-11-22 10:04:27 +05:30
<hr />
<b>Instance Selection:</b>
<br />
<select class="uk-select uk-width-auto" v-model="selectedInstance" @change="onChange($event)">
<option v-bind:key="instance.name" v-for="instance in instances" v-bind:value="instance.apiurl">
2020-11-17 10:45:35 +05:30
{{ instance.name }}
</option>
</select>
</template>
<script>
import CountryMap from "@/utils/CountryMap.js";
2020-11-17 10:45:35 +05:30
export default {
data() {
return {
selectedInstance: null,
2021-02-25 20:10:40 +05:30
instances: [],
2021-02-25 20:48:59 +05:30
sponsorBlock: true,
skipSponsor: true,
skipIntro: false,
skipOutro: false,
skipPreview: false,
2021-02-25 20:48:59 +05:30
skipInteraction: true,
skipSelfPromo: true,
skipMusicOffTopic: true,
selectedTheme: "dark",
autoPlayVideo: true,
listen: false,
resolutions: [144, 240, 360, 480, 720, 1080, 1440, 2160, 4320],
2021-06-22 01:33:11 +05:30
defaultQuality: 0,
2021-06-22 16:24:20 +05:30
bufferingGoal: 10,
countryMap: CountryMap.COUNTRIES,
country: "US",
defaultHomepage: "trending",
showComments: true,
minimizeDescription: false,
watchHistory: false,
selectedLanguage: "en",
languages: [
Translations update from Weblate (#384) * Added translation using Weblate (German) * Added translation using Weblate (Norwegian Bokmål) * Added translation using Weblate (Chinese (Traditional)) * Translated using Weblate (Norwegian Bokmål) Currently translated at 82.5% (33 of 40 strings) Translation: Piped/Frontend Translate-URL: https://hosted.weblate.org/projects/piped/frontend/nb_NO/ * Added translation using Weblate (Malayalam) * Translated using Weblate (French) Currently translated at 100.0% (40 of 40 strings) Translation: Piped/Frontend Translate-URL: https://hosted.weblate.org/projects/piped/frontend/fr/ * Translated using Weblate (French) Currently translated at 100.0% (40 of 40 strings) Translation: Piped/Frontend Translate-URL: https://hosted.weblate.org/projects/piped/frontend/fr/ * Translated using Weblate (German) Currently translated at 100.0% (40 of 40 strings) Translation: Piped/Frontend Translate-URL: https://hosted.weblate.org/projects/piped/frontend/de/ * Translated using Weblate (Chinese (Traditional)) Currently translated at 42.5% (17 of 40 strings) Translation: Piped/Frontend Translate-URL: https://hosted.weblate.org/projects/piped/frontend/zh_Hant/ * Translated using Weblate (Malayalam) Currently translated at 90.0% (36 of 40 strings) Translation: Piped/Frontend Translate-URL: https://hosted.weblate.org/projects/piped/frontend/ml/ * Add support for 4 new languages. Co-authored-by: J. Lavoie <j.lavoie@net-c.ca> Co-authored-by: Allan Nordhøy <epost@anotheragency.no> Co-authored-by: Jamugha <hackdown@necord.com> Co-authored-by: vachan-maker <vachan2014carmel@gmail.com> Co-authored-by: FireMasterK <20838718+FireMasterK@users.noreply.github.com>
2021-08-26 17:18:23 +05:30
{ code: "zh_Hant", name: "Chinese (Traditional)" },
{ code: "en", name: "English" },
{ code: "fr", name: "French" },
Translations update from Weblate (#384) * Added translation using Weblate (German) * Added translation using Weblate (Norwegian Bokmål) * Added translation using Weblate (Chinese (Traditional)) * Translated using Weblate (Norwegian Bokmål) Currently translated at 82.5% (33 of 40 strings) Translation: Piped/Frontend Translate-URL: https://hosted.weblate.org/projects/piped/frontend/nb_NO/ * Added translation using Weblate (Malayalam) * Translated using Weblate (French) Currently translated at 100.0% (40 of 40 strings) Translation: Piped/Frontend Translate-URL: https://hosted.weblate.org/projects/piped/frontend/fr/ * Translated using Weblate (French) Currently translated at 100.0% (40 of 40 strings) Translation: Piped/Frontend Translate-URL: https://hosted.weblate.org/projects/piped/frontend/fr/ * Translated using Weblate (German) Currently translated at 100.0% (40 of 40 strings) Translation: Piped/Frontend Translate-URL: https://hosted.weblate.org/projects/piped/frontend/de/ * Translated using Weblate (Chinese (Traditional)) Currently translated at 42.5% (17 of 40 strings) Translation: Piped/Frontend Translate-URL: https://hosted.weblate.org/projects/piped/frontend/zh_Hant/ * Translated using Weblate (Malayalam) Currently translated at 90.0% (36 of 40 strings) Translation: Piped/Frontend Translate-URL: https://hosted.weblate.org/projects/piped/frontend/ml/ * Add support for 4 new languages. Co-authored-by: J. Lavoie <j.lavoie@net-c.ca> Co-authored-by: Allan Nordhøy <epost@anotheragency.no> Co-authored-by: Jamugha <hackdown@necord.com> Co-authored-by: vachan-maker <vachan2014carmel@gmail.com> Co-authored-by: FireMasterK <20838718+FireMasterK@users.noreply.github.com>
2021-08-26 17:18:23 +05:30
{ code: "de", name: "German" },
{ code: "el", name: "Greek" },
{ code: "lt", name: "Lithuanian" },
Translations update from Weblate (#384) * Added translation using Weblate (German) * Added translation using Weblate (Norwegian Bokmål) * Added translation using Weblate (Chinese (Traditional)) * Translated using Weblate (Norwegian Bokmål) Currently translated at 82.5% (33 of 40 strings) Translation: Piped/Frontend Translate-URL: https://hosted.weblate.org/projects/piped/frontend/nb_NO/ * Added translation using Weblate (Malayalam) * Translated using Weblate (French) Currently translated at 100.0% (40 of 40 strings) Translation: Piped/Frontend Translate-URL: https://hosted.weblate.org/projects/piped/frontend/fr/ * Translated using Weblate (French) Currently translated at 100.0% (40 of 40 strings) Translation: Piped/Frontend Translate-URL: https://hosted.weblate.org/projects/piped/frontend/fr/ * Translated using Weblate (German) Currently translated at 100.0% (40 of 40 strings) Translation: Piped/Frontend Translate-URL: https://hosted.weblate.org/projects/piped/frontend/de/ * Translated using Weblate (Chinese (Traditional)) Currently translated at 42.5% (17 of 40 strings) Translation: Piped/Frontend Translate-URL: https://hosted.weblate.org/projects/piped/frontend/zh_Hant/ * Translated using Weblate (Malayalam) Currently translated at 90.0% (36 of 40 strings) Translation: Piped/Frontend Translate-URL: https://hosted.weblate.org/projects/piped/frontend/ml/ * Add support for 4 new languages. Co-authored-by: J. Lavoie <j.lavoie@net-c.ca> Co-authored-by: Allan Nordhøy <epost@anotheragency.no> Co-authored-by: Jamugha <hackdown@necord.com> Co-authored-by: vachan-maker <vachan2014carmel@gmail.com> Co-authored-by: FireMasterK <20838718+FireMasterK@users.noreply.github.com>
2021-08-26 17:18:23 +05:30
{ code: "ml", name: "Malayalam" },
{ code: "nb_NO", name: "Norwegian Bokmål" },
{ code: "tr", name: "Turkish" },
2021-08-28 10:42:52 +05:30
{ code: 'bn', name: 'Bengali' }
],
enabledCodecs: ["av1", "vp9", "avc"],
2020-11-17 10:45:35 +05:30
};
},
activated() {
document.title = this.$t("titles.preferences") + " - Piped";
},
2020-11-17 10:45:35 +05:30
mounted() {
if (Object.keys(this.$route.query).length > 0) this.$router.replace({ query: {} });
fetch("https://raw.githubusercontent.com/wiki/TeamPiped/Piped-Frontend/Instances.md")
2020-11-17 10:45:35 +05:30
.then(resp => resp.text())
.then(body => {
var skipped = 0;
const lines = body.split("\n");
lines.map(line => {
const split = line.split("|");
if (split.length == 4) {
if (skipped < 2) {
skipped++;
return;
}
this.instances.push({
name: split[0].trim(),
apiurl: split[1].trim(),
locations: split[2].trim(),
cdn: split[3].trim(),
2020-11-17 10:45:35 +05:30
});
}
});
2021-08-26 01:25:30 +05:30
if (this.instances.filter(instance => instance.apiurl == this.apiUrl()).length == 0)
this.instances.push({
name: "Custom Instance",
apiurl: this.apiUrl(),
locations: "Unknown",
cdn: "Unknown",
});
2020-11-17 10:45:35 +05:30
});
2021-02-25 20:10:40 +05:30
if (localStorage) {
this.selectedInstance = this.getPreferenceString("instance", "https://pipedapi.kavin.rocks");
2021-02-25 20:10:40 +05:30
this.sponsorBlock = this.getPreferenceBoolean("sponsorblock", true);
2021-04-21 19:08:50 +05:30
if (localStorage.getItem("selectedSkip") !== null) {
2021-02-25 20:48:59 +05:30
var skipList = localStorage.getItem("selectedSkip").split(",");
this.skipSponsor = this.skipIntro = this.skipOutro = this.skipPreview = this.skipInteraction = this.skipSelfPromo = this.skipMusicOffTopic = false;
2021-02-25 20:48:59 +05:30
skipList.forEach(skip => {
switch (skip) {
case "sponsor":
this.skipSponsor = true;
break;
case "intro":
this.skipIntro = true;
break;
case "outro":
this.skipOutro = true;
break;
case "preview":
this.skipPreview = true;
break;
2021-02-25 20:48:59 +05:30
case "interaction":
this.skipInteraction = true;
break;
case "selfpromo":
this.skipSelfPromo = true;
break;
case "music_offtopic":
this.skipMusicOffTopic = true;
break;
default:
console.log("Unknown sponsor type: " + skip);
break;
}
});
}
this.selectedTheme = this.getPreferenceString("theme", "dark");
this.autoPlayVideo = this.getPreferenceBoolean(localStorage.getItem("playerAutoPlay"), true);
this.listen = this.getPreferenceBoolean("listen", false);
2021-06-22 01:33:11 +05:30
this.defaultQuality = Number(localStorage.getItem("quality"));
2021-06-22 16:24:20 +05:30
this.bufferingGoal = Math.max(Number(localStorage.getItem("bufferGoal")), 10);
this.country = this.getPreferenceString("region", "US");
this.defaultHomepage = this.getPreferenceString("homepage", "trending");
this.showComments = this.getPreferenceBoolean("comments", true);
this.minimizeDescription = this.getPreferenceBoolean("minimizeDescription", false);
this.watchHistory = this.getPreferenceBoolean("watchHistory", false);
this.selectedLanguage = this.getPreferenceString("hl", "en");
this.enabledCodecs = this.getPreferenceString("enabledCodecs", "av1,vp9,avc").split(",");
2021-02-25 20:10:40 +05:30
}
2020-11-17 10:45:35 +05:30
},
methods: {
onChange() {
2021-02-25 20:10:40 +05:30
if (localStorage) {
var shouldReload = false;
if (
this.getPreferenceString("theme", "dark") !== this.selectedTheme ||
this.getPreferenceBoolean("watchHistory", false) != this.watchHistory ||
this.getPreferenceString("hl", "en") !== this.selectedLanguage ||
this.getPreferenceString("enabledCodecs", "av1,vp9,avc") !== this.enabledCodecs.join(",")
)
shouldReload = true;
2020-11-17 10:45:35 +05:30
localStorage.setItem("instance", this.selectedInstance);
2021-02-25 20:10:40 +05:30
localStorage.setItem("sponsorblock", this.sponsorBlock);
2021-02-25 20:48:59 +05:30
var sponsorSelected = [];
if (this.skipSponsor) sponsorSelected.push("sponsor");
if (this.skipIntro) sponsorSelected.push("intro");
if (this.skipOutro) sponsorSelected.push("outro");
if (this.skipPreview) sponsorSelected.push("preview");
2021-02-25 20:48:59 +05:30
if (this.skipInteraction) sponsorSelected.push("interaction");
if (this.skipSelfPromo) sponsorSelected.push("selfpromo");
if (this.skipMusicOffTopic) sponsorSelected.push("music_offtopic");
2021-02-25 20:48:59 +05:30
localStorage.setItem("selectedSkip", sponsorSelected);
localStorage.setItem("theme", this.selectedTheme);
localStorage.setItem("playerAutoPlay", this.autoPlayVideo);
localStorage.setItem("listen", this.listen);
2021-06-22 01:33:11 +05:30
localStorage.setItem("quality", this.defaultQuality);
2021-06-22 16:24:20 +05:30
localStorage.setItem("bufferGoal", this.bufferingGoal);
localStorage.setItem("region", this.country);
localStorage.setItem("homepage", this.defaultHomepage);
localStorage.setItem("comments", this.showComments);
localStorage.setItem("minimizeDescription", this.minimizeDescription);
localStorage.setItem("watchHistory", this.watchHistory);
localStorage.setItem("hl", this.selectedLanguage);
localStorage.setItem("enabledCodecs", this.enabledCodecs.join(","));
if (shouldReload) window.location.reload();
2021-02-25 20:10:40 +05:30
}
2020-11-30 12:09:40 +05:30
},
sslScore(url) {
return "https://www.ssllabs.com/ssltest/analyze.html?d=" + new URL(url).host + "&latest";
},
},
2020-11-17 10:45:35 +05:30
};
</script>