UNPKG

social-link-parser

Version:

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

60 lines 2.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.bitchute = 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 = ['bitchute.com']; const subdomains = []; const DOMAIN_PATTERN = (0, url_2.createDomainPattern)(domains, subdomains); const channelSlug = /^[A-Za-z0-9_-]{3,40}$/; exports.bitchute = { id: types_1.Platforms.BitChute, name: 'BitChute', color: '#D90207', domains: domains, subdomains: subdomains, patterns: { profile: new RegExp(`^https?://${DOMAIN_PATTERN}/channel/([A-Za-z0-9_-]{3,40})/?${constants_1.QUERY_HASH}$`, 'i'), handle: channelSlug, content: { video: new RegExp(`^https?://${DOMAIN_PATTERN}/(?:video|embed)/([A-Za-z0-9]+)/?${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 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 (0, url_1.normalize)(url); }, }; //# sourceMappingURL=index.js.map