"use-strict"; const { objSerialize, fromConstToPascal } = require("./util.js") /** * @public * @readonly */ const BMetadataType = { "AUDIO": 0b1, "VIDEO": 0b10, "ORIGINAL": 0b100, "ALT": 0b1000, "OFFICIAL": 0b10000, "EXPLICIT": 0b100000, "PREFERED": 0b1000000, "PSEUDONYM": 0b10000000, "UNAVAILABLE": 0b100000000, "PREMIUM": 0b1000000000 } /** * @public * @constructor * @params {string|undefined} title * @params {string|undefined} artist * @params {URL|string|undefined} [href] href * @params {string} [extra] extra Playback effects. i.e: Pitch, speed * @returns {RadioMetadata} */ const RadioMetadata = function (title, artist, href, extra) { this.info = undefined this.title = title || undefined this.artist = artist || undefined this.href = href || undefined this.extra = extra || undefined return this } /** * @public * @params {string|undefined} title * @params {string|undefined} artist * @params {URL|string|undefined} [href] href * @params {string} [extra] extra Playback effects. i.e: Pitch, speed * @returns {RadioMetadata} */ RadioMetadata.new = (title, artist, href, extra) => new RadioMetadata(title, artist, href, extra) /** * Alias for new(...).bVideo().bAudio() * @public * @params {string|undefined} title * @params {string|undefined} artist * @params {URL|string|undefined} [href] href * @params {string} [extra] extra Playback effects. i.e: Pitch, speed * @returns {RadioMetadata} */ RadioMetadata.newLAV = (title, artist, href, extra) => (new RadioMetadata(title, artist, href, extra)).bVideo().bAudio() /** * Alias for new(...).bVideo() * @public * @params {string|undefined} title * @params {string|undefined} artist * @params {URL|string|undefined} [href] href * @params {string} [extra] extra Playback effects. i.e: Pitch, speed * @returns {RadioMetadata} */ RadioMetadata.newLV = (title, artist, href, extra) => (new RadioMetadata(title, artist, href, extra)).bVideo() /** * Alias for new(...).bAudio() * @public * @params {string|undefined} title * @params {string|undefined} artist * @params {URL|string|undefined} [href] href * @params {string} [extra] extra Playback effects. i.e: Pitch, speed * @returns {RadioMetadata} */ RadioMetadata.newLA = (title, artist, href, extra) => (new RadioMetadata(title, artist, href, extra)).bAudio() /** * @public * @params {string} watch_id * @returns {RadioMetadata} */ RadioMetadata.createYouTubeURI = id => `x-yt://${id}` /** * @public * @params {string} id * @returns {RadioMetadata} */ RadioMetadata.createNicoNicoURI = id => `x-nn://${id}` /** * @public * @params {string} id * @returns {RadioMetadata} */ RadioMetadata.createInternetArchiveURI = id => `x-ia://${id}` /** * @public * @params {bigint|string} post_id * @params {string} username * @returns {RadioMetadata} */ RadioMetadata.createTikTokURI = (post_id, username) => `x-tt://${username}/${post_id}` /** * @public * @params {string} track * @params {string} artist * @returns {RadioMetadata} */ RadioMetadata.createBandcampURI = (track, artist) => `x-bc://${artist}/${track}` /** * @public * @params {string} track * @params {string} artist * @returns {RadioMetadata} */ RadioMetadata.createSoundcloudURI = (track, artist) => `x-sc://${artist}/${track}` /** * @public * @params {number} post_id * @returns {RadioMetadata} */ RadioMetadata.createBooruSoyURI = id => `x-bs://${id}` /** * @public * @params {number} track_id * @params {number|undefined} album_id * @returns {RadioMetadata} */ RadioMetadata.createAppleMusicURI = (track_id, album_id) => `x-am://${track_id}${album_id ? '/' + album_id : ''}` /** * @public * @params {number} match_id * @returns {RadioMetadata} */ RadioMetadata.createShazamURI = match_id => `x-sz://${match_id}` /** * @public * @params {string} id * @returns {RadioMetadata} */ RadioMetadata.createWikipediaURI = id => `x-wp://${id}` /** * @public * @params {number} string * @returns {RadioMetadata} */ RadioMetadata.createWikimediaCommonsURI = id => `x-wc://${id}` /** * Used to differentiate identical info bits for different info items * @public * @params {string} key * @returns {RadioMetadata} */ RadioMetadata.prototype.setFor = function (key) { this.for = key return this } /** * @deprecated * @params {RadioSource} radioSource * @returns {Object} */ RadioMetadata.prototype.serialize = function () { return objSerialize(this, [ "info", "for", "title", "artist", "href", "extra" ]) } for (const key in BMetadataType) { RadioMetadata.prototype[`b${fromConstToPascal(key)}`] = function () { //this.info = (this.info || 0) | BMetadataType[key] this.info |= BMetadataType[key] return this } } module.exports = { RadioMetadata, BMetadataType }