{"size": 6151, "ext": "js", "max_stars_repo_path": "node_modules/music-metadata/lib/id3v2/ID3v24TagMapper.js", "max_stars_repo_name": "jasonkwh/bbamp", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "node_modules/music-metadata/lib/id3v2/ID3v24TagMapper.js", "max_issues_repo_name": "jasonkwh/bbamp", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "node_modules/music-metadata/lib/id3v2/ID3v24TagMapper.js", "max_forks_repo_name": "jasonkwh/bbamp", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 35.3505747126, "max_line_length": 117, "alphanum_fraction": 0.5867338644}
"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
var GenericTagMapper_1 = require("../common/GenericTagMapper");
var Util_1 = require("../common/Util");
/**
 * ID3v2.3/ID3v2.4 tag mappings
 */
var id3v24TagMap = {
    // id3v2.3
    TIT2: "title",
    TPE1: "artist",
    "TXXX:Artists": "artists",
    TPE2: "albumartist",
    TALB: "album",
    TDRV: "date",
    /**
     * Original release year
     */
    TORY: "originalyear",
    TPOS: "disk",
    TCON: "genre",
    APIC: "picture",
    TCOM: "composer",
    "USLT:description": "lyrics",
    TSOA: "albumsort",
    TSOT: "titlesort",
    TOAL: "originalalbum",
    TSOP: "artistsort",
    TSO2: "albumartistsort",
    TSOC: "composersort",
    TEXT: "lyricist",
    "TXXX:Writer": "writer",
    TPE3: "conductor",
    // 'IPLS:instrument': 'performer:instrument', // ToDo
    TPE4: "remixer",
    "IPLS:arranger": "arranger",
    "IPLS:engineer": "engineer",
    "IPLS:producer": "producer",
    "IPLS:DJ-mix": "djmixer",
    "IPLS:mix": "mixer",
    TPUB: "label",
    TIT1: "grouping",
    TIT3: "subtitle",
    TRCK: "track",
    TCMP: "compilation",
    POPM: "rating",
    TBPM: "bpm",
    TMED: "media",
    "TXXX:CATALOGNUMBER": "catalognumber",
    "TXXX:MusicBrainz Album Status": "releasestatus",
    "TXXX:MusicBrainz Album Type": "releasetype",
    /**
     * Release country as documented: https://picard.musicbrainz.org/docs/mappings/#cite_note-0
     */
    "TXXX:MusicBrainz Album Release Country": "releasecountry",
    /**
     * Release country as implemented // ToDo: report
     */
    "TXXX:RELEASECOUNTRY": "releasecountry",
    "TXXX:SCRIPT": "script",
    TLAN: "language",
    TCOP: "copyright",
    WCOP: "license",
    TENC: "encodedby",
    TSSE: "encodersettings",
    "TXXX:BARCODE": "barcode",
    TSRC: "isrc",
    "TXXX:ASIN": "asin",
    "TXXX:originalyear": "originalyear",
    "UFID:http://musicbrainz.org": "musicbrainz_recordingid",
    "TXXX:MusicBrainz Release Track Id": "musicbrainz_trackid",
    "TXXX:MusicBrainz Album Id": "musicbrainz_albumid",
    "TXXX:MusicBrainz Artist Id": "musicbrainz_artistid",
    "TXXX:MusicBrainz Album Artist Id": "musicbrainz_albumartistid",
    "TXXX:MusicBrainz Release Group Id": "musicbrainz_releasegroupid",
    "TXXX:MusicBrainz Work Id": "musicbrainz_workid",
    "TXXX:MusicBrainz TRM Id": "musicbrainz_trmid",
    "TXXX:MusicBrainz Disc Id": "musicbrainz_discid",
    "TXXX:ACOUSTID_ID": "acoustid_id",
    "TXXX:Acoustid Id": "acoustid_id",
    "TXXX:Acoustid Fingerprint": "acoustid_fingerprint",
    "TXXX:MusicIP PUID": "musicip_puid",
    "TXXX:MusicMagic Fingerprint": "musicip_fingerprint",
    WOAR: "website",
    // id3v2.4
    // ToDo: In same sequence as defined at http://id3.org/id3v2.4.0-frames
    TDRC: "date",
    TYER: "year",
    TDOR: "originaldate",
    // 'TMCL:instrument': 'performer:instrument',
    "TIPL:arranger": "arranger",
    "TIPL:engineer": "engineer",
    "TIPL:producer": "producer",
    "TIPL:DJ-mix": "djmixer",
    "TIPL:mix": "mixer",
    TMOO: "mood",
    // additional mappings:
    SYLT: "lyrics",
    TSST: "discsubtitle",
    TKEY: "key",
    COMM: "comment",
    TOPE: "originalartist",
    // Windows Media Player
    "PRIV:AverageLevel": "averageLevel",
    "PRIV:PeakLevel": "peakLevel",
    // Discogs
    "TXXX:DISCOGS_RELEASE_ID": "discogs_release_id",
    "TXXX:CATALOGID": "catalognumber",
    "TXXX:STYLE": "genre",
    "TXXX:replaygain_track_peak": "replaygain_track_peak",
    "TXXX:replaygain_track_gain": "replaygain_track_gain"
};
var ID3v24TagMapper = /** @class */ (function (_super) {
    __extends(ID3v24TagMapper, _super);
    function ID3v24TagMapper() {
        return _super.call(this, ['ID3v2.3', 'ID3v2.4'], id3v24TagMap) || this;
    }
    ID3v24TagMapper.toRating = function (popm) {
        return {
            source: popm.email,
            rating: popm.rating > 0 ? popm.rating / 255 * GenericTagMapper_1.CommonTagMapper.rating_steps : undefined
        };
    };
    /**
     * Handle post mapping exceptions / correction
     * @param {string} id Tag key e.g. "©alb"
     * @param id e.g. "Buena Vista Social Club"
     * @return Common value e.g. "Buena Vista Social Club"
     */
    ID3v24TagMapper.prototype.postMap = function (tag) {
        switch (tag.id) {
            case 'UFID': // decode MusicBrainz Recording Id
                if (tag.value.owner_identifier === 'http://musicbrainz.org') {
                    tag.id += ':' + tag.value.owner_identifier;
                    tag.value = Util_1.default.decodeString(tag.value.identifier, 'iso-8859-1');
                }
                break;
            case 'PRIV':
                switch (tag.value.owner_identifier) {
                    // decode Windows Media Player
                    case 'AverageLevel':
                    case 'PeakValue':
                        tag.id += ':' + tag.value.owner_identifier;
                        tag.value = tag.value.data.length === 4 ? tag.value.data.readUInt32LE() : null;
                        // ToDo: flag warning if: tag.value === null
                        break;
                    default:
                    // Unknown PRIV owner-identifier
                }
                break;
            case 'COMM':
                tag.value = tag.value ? tag.value.text : null;
                break;
            case 'POPM':
                tag.value = ID3v24TagMapper.toRating(tag.value);
                break;
            default:
                break;
        }
    };
    return ID3v24TagMapper;
}(GenericTagMapper_1.CommonTagMapper));
exports.ID3v24TagMapper = ID3v24TagMapper;
