Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video title filter / blacklist #4202

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -120,13 +120,16 @@ export default defineComponent({
return ch
})
},
forbiddenVideoTitleText: function() {
return JSON.parse(this.$store.getters.getForbiddenVideoTitleText)
},
hideSubscriptionsLiveTooltip: function () {
return this.$t('Tooltips.Distraction Free Settings.Hide Subscriptions Live', {
appWideSetting: this.$t('Settings.Distraction Free Settings.Hide Live Streams'),
subsection: this.$t('Settings.Distraction Free Settings.Sections.General'),
settingsSection: this.$t('Settings.Distraction Free Settings.Distraction Free Settings')
})
}
},
},
mounted: function () {
this.verifyChannelsHidden()
@@ -148,6 +151,9 @@ export default defineComponent({
handleChannelsHidden: function (value) {
this.updateChannelsHidden(JSON.stringify(value))
},
handleForbiddenVideoTitleText: function (value) {
this.updateForbiddenVideoTitleText(JSON.stringify(value))
},
handleChannelsExists: function () {
showToast(this.$t('Settings.Distraction Free Settings.Hide Channels Already Exists'))
},
@@ -206,6 +212,7 @@ export default defineComponent({
'updateHideSharingActions',
'updateHideChapters',
'updateChannelsHidden',
'updateForbiddenVideoTitleText',
'updateShowDistractionFreeTitles',
'updateHideFeaturedChannels',
'updateHideChannelShorts',
Original file line number Diff line number Diff line change
@@ -239,12 +239,24 @@
:tooltip="$t('Tooltips.Distraction Free Settings.Hide Channels')"
:validate-tag-name="validateChannelId"
:find-tag-info="findChannelTagInfo"
:are-channel-tags="true"
@invalid-name="handleInvalidChannel"
@error-find-tag-info="handleChannelAPIError"
@change="handleChannelsHidden"
@already-exists="handleChannelsExists"
/>
</ft-flex-box>
<ft-flex-box>
<ft-input-tags
:label="$t('Settings.Distraction Free Settings.Hide Videos Containing Text')"
:tag-name-placeholder="$t('Settings.Distraction Free Settings.Hide Videos Containing Text Placeholder')"
:show-action-button="true"
:tag-list="forbiddenVideoTitleText"
:min-input-length="3"
:tooltip="$t('Tooltips.Distraction Free Settings.Hide Videos Containing Text')"
@change="handleForbiddenVideoTitleText"
/>
</ft-flex-box>
</ft-settings-section>
</template>

13 changes: 13 additions & 0 deletions src/renderer/components/ft-community-post/ft-community-post.js
Original file line number Diff line number Diff line change
@@ -27,6 +27,10 @@ export default defineComponent({
appearance: {
type: String,
required: true
},
hideVideosWithForbiddenTextInTitle: {
type: Boolean,
default: true
}
},
data: function () {
@@ -57,6 +61,15 @@ export default defineComponent({

listType: function () {
return this.$store.getters.getListType
},

forbiddenVideoTitleText() {
if (!this.hideVideosWithForbiddenTextInTitle) { return [] }
return JSON.parse(this.$store.getters.getForbiddenVideoTitleText)
},

hideVideo() {
return this.forbiddenVideoTitleText.some((text) => this.data.postContent.content.title?.toLowerCase().includes(text.toLowerCase()))
}
},
created: function () {
Original file line number Diff line number Diff line change
@@ -13,6 +13,12 @@
box-sizing: border-box;
}

.hiddenVideo {
font-style: italic;
opacity: 0.85;
text-align: center;
}

.communityImage {
block-size: 100%;
inline-size: 100%;
Original file line number Diff line number Diff line change
@@ -82,9 +82,16 @@
v-if="type === 'video'"
>
<ft-list-video
v-if="!hideVideo"
:data="data.postContent.content"
appearance=""
/>
<p
v-else
class="hiddenVideo"
>
{{ '[' + $t('Channel.Community.Video hidden by FreeTube') + ']' }}
</p>
</div>
<div
v-if="type === 'poll' || type === 'quiz'"
4 changes: 4 additions & 0 deletions src/renderer/components/ft-element-list/ft-element-list.js
Original file line number Diff line number Diff line change
@@ -26,6 +26,10 @@ export default defineComponent({
type: Boolean,
default: true,
},
hideVideosWithForbiddenTextInTitle: {
type: Boolean,
default: true
}
},
computed: {
listType: function () {
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
:layout="displayValue"
:show-video-with-last-viewed-playlist="showVideoWithLastViewedPlaylist"
:use-channels-hidden-preference="useChannelsHiddenPreference"
:hide-videos-with-forbidden-text-in-title="hideVideosWithForbiddenTextInTitle"
/>
</ft-auto-grid>
</template>
37 changes: 37 additions & 0 deletions src/renderer/components/ft-input-tags/ft-input-tags.js
Original file line number Diff line number Diff line change
@@ -7,6 +7,10 @@ export default defineComponent({
'ft-input': FtInput,
},
props: {
areChannelTags: {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
@@ -23,6 +27,10 @@ export default defineComponent({
type: String,
required: true
},
minInputLength: {
type: Number,
default: 1
},
showActionButton: {
type: Boolean,
default: true
@@ -46,6 +54,21 @@ export default defineComponent({
},
methods: {
updateTags: async function (text, _e) {
if (this.areChannelTags) {
await this.updateChannelTags(text, _e)
return
}
// text entered add tag and update tag list
const trimmedText = text.trim()
if (!this.tagList.includes(trimmedText)) {
const newList = this.tagList.slice(0)
newList.push(trimmedText)
this.$emit('change', newList)
}
// clear input box
this.$refs.tagNameInput.handleClearTextClick()
},
updateChannelTags: async function (text, _e) {
// text entered add tag and update tag list
const name = text.trim()

@@ -73,6 +96,20 @@ export default defineComponent({
this.$refs.tagNameInput.handleClearTextClick()
},
removeTag: function (tag) {
if (this.areChannelTags) {
this.removeChannelTag(tag)
return
}
// Remove tag from list
const tagName = tag.trim()
if (this.tagList.includes(tagName)) {
const newList = this.tagList.slice(0)
const index = newList.indexOf(tagName)
newList.splice(index, 1)
this.$emit('change', newList)
}
},
removeChannelTag: function (tag) {
// Remove tag from list
if (this.tagList.some((tmpTag) => tmpTag.name === tag.name)) {
const newList = this.tagList.filter((tmpTag) => tmpTag.name !== tag.name)
26 changes: 15 additions & 11 deletions src/renderer/components/ft-input-tags/ft-input-tags.vue
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
:disabled="disabled"
:placeholder="tagNamePlaceholder"
:label="label"
:min-input-length="minInputLength"
:show-label="true"
:tooltip="tooltip"
:show-action-button="showActionButton"
@@ -26,18 +27,21 @@
v-for="tag in tagList"
:key="tag.id"
>
<router-link
v-if="tag.icon"
:to="tag.iconHref ?? ''"
class="tag-icon-link"
>
<img
:src="tag.icon"
alt=""
class="tag-icon"
<template v-if="areChannelTags">
<router-link
v-if="tag.icon"
:to="tag.iconHref ?? ''"
class="tag-icon-link"
>
</router-link>
<span>{{ (tag.preferredName) ? tag.preferredName : tag.name }}</span>
<img
:src="tag.icon"
alt=""
class="tag-icon"
>
</router-link>
<span>{{ (tag.preferredName) ? tag.preferredName : tag.name }}</span>
</template>
<span v-else>{{ tag }}</span>
<font-awesome-icon
v-if="!disabled"
:icon="['fas', 'fa-times']"
6 changes: 5 additions & 1 deletion src/renderer/components/ft-input/ft-input.js
Original file line number Diff line number Diff line change
@@ -54,6 +54,10 @@ export default defineComponent({
type: Boolean,
default: true
},
minInputLength: {
type: Number,
default: 1
},
dataList: {
type: Array,
default: () => { return [] }
@@ -99,7 +103,7 @@ export default defineComponent({
},

inputDataPresent: function () {
return this.inputData.length > 0
return this.inputData.length >= this.minInputLength
},
inputDataDisplayed() {
if (!this.isSearch) { return this.inputData }
Original file line number Diff line number Diff line change
@@ -39,6 +39,10 @@ export default defineComponent({
type: Boolean,
default: true,
},
hideVideosWithForbiddenTextInTitle: {
type: Boolean,
default: true
},
},
data: function () {
return {
@@ -61,6 +65,10 @@ export default defineComponent({
return ch
})
},
forbiddenVideoTitleText: function() {
if (!this.hideVideosWithForbiddenTextInTitle) { return [] }
return JSON.parse(this.$store.getters.getForbiddenVideoTitleText)
},
hideUpcomingPremieres: function () {
return this.$store.getters.getHideUpcomingPremieres
},
@@ -97,6 +105,9 @@ export default defineComponent({
// hide videos by author
return false
}
if (this.forbiddenVideoTitleText.some((text) => this.data.title?.toLowerCase().includes(text.toLowerCase()))) {
return false
}
} else if (data.type === 'channel') {
const attrsToCheck = [
// Local API
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@
/>
<ft-community-post
v-else-if="data.type === 'community'"
:hide-videos-with-forbidden-text-in-title="hideVideosWithForbiddenTextInTitle"
:appearance="appearance"
:data="data"
/>
12 changes: 11 additions & 1 deletion src/renderer/components/ft-list-video-lazy/ft-list-video-lazy.js
Original file line number Diff line number Diff line change
@@ -47,6 +47,10 @@ export default defineComponent({
type: Boolean,
default: false,
},
hideVideosWithForbiddenTextInTitle: {
type: Boolean,
default: false
}
},
data: function () {
return {
@@ -67,9 +71,15 @@ export default defineComponent({
})
},

forbiddenVideoTitleText() {
if (!this.hideVideosWithForbiddenTextInTitle) { return [] }
return JSON.parse(this.$store.getters.getForbiddenVideoTitleText)
},

shouldBeVisible() {
return !(this.channelsHidden.some(ch => ch.name === this.data.authorId) ||
this.channelsHidden.some(ch => ch.name === this.data.author))
this.channelsHidden.some(ch => ch.name === this.data.author) ||
this.forbiddenVideoTitleText.some((text) => this.data.title?.toLowerCase().includes(text.toLowerCase())))
}
},
created() {
2 changes: 1 addition & 1 deletion src/renderer/components/ft-video-player/ft-video-player.js
Original file line number Diff line number Diff line change
@@ -771,7 +771,7 @@ export default defineComponent({
let newTime = null
let skippedCategory = null
skipSegments.forEach(({ category, segment: [startTime, endTime] }) => {
if (startTime <= currentTime && currentTime < endTime) {
if (startTime <= currentTime && currentTime <= endTime) {
newTime = endTime
skippedCategory = category
}
Original file line number Diff line number Diff line change
@@ -43,6 +43,7 @@
v-if="!isLoading && activeVideoList.length > 0"
:data="activeVideoList"
:use-channels-hidden-preference="false"
:hide-videos-with-forbidden-text-in-title="true"
:display="isCommunity ? 'list' : ''"
/>
<ft-flex-box
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@
appearance="recommendation"
force-list-type="list"
:use-channels-hidden-preference="true"
:hide-videos-with-forbidden-text-in-title="true"
/>
</ft-card>
</template>
1 change: 1 addition & 0 deletions src/renderer/store/modules/settings.js
Original file line number Diff line number Diff line change
@@ -204,6 +204,7 @@ const state = {
hideComments: false,
hideFeaturedChannels: false,
channelsHidden: '[]',
forbiddenVideoTitleText: '[]',
hideVideoDescription: false,
hideLiveChat: false,
hideLiveStreams: false,
Loading