itube-specs 0.0.219 → 0.0.222
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/composables/use-fetch-videos.ts +77 -0
- package/lib/index.ts +6 -0
- package/lib/scheme/select-added-items.ts +45 -0
- package/lib/scheme/select-duration-items.ts +39 -0
- package/lib/scheme/sort-channels.ts +28 -0
- package/lib/scheme/sort-items-default.ts +22 -0
- package/lib/scheme/sort-models.ts +22 -0
- package/lib/scheme/sort-playlists.ts +22 -0
- package/package.json +1 -1
- package/runtime/utils/normalize-url.ts +5 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { selectDurationItems, sortItemsDefault, selectAddedItems } from '../lib/';
|
|
2
|
+
import { EAsyncData, ELanguage, getSelectedQuery, ApiHelper } from '../runtime';
|
|
3
|
+
import { useRoute } from 'vue-router';
|
|
4
|
+
import type { IVideoCard, PaginatedResponse, RequestPagination, IRequestVideoFilter } from '../types';
|
|
5
|
+
|
|
6
|
+
async function getListByNiche(
|
|
7
|
+
pagination: RequestPagination,
|
|
8
|
+
videosFilter: IRequestVideoFilter,
|
|
9
|
+
lang: ELanguage,
|
|
10
|
+
order: string,
|
|
11
|
+
niche = 'gay',
|
|
12
|
+
): Promise<PaginatedResponse<IVideoCard>> {
|
|
13
|
+
return await ApiHelper.fetch(
|
|
14
|
+
'/videos/list-by-niche',
|
|
15
|
+
{
|
|
16
|
+
method: 'POST',
|
|
17
|
+
headers: {
|
|
18
|
+
'X-Niche': niche,
|
|
19
|
+
'X-Language': lang,
|
|
20
|
+
'X-Cache-Time': '259200',
|
|
21
|
+
'Content-Type': 'application/json',
|
|
22
|
+
},
|
|
23
|
+
params: {
|
|
24
|
+
...pagination,
|
|
25
|
+
order,
|
|
26
|
+
},
|
|
27
|
+
body: {
|
|
28
|
+
filter_request: videosFilter,
|
|
29
|
+
max_limit: 0,
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const useFetchVideos = async () => {
|
|
36
|
+
const route = useRoute();
|
|
37
|
+
const { locale } = useI18n();
|
|
38
|
+
const lang = locale.value as ELanguage;
|
|
39
|
+
const perPage = 48;
|
|
40
|
+
|
|
41
|
+
const { data, status, error } = await useAsyncData<PaginatedResponse<IVideoCard>>(
|
|
42
|
+
EAsyncData.Videos,
|
|
43
|
+
fetchData,
|
|
44
|
+
{
|
|
45
|
+
watch: [
|
|
46
|
+
() => {
|
|
47
|
+
if (route.query) {
|
|
48
|
+
const currentQuery = route.query;
|
|
49
|
+
return JSON.stringify(currentQuery);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
async function fetchData() {
|
|
57
|
+
try {
|
|
58
|
+
return await getListByNiche(
|
|
59
|
+
{
|
|
60
|
+
page: Number(route.query[ 'page' ]) || 1,
|
|
61
|
+
[ 'per-page' ]: perPage,
|
|
62
|
+
},
|
|
63
|
+
useGetVideosFilterRequest(route, selectDurationItems, selectAddedItems),
|
|
64
|
+
lang,
|
|
65
|
+
getSelectedQuery(route, sortItemsDefault) || '-popularity,-primary_thumb_rank'
|
|
66
|
+
);
|
|
67
|
+
} catch (err) {
|
|
68
|
+
throw createError({
|
|
69
|
+
statusCode: 500,
|
|
70
|
+
statusMessage: 'Error fetching videos',
|
|
71
|
+
message: err instanceof Error ? err.message : 'An unknown error occurred',
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return { data, status, error };
|
|
77
|
+
};
|
package/lib/index.ts
CHANGED
|
@@ -5,3 +5,9 @@ export * from './contacts/report-wrong-items';
|
|
|
5
5
|
export * from './report-forms-scheme';
|
|
6
6
|
export * from './contact-forms-scheme';
|
|
7
7
|
export * from './alphabet-items';
|
|
8
|
+
export * from './scheme/select-duration-items';
|
|
9
|
+
export * from './scheme/select-added-items';
|
|
10
|
+
export * from './scheme/sort-channels';
|
|
11
|
+
export * from './scheme/sort-models';
|
|
12
|
+
export * from './scheme/sort-playlists';
|
|
13
|
+
export * from './scheme/sort-items-default';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ISelectItem } from 'itube-specs/types';
|
|
2
|
+
|
|
3
|
+
export const selectAddedItems: Array<ISelectItem> = [
|
|
4
|
+
{
|
|
5
|
+
title: 'all',
|
|
6
|
+
key: 'added',
|
|
7
|
+
value: 'all',
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
title: '1 day ago',
|
|
11
|
+
key: 'added',
|
|
12
|
+
value: '1d',
|
|
13
|
+
query: '1d',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
title: '3 day ago',
|
|
17
|
+
key: 'added',
|
|
18
|
+
value: '3d',
|
|
19
|
+
query: '3d',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
title: '7 day ago',
|
|
23
|
+
key: 'added',
|
|
24
|
+
value: '7d',
|
|
25
|
+
query: '7d',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
title: '1 month ago',
|
|
29
|
+
key: 'added',
|
|
30
|
+
value: '30d',
|
|
31
|
+
query: '30d',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
title: '3 months ago',
|
|
35
|
+
key: 'added',
|
|
36
|
+
value: '90d',
|
|
37
|
+
query: '90d',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
title: 'other 1 year ago',
|
|
41
|
+
key: 'added',
|
|
42
|
+
value: '360d',
|
|
43
|
+
query: '360d',
|
|
44
|
+
},
|
|
45
|
+
];
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ISelectItem } from 'itube-specs/types';
|
|
2
|
+
|
|
3
|
+
export const selectDurationItems: Array<ISelectItem> = [
|
|
4
|
+
{
|
|
5
|
+
title: 'all',
|
|
6
|
+
key: 'duration',
|
|
7
|
+
value: 'all',
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
title: '< 10 minutes',
|
|
11
|
+
key: 'duration',
|
|
12
|
+
value: '600',
|
|
13
|
+
query: '599s',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
title: '10 - 30 minutes',
|
|
17
|
+
key: 'duration',
|
|
18
|
+
value: '1800',
|
|
19
|
+
query: ['600s', '1800s'],
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
title: '30 - 45 minutes',
|
|
23
|
+
key: 'duration',
|
|
24
|
+
value: '2700',
|
|
25
|
+
query: ['1800s', '2700s'],
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
title: '45 - 1 hours',
|
|
29
|
+
key: 'duration',
|
|
30
|
+
value: '3600',
|
|
31
|
+
query: ['2700s', '3600s'],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
title: 'other 1 hours',
|
|
35
|
+
key: 'duration',
|
|
36
|
+
value: '3601',
|
|
37
|
+
query: '3601s',
|
|
38
|
+
},
|
|
39
|
+
];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { IChipsItem } from 'itube-specs/types';
|
|
2
|
+
|
|
3
|
+
export const sortChannels: Array<IChipsItem> = [
|
|
4
|
+
{
|
|
5
|
+
title: 'sort.trending',
|
|
6
|
+
value: 'trending',
|
|
7
|
+
key: 'sort',
|
|
8
|
+
query: '',
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
title: 'sort.new_videos',
|
|
12
|
+
value: 'new-videos',
|
|
13
|
+
key: 'sort',
|
|
14
|
+
query: '-updated',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
title: 'A-Z',
|
|
18
|
+
value: 'alphabet',
|
|
19
|
+
key: 'sort',
|
|
20
|
+
query: 'name',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
title: 'sort.network',
|
|
24
|
+
value: 'network',
|
|
25
|
+
key: 'sort',
|
|
26
|
+
query: '-is_network',
|
|
27
|
+
},
|
|
28
|
+
];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IChipsItem } from 'itube-specs/types';
|
|
2
|
+
|
|
3
|
+
export const sortItemsDefault: Array<IChipsItem> = [
|
|
4
|
+
{
|
|
5
|
+
title: 'sort.trending',
|
|
6
|
+
value: 'trending',
|
|
7
|
+
key: 'sort',
|
|
8
|
+
query: '-popularity',
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
title: 'sort.new',
|
|
12
|
+
value: 'new-videos',
|
|
13
|
+
key: 'sort',
|
|
14
|
+
query: '-created',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
title: 'sort.longest',
|
|
18
|
+
value: 'longest',
|
|
19
|
+
key: 'sort',
|
|
20
|
+
query: '-duration',
|
|
21
|
+
},
|
|
22
|
+
];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { IChipsItem } from 'itube-specs/types';
|
|
2
|
+
|
|
3
|
+
export const sortModels: Array<IChipsItem> = [
|
|
4
|
+
{
|
|
5
|
+
title: 'sort.trending',
|
|
6
|
+
value: 'trending',
|
|
7
|
+
key: 'sort',
|
|
8
|
+
query: '-popularity',
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
title: 'sort.new_videos',
|
|
12
|
+
value: 'created',
|
|
13
|
+
key: 'sort',
|
|
14
|
+
query: '-created',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
title: 'sort.az',
|
|
18
|
+
value: 'title',
|
|
19
|
+
key: 'sort',
|
|
20
|
+
query: 'title',
|
|
21
|
+
},
|
|
22
|
+
];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { IChipsItem } from 'itube-specs/types';
|
|
2
|
+
|
|
3
|
+
export const sortPlaylists: Array<IChipsItem> = [
|
|
4
|
+
{
|
|
5
|
+
title: 'sort.trending',
|
|
6
|
+
value: 'trending',
|
|
7
|
+
key: 'sort',
|
|
8
|
+
query: '-views',
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
title: 'sort.most_videos',
|
|
12
|
+
value: 'most-videos',
|
|
13
|
+
key: 'sort',
|
|
14
|
+
query: '-videos_count',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
title: 'sort.last_updated',
|
|
18
|
+
value: 'updated',
|
|
19
|
+
key: 'sort',
|
|
20
|
+
query: '-updated',
|
|
21
|
+
},
|
|
22
|
+
];
|
package/package.json
CHANGED
|
@@ -14,6 +14,11 @@ export function normalizeUrl(to: { path: string; query: Record<string, any> }) {
|
|
|
14
14
|
query = rest
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
// Удаляем query без значений
|
|
18
|
+
query = Object.fromEntries(
|
|
19
|
+
Object.entries(query).filter(([_, v]) => v !== '' && v !== null && v !== undefined)
|
|
20
|
+
)
|
|
21
|
+
|
|
17
22
|
// Приводим query к нижнему регистру (ключи и строковые значения)
|
|
18
23
|
const loweredQuery: Record<string, any> = {}
|
|
19
24
|
for (const [key, value] of Object.entries(query)) {
|