import { ApeTagItem } from "./apeTagItem"; import { ByteVector } from "../byteVector"; import { File } from "../file"; import { IPicture } from "../picture"; import { Tag, TagTypes } from "../tag"; /** * Provides a representation of an APEv2 tag which can be read from and written to disk. */ export default class ApeTag extends Tag { /** * Names of picture fields, indexed to correspond to their picture item names. * @private */ private static readonly PICTURE_ITEM_NAMES; private static readonly NOT_PICTURE_ITEM_TYPE_ID; private _footer; private _items; private constructor(); /** * Constructs and initializes a new instance by reading the contents of a raw tag in a * specified {@link ByteVector} object. * @param data Object containing the raw tag */ static fromData(data: ByteVector): ApeTag; /** * Constructs an empty APEv2 tag. */ static fromEmpty(): ApeTag; /** * Constructs a new instance by reading the contents from a specified position in a specified * file. * @param file File to read the tag from * @param position Position where the tag header or footer begins * @remarks * If `position` points to the beginning of the tag footer, the footer will be read * and then the parser will back up and start reading from the beginning of the file. */ static fromFile(file: File, position: number): ApeTag; /** * Gets whether the current instance has a header when rendered. */ get isHeaderPresent(): boolean; /** * Sets whether the current instance has a header when rendered. */ set isHeaderPresent(value: boolean); /** * Gets all items stored in the current instance */ get items(): ApeTagItem[]; /** @inheritDoc */ get tagTypes(): TagTypes; /** @inheritDoc */ get sizeOnDisk(): number; /** * @inheritDoc * @remarks Stored in the `Title` item */ get title(): string; /** * @inheritDoc * @remarks Stored in the `Title` item */ set title(value: string); /** * @inheritDoc * @remarks Stored in the `TitleSort` item */ get titleSort(): string; /** * @inheritDoc * @remarks Stored in the `TitleSort` item */ set titleSort(value: string); /** * @inheritDoc * @remarks Stored in the `Subtitle` item */ get subtitle(): string; /** * @inheritDoc * @remarks Stored in the `Subtitle` */ set subtitle(value: string); /** * @inheritDoc * @remarks Stored in the `Description` item */ get description(): string; /** * @inheritDoc * @remarks Stored in the `Description` item */ set description(value: string); /** * @inheritDoc * @remarks Stored in the `Artist` item */ get performers(): string[]; /** * @inheritDoc * @remarks Stored in the `Artist` item */ set performers(value: string[]); /** * @inheritDoc * @remarks Stored in the `ArtistSort` item */ get performersSort(): string[]; /** * @inheritDoc * @remarks Stored in the `ArtistSort` item */ set performersSort(value: string[]); /** * @inheritDoc * @remarks Stored in the `PerformersRole` item */ get performersRole(): string[]; /** * @inheritDoc * @remarks Stored in the `PerformersRole` item */ set performersRole(value: string[]); /** * @inheritDoc * @remarks * This property is implemented using the "Album Artist" item and "AlbumArtist" as a backup if * it exists. */ get albumArtists(): string[]; /** * @inheritDoc * @remarks * Will be stored in "Album Artist" primarily. If "AlbumArtist" exists, value will also be * stored there for compatibility. */ set albumArtists(value: string[]); /** * @inheritDoc * @remarks Stored in the `AlbumArtistSort` item */ get albumArtistsSort(): string[]; /** * @inheritDoc * @remarks Stored in the `AlbumArtistSort` item */ set albumArtistsSort(value: string[]); /** * @inheritDoc * @remarks Stored in the `Composer` item */ get composers(): string[]; /** * @inheritDoc * @remarks Stored in the `Composer` item */ set composers(value: string[]); /** * @inheritDoc * @remarks Stored in the `ComposerSort` item */ get composersSort(): string[]; /** * @inheritDoc * @remarks via ComposerSort */ set composersSort(value: string[]); /** * @inheritDoc * @remarks Stored in the `Album` item */ get album(): string; /** * @inheritDoc * @remarks Stored in the `Album` item */ set album(value: string); /** * @inheritDoc * @remarks Stored in the `AlbumSort` item */ get albumSort(): string; /** * @inheritDoc * @remarks Stored in the `AlbumSort` item */ set albumSort(value: string); /** * @inheritDoc * @remarks Stored in the `Comment` item */ get comment(): string; /** * @inheritDoc * @remarks Stored in the `Comment` item */ set comment(value: string); /** * @inheritDoc * @remarks Stored in the `Genre` item */ get genres(): string[]; /** * @inheritDoc * @remarks Stored in the `Genre` item */ set genres(value: string[]); /** * @inheritDoc * @remarks Stored in the `Year` item */ get year(): number; /** * @inheritDoc * @remarks Stored in the `Year` item */ set year(value: number); /** * @inheritDoc * @remarks Stored in the `Track` item numerator */ get track(): number; /** * @inheritDoc * @remarks Stored in the `Track` item numerator */ set track(value: number); /** * @inheritDoc * @remarks Stored in the `Track` item denominator */ get trackCount(): number; /** * @inheritDoc * @remarks Stored in the `Track` item denominator */ set trackCount(value: number); /** * @inheritDoc * @remarks Stored in the `Disc` item numerator */ get disc(): number; /** * @inheritDoc * @remarks Stored in the `Disc` item numerator */ set disc(value: number); /** * @inheritDoc * @remarks Stored in the `Disc` item denominator */ get discCount(): number; /** * @inheritDoc * @remarks Stored in the `Disc` item denominator */ set discCount(value: number); /** * @inheritDoc * @remarks Stored in the `Lyrics` item */ get lyrics(): string; /** * @inheritDoc * @remarks Stored in the `Lyrics` item */ set lyrics(value: string); /** * @inheritDoc * @remarks Stored in the `Grouping` item */ get grouping(): string; /** * @inheritDoc * @remarks Stored in the `Grouping` item */ set grouping(value: string); /** * @inheritDoc * @remarks Stored in the `BPM` item */ get beatsPerMinute(): number; /** * @inheritDoc * @remarks Stored in the `BPM` item */ set beatsPerMinute(value: number); /** * @inheritDoc * @remarks Stored in the `Conductor` item */ get conductor(): string; /** * @inheritDoc * @remarks Stored in the `Conductor` item */ set conductor(value: string); /** * @inheritDoc * @remarks Stored in the `Copyright` item */ get copyright(): string; /** * @inheritDoc * @remarks Stored in the `Copyright` item */ set copyright(value: string); /** * @inheritDoc * @remarks Stored in the `DateTagged` item */ get dateTagged(): Date | undefined; /** * @inheritDoc * @remarks Stored in the `DateTagged` item */ set dateTagged(value: Date | undefined); /** * @inheritDoc * @remarks Stored in the `MUSICBRAINZ_ARTISTID` item */ get musicBrainzArtistId(): string; /** * @inheritDoc * @remarks Stored in the `MUSICBRAINZ_ARTISTID` item */ set musicBrainzArtistId(value: string); /** * @inheritDoc * @remarks Stored in the `MUSICBRAINZ_RELEASEGROUPID` item */ get musicBrainzReleaseGroupId(): string; /** * @inheritDoc * @remarks Stored in the `MUSICBRAINZ_RELEASEGROUPID` item */ set musicBrainzReleaseGroupId(value: string); /** * @inheritDoc * @remarks Stored in the `MUSICBRAINZ_ALBUMID` item */ get musicBrainzReleaseId(): string; /** * @inheritDoc * @remarks Stored in the `MUSICBRAINZ_ALBUMID` item */ set musicBrainzReleaseId(value: string); /** * @inheritDoc * @remarks Stored in the `MUSICBRAINZ_ALBUMARTISTID` item */ get musicBrainzReleaseArtistId(): string; /** * @inheritDoc * @remarks Stored in the `MUSICBRAINZ_ALBUMARTISTID` item */ set musicBrainzReleaseArtistId(value: string); /** * @inheritDoc * @remarks Stored in the `MUSICBRAINZ_TRACKID` item */ get musicBrainzTrackId(): string; /** * @inheritDoc * @remarks Stored in the `MUSICBRAINZ_TRACKID` item */ set musicBrainzTrackId(value: string); /** * @inheritDoc * @remarks Stored in the `MUSICBRAINZ_DISCID` item */ get musicBrainzDiscId(): string; /** * @inheritDoc * @remarks Stored in the `MUSICBRAINZ_DISCID` item */ set musicBrainzDiscId(value: string); /** * @inheritDoc * @remarks Stored in the `MUSICIP_PUID` item */ get musicIpId(): string; /** * @inheritDoc * @remarks Stored in the `MUSICIP_PUID` item */ set musicIpId(value: string); /** * @inheritDoc * @remarks Stored in the `ASIN` item */ get amazonId(): string; /** * @inheritDoc * @remarks Stored in the `ASIN` item */ set amazonId(value: string); /** * @inheritDoc * @remarks Stored in the `MUSICBRAINZ_ALBUMSTATUS` item */ get musicBrainzReleaseStatus(): string; /** * @inheritDoc * @remarks Stored in the `MUSICBRAINZ_ALBUMSTATUS` item */ set musicBrainzReleaseStatus(value: string); /** * @inheritDoc * @remarks Stored in the `MUSICBRAINZ_ALBUMTYPE` item */ get musicBrainzReleaseType(): string; /** * @inheritDoc * @remarks Stored in the `MUSICBRAINZ_ALBUMTYPE` item */ set musicBrainzReleaseType(value: string); /** * @inheritDoc * @remarks Stored in the `RELEASECOUNTRY` item */ get musicBrainzReleaseCountry(): string; /** * @inheritDoc * @remarks Stored in the `RELEASECOUNTRY` item */ set musicBrainzReleaseCountry(value: string); /** * @inheritDoc * @remarks Stored in the `REPLAYGAIN_TRACK_GAIN` item */ get replayGainTrackGain(): number; /** * @inheritDoc * @remarks Stored in the `REPLAYGAIN_TRACK_GAIN` item */ set replayGainTrackGain(value: number); /** * @inheritDoc * @remarks Stored in the `REPLAYGAIN_TRACK_PEAK` item */ get replayGainTrackPeak(): number; /** * @inheritDoc * @remarks Stored in the `REPLAYGAIN_TRACK_PEAK` item */ set replayGainTrackPeak(value: number); /** * @inheritDoc * @remarks Stored in the `REPLAYGAIN_ALBUM_GAIN` item */ get replayGainAlbumGain(): number; /** * @inheritDoc * @remarks Stored in the `REPLAYGAIN_ALBUM_GAIN` item */ set replayGainAlbumGain(value: number); /** * @inheritDoc * @remarks Stored in the `REPLAYGAIN_ALBUM_PEAK` item */ get replayGainAlbumPeak(): number; /** * @inheritDoc * @remarks Stored in the `REPLAYGAIN_ALBUM_PEAK` item */ set replayGainAlbumPeak(value: number); /** * @inheritDoc * @remarks Stored in `Cover Art *` or `Embedded Object` items */ get pictures(): IPicture[]; /** * @inheritDoc * @remarks Stored in `Cover Art *` or `Embedded Object` items */ set pictures(value: IPicture[]); /** @inheritDoc */ get isEmpty(): boolean; /** * Adds a single value to the contents of an item. Creates a new item if one does not exist. * @param key Key to use to lookup to item to add `value` to * @param value Values to add to item identified by `key` */ appendStringValue(key: string, value: string): void; /** * Adds a lists of strings to the values stored in a specified item. Creates a new item if one * does not already exist. * @param key Key to use to look up the item * @param values Values to add to the item */ appendStringValues(key: string, values: string[]): void; /** @inheritDoc */ clear(): void; copyTo(target: Tag, overwrite: boolean): void; /** * Gets an item from the current instance identified by `key`. * @param key Identifier for the item to get * @returns * ApeTagItem Item specified by `key` if it exists, undefined is * returned otherwise */ getItem(key: string): ApeTagItem; /** * Determines if any items with the specified `key` exist in the current instance. * @param key Identifier for looking up a matching item * @returns `true` if an item with the specified key exists, `false` otherwise */ hasItem(key: string): boolean; /** * Removes all items from the current instance with the specified `key`. * @param key Identifier of the items to remove. */ removeItem(key: string): void; /** * Renders the current instance as a raw APEv2 tag. * @returns Bytes that represent the current instance */ render(): ByteVector; /** * Adds an item to the current instance, replacing an existing one with the same key. * @param item Item to add to the current instance */ setItem(item: ApeTagItem): void; /** * Stores a number in a specified item. If both `numerator` and * `denominator` are provided the item will be set to `numerator/denominator`. If * neither `numerator` nor `denominator` are provided, the item will be * removed from this tag. A new item is created if one with the specified `key` does * not exist. * @param key Identifier for the item to set the item * @param numerator Whole number of top half of the fraction if `denominator` is * provided * @param denominator Bottom half of the fraction to store. Can be `undefined` if only * `numerator` is needed. */ setNumericValue(key: string, numerator: number, denominator: number): void; /** * Stores a string in the item specified by `key`. This will replace the contents of * the specified item. If `value` is falsy, the item will be removed. * @param key Item to set the value of * @param value String to store in the item. If falsy, the specified item will be removed */ setStringValue(key: string, value: string): void; /** * Stores a list of strings in the item specified by `key`. This will replace the * contents of the specified item. If `value` is falsy or empty, the item will be removed * @param key Item to set the value of * @param values String to store in the item. If falsy or empty, the specified item will be * removed */ setStringValues(key: string, values: string[]): void; private getStringValue; private getStringValues; private getUint32Value; private getItemIndex; private parse; }