UNPKG

social-link-parser

Version:

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

57 lines 1.98 kB
import { Platforms } from '../../core/types.js'; import { normalize } from '../../utils/url.js'; import { createDomainPattern } from '../../utils/url.js'; import { QUERY_HASH } from '../../utils/constants.js'; const domains = ['bitchute.com']; const subdomains = []; const DOMAIN_PATTERN = createDomainPattern(domains, subdomains); const channelSlug = /^[A-Za-z0-9_-]{3,40}$/; export const bitchute = { id: Platforms.BitChute, name: 'BitChute', color: '#D90207', domains: domains, subdomains: subdomains, patterns: { profile: new RegExp(`^https?://${DOMAIN_PATTERN}/channel/([A-Za-z0-9_-]{3,40})/?${QUERY_HASH}$`, 'i'), handle: channelSlug, content: { video: new RegExp(`^https?://${DOMAIN_PATTERN}/(?:video|embed)/([A-Za-z0-9]+)/?${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 v = this.patterns.content?.video?.exec(url); if (v) { result.ids.videoId = v[1]; result.metadata.isVideo = true; result.metadata.contentType = 'video'; return; } const c = this.patterns.profile.exec(url); if (c) { result.username = c[1]; result.metadata.isProfile = true; result.metadata.contentType = 'profile'; } }, validateHandle(handle) { return channelSlug.test(handle); }, buildProfileUrl(username) { return `https://www.bitchute.com/channel/${username}`; }, buildContentUrl(type, id) { if (type === 'video') return `https://www.bitchute.com/video/${id}`; return `https://www.bitchute.com/${id}`; }, normalizeUrl(url) { return normalize(url); }, }; //# sourceMappingURL=index.js.map