UNPKG

social-link-parser

Version:

Extract usernames, IDs, and metadata from social media URLs across 100+ platforms

61 lines 2.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.kick = void 0; const types_1 = require("../../core/types"); const url_1 = require("../../utils/url"); const url_2 = require("../../utils/url"); const constants_1 = require("../../utils/constants"); const domains = ['kick.com']; const subdomains = []; const DOMAIN_PATTERN = (0, url_2.createDomainPattern)(domains, subdomains); const usernamePattern = /^[A-Za-z0-9_]{3,25}$/; exports.kick = { id: types_1.Platforms.Kick, name: 'Kick', color: '#52FF00', domains: domains, subdomains: subdomains, patterns: { profile: new RegExp(`^https?://${DOMAIN_PATTERN}/([A-Za-z0-9_]{3,25})/?${constants_1.QUERY_HASH}$`, 'i'), handle: usernamePattern, content: { video: new RegExp(`^https?://${DOMAIN_PATTERN}/video/(\\d{5,})/?${constants_1.QUERY_HASH}$`, 'i'), }, }, detect(url) { if (!this.domains.some(domain => url.includes(domain))) return false; return this.patterns.profile.test(url) || !!(this.patterns.content?.video?.test(url)); }, extract(url, result) { const vid = this.patterns.content?.video?.exec(url); if (vid) { result.ids.videoId = vid[1]; result.metadata.isVideo = true; result.metadata.contentType = 'video'; return; } const prof = this.patterns.profile.exec(url); if (prof) { result.username = prof[1]; result.metadata.isProfile = true; result.metadata.contentType = 'profile'; return; } }, validateHandle(handle) { return usernamePattern.test(handle); }, buildProfileUrl(username) { return `https://kick.com/${username}`; }, buildContentUrl(type, id) { if (type === 'video') return `https://kick.com/video/${id}`; return `https://kick.com/${id}`; }, normalizeUrl(url) { return (0, url_1.normalize)(url); }, }; //# sourceMappingURL=index.js.map