itube-specs 0.0.690 → 0.0.691

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.
@@ -1,7 +1,8 @@
1
1
  <template>
2
2
  <img
3
3
  v-bind="$attrs"
4
- :src="src"
4
+ :src="imgSrc"
5
+ :srcset="srcset"
5
6
  :loading="loading"
6
7
  :width="width"
7
8
  :height="height"
@@ -14,11 +15,15 @@
14
15
  </template>
15
16
 
16
17
  <script setup lang="ts">
18
+ import type { IThumbUrls } from '~/types/thumbs-urls';
19
+ import { ThumbSize } from '~/runtime/enums/thumb-size';
20
+
17
21
  const props = withDefaults(defineProps<{
18
- src: string | Blob,
22
+ src?: string,
19
23
  width: string | number,
20
24
  height: string | number,
21
25
  sizes: string,
26
+ urls?: IThumbUrls,
22
27
  alt?: string,
23
28
  loading?: 'lazy' | 'eager',
24
29
  fit?: 'cover' | 'contain' | 'fill' | 'inside' | 'outside',
@@ -28,6 +33,21 @@ const props = withDefaults(defineProps<{
28
33
  fit: 'cover',
29
34
  })
30
35
 
36
+ const imgSrc = computed(() => {
37
+ if (props.src) return props.src
38
+ if (props.urls) return props.urls.webp[ThumbSize.Medium]
39
+ return undefined
40
+ })
41
+
42
+ const srcset = computed(() => {
43
+ if (!props.urls) return undefined
44
+ const entries = Object.entries(props.urls.webp)
45
+ if (!entries.length) return undefined
46
+ return entries
47
+ .map(([size, url]) => `${url} ${size.split('x')[0]}w`)
48
+ .join(', ')
49
+ })
50
+
31
51
  const emit = defineEmits<{
32
52
  (e: 'error', event: Event): void
33
53
  }>()
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "itube-specs",
3
3
  "type": "module",
4
- "version": "0.0.690",
4
+ "version": "0.0.691",
5
5
  "main": "./nuxt.config.ts",
6
6
  "types": "./types/index.d.ts",
7
7
  "scripts": {
@@ -14,8 +14,12 @@ export const cleanVideoCard = (card: IRawVideoCard): IVideoCard => ({
14
14
  channelName: card.channel?.name || '',
15
15
  url: card.url || '',
16
16
  previewUrl: card.preview_url || '',
17
- thumbUrl: card.thumb_urls?.webp?.[ThumbSize.Medium] || '',
18
- thumbUrls: card.thumb_urls || {},
17
+ thumbUrls: card.thumb_urls ? {
18
+ webp: {
19
+ [ThumbSize.Small]: card.thumb_urls.webp?.[ThumbSize.Small] || '',
20
+ [ThumbSize.Medium]: card.thumb_urls.webp?.[ThumbSize.Medium] || '',
21
+ },
22
+ } : undefined,
19
23
  md5: card.md5 || '',
20
24
  thumbNum: card.thumb_number || 0,
21
25
  models: card.models?.map(item => item.title) || [],
@@ -1,5 +1,4 @@
1
1
  import type { IRawVideoData, IVideoData } from '../../../types';
2
- import { ThumbSize } from '../../enums/thumb-size';
3
2
 
4
3
  export const cleanVideoData = (data: IRawVideoData): IVideoData => ({
5
4
  guid: data.guid || '',
@@ -19,7 +18,9 @@ export const cleanVideoData = (data: IRawVideoData): IVideoData => ({
19
18
  channelAvatar: data.channel?.avatar_url || '',
20
19
  url: data.url || '',
21
20
  previewUrl: data.preview_url || '',
22
- thumbUrl: data.thumb_urls?.webp?.[ThumbSize.Big] || '',
21
+ thumbUrls: data.thumb_urls ? {
22
+ webp: data.thumb_urls.webp,
23
+ } : undefined,
23
24
  vttUrl: data.vtt_url || '',
24
25
  vttSpriteUrl: data.vtt_sprite_url || '',
25
26
  created: data.created || 0,
package/types/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './video-data.d.ts';
2
2
  export * from './video-card.d.ts';
3
3
  export * from './thumbs-urls.d.ts';
4
+ export * from './raw/raw-thumbs-urls.d.ts';
4
5
  export * from './raw/raw-category-info.d.ts';
5
6
  export * from './raw/raw-category-card.d.ts';
6
7
  export * from './raw/raw-channel-card.d.ts';
@@ -1,4 +1,4 @@
1
- import type { IThumbUrls } from '../thumbs-urls';
1
+ import type { IRawThumbUrls } from './raw-thumbs-urls';
2
2
 
3
3
  export interface IRawCategoryCard {
4
4
  guid: string; // unused
@@ -19,7 +19,7 @@ export interface IRawCategoryCard {
19
19
  thumb_number: number; // unused
20
20
  description: string;
21
21
  header: string; // unused
22
- video_thumb_urls: IThumbUrls; // ✅ used (для card.videoThumbUrls.webp['480X270'])
22
+ video_thumb_urls: IRawThumbUrls; // ✅ used (для card.videoThumbUrls.webp['480X270'])
23
23
  files?: Record<string, string>;
24
24
  icon?: string;
25
25
  }
@@ -1,4 +1,4 @@
1
- import type { IThumbUrls } from '../thumbs-urls';
1
+ import type { IRawThumbUrls } from './raw-thumbs-urls';
2
2
  import type { IRawCategoryCard } from './raw-category-card';
3
3
 
4
4
  export interface IRawCategoryInfo {
@@ -21,6 +21,6 @@ export interface IRawCategoryInfo {
21
21
  description: string;
22
22
  header: string;
23
23
  fullDescription: string;
24
- video_thumb_urls: IThumbUrls;
24
+ video_thumb_urls: IRawThumbUrls;
25
25
  related: IRawCategoryCard[]
26
26
  }
@@ -1,4 +1,4 @@
1
- import type { IThumbUrls } from '../thumbs-urls';
1
+ import type { IRawThumbUrls } from './raw-thumbs-urls';
2
2
 
3
3
  export interface IRawChannelCard {
4
4
  guid: string;
@@ -25,5 +25,5 @@ export interface IRawChannelCard {
25
25
  avatar_url: string;
26
26
  mobile_banner_image_url: string; // unused
27
27
  desktop_banner_image_url: string; // unused
28
- video_thumb_urls: IThumbUrls;
28
+ video_thumb_urls: IRawThumbUrls;
29
29
  }
@@ -1,4 +1,4 @@
1
- import type { IThumbUrls } from '../thumbs-urls';
1
+ import type { IRawThumbUrls } from './raw-thumbs-urls';
2
2
 
3
3
  export interface IRawChannelInfo {
4
4
  guid: string;
@@ -25,5 +25,5 @@ export interface IRawChannelInfo {
25
25
  avatar_url: string;
26
26
  mobile_banner_image_url: string; // unused
27
27
  desktop_banner_image_url: string; // unused
28
- video_thumb_urls: IThumbUrls;
28
+ video_thumb_urls: IRawThumbUrls;
29
29
  }
@@ -1,4 +1,4 @@
1
- import type { IThumbUrls } from '../thumbs-urls';
1
+ import type { IRawThumbUrls } from './raw-thumbs-urls';
2
2
  import type { IModelParameter } from '~/types';
3
3
 
4
4
  export interface IRawModelCard {
@@ -26,7 +26,7 @@ export interface IRawModelCard {
26
26
  video_guid: string;
27
27
  video_md5: string;
28
28
 
29
- video_thumb_urls: IThumbUrls;
29
+ video_thumb_urls: IRawThumbUrls;
30
30
 
31
31
  videos_count: number;
32
32
  views: number;
@@ -1,4 +1,4 @@
1
- import type { IThumbUrls } from '../thumbs-urls';
1
+ import type { IRawThumbUrls } from './raw-thumbs-urls';
2
2
  import type { IParameterModel } from '~/types';
3
3
 
4
4
  export interface IRawModelInfo {
@@ -31,7 +31,7 @@ export interface IRawModelInfo {
31
31
  primary_image_md5: string;
32
32
  rank: number;
33
33
  number_of_videos_in_recent_days: number;
34
- video_thumb_urls: IThumbUrls;
34
+ video_thumb_urls: IRawThumbUrls;
35
35
  parameters: IParameterModel[];
36
36
  relatedNames: string[];
37
37
  }
@@ -1,4 +1,4 @@
1
- import type { IThumbUrls } from '../thumbs-urls';
1
+ import type { IRawThumbUrls } from './raw-thumbs-urls';
2
2
  import type { EPlaylistType } from '../../runtime';
3
3
 
4
4
  export interface IRawPlaylistCard {
@@ -15,7 +15,7 @@ export interface IRawPlaylistCard {
15
15
  thumbs: {
16
16
  video_md5: string; // unused
17
17
  thumb_num: number; // unused
18
- urls: IThumbUrls;
18
+ urls: IRawThumbUrls;
19
19
  }[];
20
20
  videos_count: number;
21
21
  first_video_id: string;
@@ -1,10 +1,10 @@
1
- import type { IThumbUrls } from '../thumbs-urls';
1
+ import type { IRawThumbUrls } from './raw-thumbs-urls';
2
2
  import type { EPlaylistType } from '../../runtime';
3
3
 
4
4
  export interface IPlaylistThumb {
5
5
  video_md5: string;
6
6
  thumb_num: number;
7
- urls: IThumbUrls;
7
+ urls: IRawThumbUrls;
8
8
  }
9
9
 
10
10
  export interface IRawPlaylistData {
@@ -1,4 +1,4 @@
1
- import type { IThumbUrls } from '~/types';
1
+ import type { IRawThumbUrls } from './raw-thumbs-urls';
2
2
 
3
3
  export interface IRawPlaylistVideo {
4
4
  actions: IAction[];
@@ -36,7 +36,7 @@ export interface IRawPlaylistVideo {
36
36
  referer_phrases: string[];
37
37
  tags: string[];
38
38
  thumb_number: number;
39
- thumb_urls: IThumbUrls;
39
+ thumb_urls: IRawThumbUrls;
40
40
  title: string;
41
41
  uploader: IUploader;
42
42
  url: string;
@@ -95,7 +95,7 @@ export interface IChannel {
95
95
  url: string;
96
96
  video_guid: string;
97
97
  video_md5: string;
98
- video_thumb_urls: IThumbUrls;
98
+ video_thumb_urls: IRawThumbUrls;
99
99
  videos_count: number;
100
100
  }
101
101
 
@@ -0,0 +1,7 @@
1
+ import type { ThumbSize } from '../../runtime/enums/thumb-size';
2
+
3
+ /** Raw тумбы из API */
4
+ export interface IRawThumbUrls {
5
+ jpeg: Record<ThumbSize, string>;
6
+ webp: Record<ThumbSize, string>;
7
+ }
@@ -1,4 +1,4 @@
1
- import type { IThumbUrls } from '../thumbs-urls';
1
+ import type { IRawThumbUrls } from './raw-thumbs-urls';
2
2
  import type { ICategoryCard } from '../category-short';
3
3
 
4
4
  interface IVideoAction {
@@ -30,7 +30,7 @@ interface IChannelVideo {
30
30
  url: string;
31
31
  video_guid: string;
32
32
  video_md5: string;
33
- video_thumb_urls: IThumbUrls;
33
+ video_thumb_urls: IRawThumbUrls;
34
34
  videos_count: number;
35
35
  }
36
36
 
@@ -74,7 +74,7 @@ export interface IRawVideoCard {
74
74
  cdn_video_domain: string; // unused
75
75
  preview_url: string;
76
76
  video_url: string; // unused
77
- thumb_urls: IThumbUrls;
77
+ thumb_urls: IRawThumbUrls;
78
78
  reels_url: string; // unused
79
79
  vtt_url: string; // unused
80
80
  vtt_sprite_url: string; // unused
@@ -1,4 +1,4 @@
1
- import type { IThumbUrls } from '../thumbs-urls';
1
+ import type { IRawThumbUrls } from './raw-thumbs-urls';
2
2
 
3
3
  export interface IRawVideoData {
4
4
  guid: string;
@@ -47,7 +47,7 @@ export interface IRawVideoData {
47
47
  cdn_video_domain: string; // unused
48
48
  preview_url: string;
49
49
  video_url: string; // unused
50
- thumb_urls: IThumbUrls;
50
+ thumb_urls: IRawThumbUrls;
51
51
  reels_url: string; // unused
52
52
  vtt_url: string;
53
53
  vtt_sprite_url: string;
@@ -1,7 +1,6 @@
1
1
  import type { ThumbSize } from '../runtime/enums/thumb-size';
2
2
 
3
- /** Интерфейс для работы с тумбами */
3
+ /** Очищенные тумбы только webp */
4
4
  export interface IThumbUrls {
5
- jpeg: Record<ThumbSize, string>;
6
- webp: Record<ThumbSize, string>;
5
+ webp: Partial<Record<ThumbSize, string>>;
7
6
  }
@@ -13,7 +13,6 @@ export interface IVideoCard {
13
13
  channelName?: string;
14
14
  url?: string;
15
15
  previewUrl?: string;
16
- thumbUrl: string;
17
16
  playlistId?: string;
18
17
  md5?: string;
19
18
  thumbNum?: number;
@@ -1,3 +1,5 @@
1
+ import type { IThumbUrls } from '~/types/thumbs-urls';
2
+
1
3
  export interface ITimestamp {
2
4
  duration: number;
3
5
  title: string;
@@ -28,7 +30,7 @@ export interface IVideoData {
28
30
  channelAvatar: string;
29
31
  url: string;
30
32
  previewUrl: string;
31
- thumbUrl: string;
33
+ thumbUrls?: IThumbUrls;
32
34
  vttUrl: string;
33
35
  vttSpriteUrl: string;
34
36
  created: number;