social-link-parser
Version:
Extract usernames, IDs, and metadata from social media URLs across 100+ platforms
54 lines • 1.89 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.rumble = 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 = ['rumble.com'];
const subdomains = [];
const DOMAIN_PATTERN = (0, url_2.createDomainPattern)(domains, subdomains);
exports.rumble = {
id: types_1.Platforms.Rumble,
name: 'Rumble',
color: '#60d669',
domains: domains,
subdomains: subdomains,
patterns: {
profile: new RegExp(`^https?://${DOMAIN_PATTERN}/(?:c(?:/)?|user/)?([A-Za-z0-9_-]{3,30})/?${constants_1.QUERY_HASH}$`, 'i'),
handle: /^[A-Za-z0-9_-]{3,30}$/,
content: {
video: new RegExp(`^https?://${DOMAIN_PATTERN}/([a-z0-9]{6,})-[a-z0-9-]+\\.html${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, res) {
const vid = this.patterns.content?.video?.exec(url);
if (vid) {
res.ids.videoId = vid[1];
res.metadata.isVideo = true;
res.metadata.contentType = 'video';
return;
}
const prof = this.patterns.profile.exec(url);
if (prof) {
res.username = prof[1];
res.metadata.isProfile = true;
res.metadata.contentType = 'profile';
}
},
validateHandle(handle) {
return this.patterns.handle.test(handle);
},
buildProfileUrl(handle) {
return `https://rumble.com/c/${handle}`;
},
normalizeUrl(url) {
return (0, url_1.normalize)(url);
},
};
//# sourceMappingURL=index.js.map