Implemented a filter for shorts

This commit is contained in:
root
2024-04-10 20:34:20 +05:30
parent 785348e601
commit 05fa16902a
7 changed files with 58 additions and 27 deletions
+4
View File
@@ -138,15 +138,19 @@ export default {
tab.originalName = tab.name
switch (tab.name) {
case 'Livestreams':
case 'livestreams':
tab.name = this.$t('channel_tabs.livestreams')
break
case 'Playlists':
case 'playlists':
tab.name = this.$t('channel_tabs.playlists')
break
case 'Channels':
case 'channels':
tab.name = this.$t('channel_tabs.channels')
break
case 'Shorts':
case 'shorts':
tab.name = this.$t('channel_tabs.shorts')
break
}
+8 -1
View File
@@ -159,7 +159,14 @@ export default {
computed: {
currentVideos () {
const start = (this.currentPage - 1) * PAGE_SIZE
return this.videos.slice(start, start + PAGE_SIZE)
let out = this.videos.slice(start, start + PAGE_SIZE)
const isShortsFilterEnabled = this.$store.getters['prefs/getPreferenceBoolean']('filterOutShortsInFeedPage', false)
if (isShortsFilterEnabled) {
out = out.filter(v => v.isShort === false)
}
return out
}
},
components: {
+10
View File
@@ -190,6 +190,16 @@ export default {
type: 'bool',
default: false
},
{
id: 'filterOutShortsInFeedPage',
type: 'bool',
default: false
},
{
id: 'filterOutShortsInSearchResults',
type: 'bool',
default: false
},
{
id: 'showRelatedVideos',
type: 'bool',
+26 -22
View File
@@ -12,9 +12,9 @@
/>
<v-divider class="my-4" />
<div v-if="results && results.items">
<div v-if="filteredResults.length !== 0">
<GridRow>
<GridCol v-for="(video, videoId) in results.items" :key="videoId">
<GridCol v-for="(video, videoId) in filteredResults" :key="videoId">
<VideoItem :height="270" :width="480" :video="video" max-height v-if="video.type === 'stream'" />
<GenericDisplayItem :height="270" :width="480" :item="video" v-else />
</GridCol>
@@ -51,7 +51,7 @@ export default {
},
mounted () {
this.updateResults()
this.fetchResults()
},
computed: {
@@ -73,31 +73,41 @@ export default {
text: this.$t('search_results.result_types.' + name),
value: name
}))
},
filteredResults () {
let out = this.results?.items
if (out == null) {
return []
}
const isShortsFilterEnabled = this.$store.getters['prefs/getPreferenceBoolean']('filterOutShortsInSearchResults', false)
if (isShortsFilterEnabled) {
out = out.filter(v => v.isShort === false)
}
return out.map(sr => ({
title: sr.name,
uploaderName: sr.uploader,
uploadedDate: sr.uploadDate,
...sr
}))
}
},
watch: {
// For history navigation
'$route.query.search_query' () {
this.updateResults()
this.fetchResults()
},
'$route.query.filter' () {
this.updateResults()
this.fetchResults()
}
},
methods: {
rationalizeSearchResult (sr) {
return {
title: sr.name,
uploaderName: sr.uploader,
uploadedDate: sr.uploadDate,
...sr
}
},
async fetchResults () {
return this.$store.dispatch('auth/makeRequest', {
this.results = await this.$store.dispatch('auth/makeRequest', {
path: 'search',
params: {
q: this.$route.query.search_query,
@@ -106,12 +116,6 @@ export default {
})
},
async updateResults () {
this.results = this.fetchResults().then(json => {
json.items = json.items.map(this.rationalizeSearchResult)
this.results = json
})
},
onSearchResultsEndIntersect (entries) {
if (entries[0].isIntersecting) {
this.fetchMoreResults()
@@ -129,7 +133,7 @@ export default {
}).then(json => {
this.results.nextpage = json.nextpage
this.results.id = json.id
this.results.items = this.results.items.concat(json.items.map(this.rationalizeSearchResult))
this.results.items = this.results.items.concat(json.items)
})
}
}
+2
View File
@@ -22,6 +22,8 @@ const PrefsStore = {
clickbaitThumbnailAvoidance: false,
disableDuplicateHistoryEntries: false,
filterOutShortsInFeedPage: false,
filterOutShortsInSearchResults: false,
disableCommentsByDefault: false,
showRelatedVideos: true,
showMarkers: true,
+6 -4
View File
@@ -6,7 +6,7 @@
"feed": "আপনার feed",
"preferences": "পছন্দ অনুযায়ী মানিয়ে নিন",
"history": "দেখার ইতিহাস",
"playlists": "videoর তালিকা"
"playlists": "videoর তালিকা"
},
"visibilities": {
"unlisted": "অপ্রচারিত"
@@ -119,12 +119,14 @@
"homepage": "website খোলার পর গতানুগতিক কী দেখবেন",
"homepageButton": "আপনি কী গোড়াতে ফিরে যাওয়ার জন্য আরেকটি বোতাম চান?",
"instance": "আমাদের প্রতিনিধি যে YouTube এর সঙ্গে সব যোগাযোগ এর নিয়ন্ত্রণ আর দেখাশোনা করবে",
"clickbaitThumbnailAvoidance": "videoর যে thumbnail আছে সেটি কি একতা স্বয়ংক্রিয়ভাবে বানানো thumbnail দিয়ে প্রতিস্থাপন করে দেব?",
"clickbaitThumbnailAvoidance": "videoর যে thumbnail আছে সেটি কি একতা স্বয়ংক্রিয়ভাবে বানানো thumbnail দিয়ে প্রতিস্থাপন করে দেব?",
"showRelatedVideos": "আপনি কি videoর সঙ্গে অন্য সম্পর্কিত বা প্রস্তাবিত video দেখতে চান?",
"showMarkers": "আপনি কি বিজ্ঞাপনের (ও অন্য বিভ্রান্তিকর জিনিসের) চিহ্নিতকারী দেখতে চান?",
"bufferGoal": "কত সেকেণ্ডের data এনে রাখব যাতে আপানাকে অপেক্ষা না করতে হয়?",
"disableCommentsByDefault": "মন্তব্য দেখানোর জন্য আপনার অনুমতি কি চাওয়া হবে?",
"disableDuplicateHistoryEntries": "আপনি যদি একটি video অতীতে দেখে থাকেন তাহলে কি আর ইতিহাস এ অনুলিপি যোগ করব না, শুধু মাত্র কতটা আর কখন দেখেছেন সেটা নবীকরণ করব?",
"filterOutShortsInFeedPage": "আপনি কি সব YouTube Shorts (ছোট video) গুলো কে আপনার feed (সদস্যিত channelদের videoর তালিকা) থেকে পরিস্রুত করাতে চান?",
"filterOutShortsInSearchResults": "আপনি কি সব YouTube Shorts (ছোট video) গুলো কে আপনার search results (খোঁজ করা videoর ফলাফল) থেকে পরিস্রুত করাতে চান?",
"quality_opts": {
"auto": "আপনার অন্তর্জালের গতি অনুযায়ী",
"144p": "১৪৪ বিন্দু আরোহ",
@@ -155,7 +157,7 @@
"all": "সব ধরণের ফলাফল",
"videos": "সাধারণ video",
"channels": "সুধু channel",
"playlists": "সুধু videoর তালিকা",
"playlists": "সুধু videoর তালিকা",
"music_songs": "সুধু গান (YouTube Music থেকে)",
"music_videos": "সুধু গানের video (YouTube Music)",
"music_albums": "সুধু গানের পঞ্জি (album) (YouTube Music থেকে)",
@@ -163,7 +165,7 @@
}
},
"channel_tabs": {
"playlists": "videoর তালিকা",
"playlists": "videoর তালিকা",
"shorts": "ছোট video",
"videos": "সাধারণ video",
"livestreams": "সরাসরি সম্প্রচারিত video",
+2
View File
@@ -148,6 +148,8 @@
"showRelatedVideos": "Show Related Videos",
"showMarkers": "Show SponsorBlock Markers",
"disableDuplicateHistoryEntries": "Disable creation of duplicate watch history entries",
"filterOutShortsInFeedPage": "Filter out YT shorts in the feed pages (trending, feed, etc.)",
"filterOutShortsInSearchResults": "Filter out YT shorts in the search result pages",
"quality_opts": {
"auto": "Automatically determined",
"144p": "144p",