Skip to content

Commit

Permalink
builded
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyhalight committed Sep 15, 2024
1 parent 26bc44a commit 3c44cd6
Show file tree
Hide file tree
Showing 257 changed files with 470 additions and 357 deletions.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 1.2.9

- Added support Watchporn.to embed
- Fix Watchporn.to getVideoId
- Fix Kick getVideoData for new format of videos and clips

# 1.2.8

- Fix Kick getVideoId for new format of videos and clips
Expand Down
2 changes: 1 addition & 1 deletion dist/config/sites.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export default [
},
{
host: VideoService.watchpornto,
url: "https://watchporn.to/video/",
url: "https://watchporn.to/",
match: /^watchporn.to$/,
},
{
Expand Down
4 changes: 2 additions & 2 deletions dist/helpers/kick.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { BaseHelper } from "./base.js";
import * as Kick from "../types/helpers/kick.js";
import { MinimalVideoData } from "../types/client.js";
export default class KickHelper extends BaseHelper {
API_ORIGIN: string;
getClipInfo(clipId: string): Promise<false | Kick.Response>;
getClipInfo(clipId: string): Promise<MinimalVideoData | undefined>;
getVideoInfo(videoId: string): Promise<MinimalVideoData | undefined>;
getVideoData(videoId: string): Promise<MinimalVideoData | undefined>;
getVideoId(url: URL): Promise<string | undefined>;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/helpers/kick.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 27 additions & 18 deletions dist/helpers/kick.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,45 @@
import sites from "../config/sites.js";
import { BaseHelper } from "./base.js";
import { VideoService } from "../types/yandex.js";
export default class KickHelper extends BaseHelper {
API_ORIGIN = "https://kick.com/api/v2";
API_ORIGIN = "https://kick.com/api";
async getClipInfo(clipId) {
try {
const res = await this.fetch(`${this.API_ORIGIN}/clips/${clipId}`);
return (await res.json());
const res = await this.fetch(`${this.API_ORIGIN}/v2/clips/${clipId}`);
const data = (await res.json());
const { clip_url: url, duration, title } = data.clip;
return {
url,
duration,
title,
};
}
catch (err) {
console.error(`Failed to get kick clip info by clipId: ${clipId}.`, err.message);
return false;
return undefined;
}
}
async getVideoData(videoId) {
if (!videoId.startsWith("clip_")) {
async getVideoInfo(videoId) {
try {
const res = await this.fetch(`${this.API_ORIGIN}/v1/video/${videoId}`);
const data = (await res.json());
const { source: url, livestream } = data;
const { session_title: title, duration } = livestream;
return {
url: sites.find((s) => s.host === VideoService.kick).url + videoId,
url,
duration: Math.round(duration / 1000),
title,
};
}
const clipInfo = await this.getClipInfo(videoId);
if (!clipInfo) {
catch (err) {
console.error(`Failed to get kick video info by videoId: ${videoId}.`, err.message);
return undefined;
}
const { clip_url, duration, title } = clipInfo.clip;
return {
url: clip_url,
duration,
title,
};
}
async getVideoData(videoId) {
return videoId.startsWith("videos")
? await this.getVideoInfo(videoId.replace("videos/", ""))
: await this.getClipInfo(videoId.replace("clips/", ""));
}
async getVideoId(url) {
return /([^/]+)\/(videos|clips)\/([^/]+)/.exec(url.pathname)?.[0];
return /([^/]+)\/((videos|clips)\/([^/]+))/.exec(url.pathname)?.[2];
}
}
89 changes: 86 additions & 3 deletions dist/types/helpers/kick.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ISODate } from "../utils.js";
export type Category = {
id: number;
banner: string;
Expand All @@ -21,7 +22,7 @@ export type ClipInfo = {
channel: Channel;
channel_id: number;
clip_url: string;
created_at: string;
created_at: ISODate;
creator: Channel;
duration: number;
id: string;
Expand All @@ -31,7 +32,7 @@ export type ClipInfo = {
likes_count: number;
livestream_id: string;
privacy: "CLIP_PRIVACY_PUBLIC";
started_at: string;
started_at: ISODate;
thumbnail_url: string;
title: string;
user_id: number;
Expand All @@ -40,7 +41,89 @@ export type ClipInfo = {
views: number;
vod: VOD;
};
export type Response = {
export type UserSocial = {
profilepic: string;
bio: string;
twitter: string;
facebook: string;
instagram: string;
youtube: string;
discord: string;
tiktok: string;
username: string;
};
export type UserVerified = {
id: number;
channel_id: number;
created_at: ISODate;
updated_at: ISODate;
};
export type StreamChannel = {
id: number;
user_id: number;
slug: string;
is_banned: boolean;
playback_url: string;
name_updated_at: string | null;
vod_enabled: boolean;
subscription_enabled: boolean;
followersCount: number;
user: UserSocial;
can_host: boolean;
verified: UserVerified | null;
};
export type StreamCategory = {
id: number;
name: string;
slug: string;
icon: string;
};
export type StreamFullCategory = {
id: number;
category_id: number;
name: string;
slug: string;
tags: string[];
description: string;
deleted_at: null;
viewers: number;
category: StreamCategory;
};
export type LiveStream = {
id: number;
slug: string;
channel_id: number;
created_at: string;
session_title: string;
is_live: boolean;
risk_level_id: null;
start_time: string;
source: null;
twitch_channel: null;
duration: number;
language: string;
is_mature: boolean;
viewer_count: number;
thumbnail: string;
channel: StreamChannel;
categories: StreamFullCategory[];
};
export type ClipResponse = {
clip: ClipInfo;
};
export type VideoResponse = {
id: number;
live_stream_id: number;
slug: null;
thumb: null;
s3: null;
trading_platform_id: null;
created_at: ISODate;
updated_at: ISODate;
uuid: string;
views: number;
deleted_at: null;
source: string;
livestream: LiveStream;
};
//# sourceMappingURL=kick.d.ts.map
2 changes: 1 addition & 1 deletion dist/types/helpers/kick.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/utils/videoData.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export async function getVideoID(service, videoURL) {
case VideoService.archive:
return /(details|embed)\/([^/]+)/.exec(url.pathname)?.[2];
case VideoService.watchpornto:
return /\/video\/((\d+)\/([^/]+))/.exec(url.pathname)?.[1];
return /\/(video|embed)\/(\d+)(\/[^/]+\/)?/.exec(url.pathname)?.[0];
default:
return undefined;
}
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/navigation.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/assets/search.js

Large diffs are not rendered by default.

Loading

0 comments on commit 3c44cd6

Please sign in to comment.