Add an option to ignore short sponsorblock segments

This commit is contained in:
novenary 2023-02-01 23:30:02 +02:00
parent e1b355e92a
commit d980edd843
3 changed files with 23 additions and 1 deletions

View file

@ -266,6 +266,16 @@
@change="onChange($event)"
/>
</label>
<label class="pref" for="txtMinSegmentLength">
<strong v-t="'actions.min_segment_length'" />
<input
id="txtMinSegmentLength"
v-model="minSegmentLength"
class="input w-24"
type="text"
@change="onChange($event)"
/>
</label>
</div>
<h2 class="text-center" v-t="'titles.instance'" />
<label class="pref" for="ddlInstanceSelection">
@ -395,6 +405,7 @@ export default {
skipHighlight: "no",
skipFiller: "no",
showMarkers: true,
minSegmentLength: 0,
selectedTheme: "dark",
autoPlayVideo: true,
listen: false,
@ -551,6 +562,7 @@ export default {
}
this.showMarkers = this.getPreferenceBoolean("showMarkers", true);
this.minSegmentLength = Math.max(Number(localStorage.getItem("minSegmentLength")), 0);
this.selectedTheme = this.getPreferenceString("theme", "dark");
this.autoPlayVideo = this.getPreferenceBoolean("playerAutoPlay", true);
this.listen = this.getPreferenceBoolean("listen", false);
@ -613,6 +625,7 @@ export default {
localStorage.setItem("skipOptions", JSON.stringify(skipOptions));
localStorage.setItem("showMarkers", this.showMarkers);
localStorage.setItem("minSegmentLength", this.minSegmentLength);
localStorage.setItem("theme", this.selectedTheme);
localStorage.setItem("playerAutoPlay", this.autoPlayVideo);
localStorage.setItem("listen", this.listen);

View file

@ -379,9 +379,17 @@ export default {
);
}
return await this.fetchJson(this.apiUrl() + "/sponsors/" + this.getVideoId(), {
const sponsors = await this.fetchJson(this.apiUrl() + "/sponsors/" + this.getVideoId(), {
category: JSON.stringify(selectedSkip),
});
const minSegmentLength = Math.max(this.getPreferenceNumber("minSegmentLength", 0), 0);
sponsors.segments = sponsors.segments.filter(segment => {
const length = segment.segment[1] - segment.segment[0];
return length >= minSegmentLength;
});
return sponsors;
},
toggleComments() {
this.showComments = !this.showComments;

View file

@ -42,6 +42,7 @@
"skip_highlight": "Skip Highlight",
"skip_filler_tangent": "Skip Filler Tangent",
"show_markers": "Show Markers on Player",
"min_segment_length": "Minimum Segment Length (in seconds)",
"theme": "Theme",
"auto": "Auto",
"dark": "Dark",