Skip to content

Commit 0a35b6d

Browse files
committed
Update search filters in line with YouTube changes
1 parent 14fe16f commit 0a35b6d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+302
-668
lines changed

src/renderer/components/FtSearchFilters/FtSearchFilters.vue

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727

2828
<FtFlexBox class="radioFlexBox">
2929
<FtRadioButton
30-
v-model="sortByValue"
31-
:title="$t('Global.Sort By')"
32-
:labels="sortByLabels"
33-
:values="SORT_BY_VALUES"
30+
v-model="prioritizeValue"
31+
:title="$t('Search Filters.Prioritize.Prioritize')"
32+
:labels="prioritizeLabels"
33+
:values="PRIORITIZE_VALUES"
3434
class="searchRadio"
3535
/>
3636
<FtRadioButton
@@ -87,16 +87,13 @@ import store from '../../store/index'
8787
8888
const { t } = useI18n()
8989
90-
const SORT_BY_VALUES = [
90+
const PRIORITIZE_VALUES = [
9191
'relevance',
92-
'rating',
93-
'upload_date',
94-
'view_count'
92+
'popularity'
9593
]
9694
9795
const TIME_VALUES = [
9896
'',
99-
'hour',
10097
'today',
10198
'week',
10299
'month',
@@ -106,16 +103,17 @@ const TIME_VALUES = [
106103
const TYPE_VALUES = [
107104
'all',
108105
'video',
106+
'shorts',
109107
'channel',
110108
'playlist',
111109
'movie'
112110
]
113111
114112
const DURATION_VALUES = [
115113
'',
116-
'short',
117-
'medium',
118-
'long'
114+
'under_three_mins',
115+
'three_to_twenty_mins',
116+
'over_twenty_mins'
119117
]
120118
121119
const FEATURE_VALUES = [
@@ -140,16 +138,13 @@ const NOT_ALLOWED_FOR_MOVIES_FEATURES = [
140138
141139
const title = computed(() => t('Search Filters.Search Filters'))
142140
143-
const sortByLabels = computed(() => [
144-
t('Search Filters.Sort By.Most Relevant'),
145-
t('Search Filters.Sort By.Rating'),
146-
t('Search Filters.Sort By.Upload Date'),
147-
t('Search Filters.Sort By.View Count')
141+
const prioritizeLabels = computed(() => [
142+
t('Search Filters.Prioritize.Most Relevant'),
143+
t('Search Filters.Prioritize.Popularity')
148144
])
149145
150146
const timeLabels = computed(() => [
151147
t('Search Filters.Time.Any Time'),
152-
t('Search Filters.Time.Last Hour'),
153148
t('Search Filters.Time.Today'),
154149
t('Search Filters.Time.This Week'),
155150
t('Search Filters.Time.This Month'),
@@ -159,16 +154,17 @@ const timeLabels = computed(() => [
159154
const typeLabels = computed(() => [
160155
t('Search Filters.Type.All Types'),
161156
t('Search Filters.Type.Videos'),
157+
t('Global.Shorts'),
162158
t('Search Filters.Type.Channels'),
163159
t('Playlists'),
164160
t('Search Filters.Type.Movies')
165161
])
166162
167163
const durationLabels = computed(() => [
168164
t('Search Filters.Duration.All Durations'),
169-
t('Search Filters.Duration.Short (< 4 minutes)'),
170-
t('Search Filters.Duration.Medium (4 - 20 minutes)'),
171-
t('Search Filters.Duration.Long (> 20 minutes)')
165+
t('Search Filters.Duration.< 3 minutes'),
166+
t('Search Filters.Duration.3 - 20 minutes'),
167+
t('Search Filters.Duration.> 20 minutes')
172168
])
173169
174170
const featureLabels = computed(() => [
@@ -186,14 +182,18 @@ const featureLabels = computed(() => [
186182
187183
const searchSettings = store.getters.getSearchSettings
188184
189-
/** @type {import('vue').Ref<'relevance' | 'rating' | 'upload_date' | 'view_count'>} */
190-
const sortByValue = ref(searchSettings.sortBy)
185+
/** @type {import('vue').Ref<'relevance' | 'popularity'>} */
186+
const prioritizeValue = ref(searchSettings.prioritize)
191187
192-
watch(sortByValue, (value) => {
193-
store.commit('setSearchSortBy', value)
188+
watch(prioritizeValue, (value) => {
189+
if (value === 'popularity' && (typeValue.value === 'channel' || typeValue.value === 'playlist')) {
190+
typeValue.value = 'all'
191+
}
192+
193+
store.commit('setSearchPrioritize', value)
194194
})
195195
196-
/** @type {import('vue').Ref<'' | 'hour' | 'today' | 'week' | 'month' | 'year'>} */
196+
/** @type {import('vue').Ref<'' | 'today' | 'week' | 'month' | 'year'>} */
197197
const timeValue = ref(searchSettings.time)
198198
199199
watch(timeValue, (value) => {
@@ -204,14 +204,16 @@ watch(timeValue, (value) => {
204204
store.commit('setSearchTime', value)
205205
})
206206
207-
/** @type {import('vue').Ref<'all' | 'video' | 'channel' | 'playlist' | 'movie'>} */
207+
/** @type {import('vue').Ref<'all' | 'video' | 'shorts' | 'channel' | 'playlist' | 'movie'>} */
208208
const typeValue = ref(searchSettings.type)
209209
210210
watch(typeValue, (value) => {
211-
if (value === 'channel' || value === 'playlist') {
211+
if (value === 'shorts') {
212+
durationValue.value = ''
213+
} else if (value === 'channel' || value === 'playlist') {
212214
timeValue.value = ''
213215
durationValue.value = ''
214-
sortByValue.value = SORT_BY_VALUES[0]
216+
prioritizeValue.value = PRIORITIZE_VALUES[0]
215217
if (featuresValue.value.length > 0) {
216218
featuresValue.value = []
217219
}
@@ -224,7 +226,7 @@ watch(typeValue, (value) => {
224226
store.commit('setSearchType', value)
225227
})
226228
227-
/** @type {import('vue').Ref<'' | 'short' | 'medium' | 'long'>} */
229+
/** @type {import('vue').Ref<'' | 'under_three_mins' | 'three_to_twenty_mins' | 'over_twenty_mins'>} */
228230
const durationValue = ref(searchSettings.duration)
229231
230232
watch(durationValue, (value) => {
@@ -247,7 +249,7 @@ watch(featuresValue, (values) => {
247249
}, { deep: true })
248250
249251
const searchFilterValueChanged = computed(() => {
250-
return sortByValue.value !== SORT_BY_VALUES[0] ||
252+
return prioritizeValue.value !== PRIORITIZE_VALUES[0] ||
251253
timeValue.value !== TIME_VALUES[0] ||
252254
typeValue.value !== TYPE_VALUES[0] ||
253255
durationValue.value !== DURATION_VALUES[0] ||
@@ -270,7 +272,7 @@ function isVideoOrMovieOrAll(type) {
270272
}
271273
272274
function clearFilters() {
273-
sortByValue.value = SORT_BY_VALUES[0]
275+
prioritizeValue.value = PRIORITIZE_VALUES[0]
274276
timeValue.value = TIME_VALUES[0]
275277
typeValue.value = TYPE_VALUES[0]
276278
durationValue.value = DURATION_VALUES[0]

src/renderer/helpers/api/invidious.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -540,17 +540,24 @@ export async function getInvidiousPopularFeed() {
540540
* @param {any} searchSettings
541541
*/
542542
export async function getInvidiousSearchResults(query, page, searchSettings) {
543+
const DURATION_MAP = {
544+
'': '',
545+
under_three_mins: 'short',
546+
three_to_twenty_mins: 'medium',
547+
over_twenty_mins: 'long',
548+
}
549+
543550
/** @type {Promise<(InvidiousChannelObject | InvidiousPlaylistObject | InvidiousVideoType | InvidiousHashtagObject)[] | null>} */
544551
let results = await invidiousAPICall({
545552
resource: 'search',
546553
id: '',
547554
params: {
548555
q: query,
549556
page,
550-
sort_by: searchSettings.sortBy,
557+
sort_by: searchSettings.prioritize,
551558
date: searchSettings.time,
552-
duration: searchSettings.duration,
553-
type: searchSettings.type,
559+
duration: DURATION_MAP[searchSettings.duration],
560+
type: searchSettings.type === 'popularity' ? 'view_count' : 'searchSettings.type',
554561
features: searchSettings.features.join(',')
555562
}
556563
})

src/renderer/helpers/api/local.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,8 +1794,8 @@ function convertSearchFilters(filters) {
17941794
// others have empty strings that we don't want to pass to youtubei.js
17951795

17961796
if (filters) {
1797-
if (filters.sortBy) {
1798-
convertedFilters.sort_by = filters.sortBy
1797+
if (filters.prioritize) {
1798+
convertedFilters.prioritize = filters.prioritize
17991799
}
18001800

18011801
if (filters.time) {

src/renderer/helpers/utils.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,12 +483,12 @@ export function formatDurationAsTimestamp(lengthSeconds) {
483483
}
484484

485485
/**
486-
* @param {{sortBy? : string, time?: string, duration?: string, features: string[]}?} filtersA
487-
* @param {{sortBy? : string, time?: string, duration?: string, features: string[]}?} filtersB
486+
* @param {{prioritize? : string, time?: string, duration?: string, features: string[]}?} filtersA
487+
* @param {{prioritize? : string, time?: string, duration?: string, features: string[]}?} filtersB
488488
* @returns {boolean}
489489
*/
490490
export function searchFiltersMatch(filtersA, filtersB) {
491-
return filtersA?.sortBy === filtersB?.sortBy &&
491+
return filtersA?.prioritize === filtersB?.prioritize &&
492492
filtersA?.time === filtersB?.time &&
493493
filtersA?.type === filtersB?.type &&
494494
filtersA?.duration === filtersB?.duration &&

src/renderer/store/modules/utils.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const state = {
3434
regionValues: [],
3535
recentBlogPosts: [],
3636
searchSettings: {
37-
sortBy: 'relevance',
37+
prioritize: 'relevance',
3838
time: '',
3939
type: 'all',
4040
duration: '',
@@ -440,7 +440,7 @@ const actions = {
440440

441441
const searchSettings = state.searchSettings
442442
const query = {
443-
sortBy: searchSettings.sortBy,
443+
prioritize: searchSettings.prioritize,
444444
time: searchSettings.time,
445445
type: searchSettings.type,
446446
duration: searchSettings.duration,
@@ -739,8 +739,8 @@ const mutations = {
739739
state.searchFilterValueChanged = value
740740
},
741741

742-
setSearchSortBy (state, value) {
743-
state.searchSettings.sortBy = value
742+
setSearchPrioritize (state, value) {
743+
state.searchSettings.prioritize = value
744744
},
745745

746746
setSearchTime (state, value) {

static/locales/af.yaml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,11 @@ Search Listing:
7070
8K: 8K
7171
Search Filters:
7272
Search Filters: 'Soekfilters'
73-
Sort By:
73+
Prioritize:
7474
Most Relevant: 'Mees relevant'
75-
Rating: 'Gradering'
76-
Upload Date: 'Oplaaddatum'
77-
View Count: 'Beskouingsaantal'
7875
Time:
7976
Time: 'Tyd'
8077
Any Time: 'Enige tyd'
81-
Last Hour: 'Laaste uur'
8278
Today: 'Vandag'
8379
This Week: 'Hierdie week'
8480
This Month: 'Hierdie maand'
@@ -93,9 +89,9 @@ Search Filters:
9389
Duration:
9490
Duration: 'Duur'
9591
All Durations: 'Alle durasies'
96-
Short (< 4 minutes): 'Kort (<4 minute)'
97-
Medium (4 - 20 minutes): 'Medium (4 - 20 minute)'
98-
Long (> 20 minutes): 'Lank (> 20 minute)'
92+
'< 3 minutes': '<3 minute'
93+
'3 - 20 minutes': '3 - 20 minute'
94+
'> 20 minutes': '> 20 minute'
9995
Features:
10096
Features: 'Funksies'
10197
HD: 'HD'

static/locales/ar.yaml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,11 @@ Search / Go to URL: 'ابحث / اذهب إلى رابط'
4545
# In Filter Button
4646
Search Filters:
4747
Search Filters: 'فلاتر البحث'
48-
Sort By:
48+
Prioritize:
4949
Most Relevant: 'الأكثر صلة'
50-
Rating: 'التقييم'
51-
Upload Date: 'تاريخ الرفع'
52-
View Count: 'عدد المشاهدات'
5350
Time:
5451
Time: 'الوقت'
5552
Any Time: 'أي وقت'
56-
Last Hour: 'آخر ساعة'
5753
Today: 'اليوم'
5854
This Week: 'هذا الأسبوع'
5955
This Month: 'هذا الشهر'
@@ -68,10 +64,6 @@ Search Filters:
6864
Duration:
6965
Duration: 'المدة'
7066
All Durations: 'كل الآوقات'
71-
Short (< 4 minutes): 'قصير (< 4 دقائق)'
72-
Long (> 20 minutes): 'طويل (> 20 دقيقة)'
73-
# On Search Page
74-
Medium (4 - 20 minutes): متوسط (4 - 20 دقيقة)
7567
Search Results: 'نتائج البحث'
7668
Fetching results. Please wait: 'جاري إحضار النتائج. الرجاء الانتظار'
7769
Fetch more results: 'إحضار المزيد من النتائج'

static/locales/awa.yaml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,11 @@ Search Listing:
7373
# In Filter Button
7474
Search Filters:
7575
Search Filters: 'हेरय कै फिलटर'
76-
Sort By:
76+
Prioritize:
7777
Most Relevant: 'सबसे ठीक'
78-
Rating: 'रेटिंग'
79-
Upload Date: 'अपलोड तारिख'
80-
View Count: 'ब्यू कै गिनती'
8178
Time:
8279
Time: 'समय'
8380
Any Time: 'कबो भी'
84-
Last Hour: 'पिछले घंटा'
8581
Today: 'आज'
8682
This Week: 'यहि हफ्ता'
8783
This Month: 'यहि महीना'
@@ -96,9 +92,6 @@ Search Filters:
9692
Duration:
9793
Duration: 'मियाद'
9894
All Durations: 'सब अवधि (मियाद)'
99-
Short (< 4 minutes): '4 मिनट से छोट'
100-
Medium (4 - 20 minutes): 'मद्धिम 4 से 20 मिनट कै'
101-
Long (> 20 minutes): 'बड़वार 20 मिनट से जादा'
10295
Features:
10396
Features: 'सुबिधा'
10497
HD: 'एचडी'

static/locales/az.yaml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,11 @@ Search Bar:
3838
Remove: Sil
3939
Search Filters:
4040
Search Filters: 'Axtarış Filtrləri'
41-
Sort By:
41+
Prioritize:
4242
Most Relevant: 'Ən Münasib'
43-
Rating: 'Qiymətləndirmə'
44-
Upload Date: 'Yükləmə Tarixi'
45-
View Count: 'Baxış Sayı'
4643
Time:
4744
Time: 'Vaxt'
4845
Any Time: 'İstənilən Vaxt'
49-
Last Hour: 'Son Saat'
5046
Today: 'Bu gün'
5147
This Week: 'Bu Həftə'
5248
This Month: 'Bu Ay'
@@ -61,10 +57,9 @@ Search Filters:
6157
Duration:
6258
Duration: 'Müddət'
6359
All Durations: 'Bütün Müddətlər'
64-
Short (< 4 minutes): 'Qısa (<4 dəqiqədən az)'
65-
Long (> 20 minutes): 'Uzun (> 20 dəqiqədən çox)'
66-
# On Search Page
67-
Medium (4 - 20 minutes): Orta (4-20 dəqiqə)
60+
'< 3 minutes': '<3 dəqiqədən az'
61+
'> 20 minutes': '> 20 dəqiqədən çox'
62+
'3 - 20 minutes': 3-20 dəqiq
6863
Search Results: 'Axtarış Nəticələri'
6964
Fetching results. Please wait: 'Nəticələr alınır. Zəhmət olmasa, gözləyin'
7065
Fetch more results: 'Daha çox nəticə əldə edin'

static/locales/be.yaml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,11 @@ Search Bar:
5656
Remove: Выдаліць
5757
Search Filters:
5858
Search Filters: 'Фільтры пошуку'
59-
Sort By:
59+
Prioritize:
6060
Most Relevant: 'Найбольш рэлевантныя'
61-
Rating: 'Рэйтынг'
62-
Upload Date: 'Дата запампоўвання'
63-
View Count: 'Колькасць праглядаў'
6461
Time:
6562
Time: 'Час'
6663
Any Time: 'За ўвесь час'
67-
Last Hour: 'За апошнюю гадзіну'
6864
Today: 'Сёння'
6965
This Week: 'За гэты тыдзень'
7066
This Month: 'За гэты месяц'
@@ -79,9 +75,9 @@ Search Filters:
7975
Duration:
8076
Duration: 'Працягласць'
8177
All Durations: 'Любая працягласць'
82-
Short (< 4 minutes): 'Кароткія (< 4 хвілін)'
83-
Medium (4 - 20 minutes): 'Сярэднія (4-20 хвілін)'
84-
Long (> 20 minutes): 'Доўгія (> 20 хвілін)'
78+
'< 3 minutes': '< 3 хвілін'
79+
'3 - 20 minutes': '3-20 хвілін'
80+
'> 20 minutes': '> 20 хвілін'
8581
# On Search Page
8682
Search Results: 'Вынікі пошуку'
8783
Fetching results. Please wait: 'Атрыманне вынікаў. Калі ласка, пачакайце'

0 commit comments

Comments
 (0)