File: metadata.hpp

package info (click to toggle)
snapcast 0.31.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,012 kB
  • sloc: cpp: 37,729; python: 2,543; sh: 455; makefile: 16
file content (148 lines) | stat: -rw-r--r-- 6,388 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/***
    This file is part of snapcast
    Copyright (C) 2014-2024  Johannes Pohl

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
***/

#pragma once


// local headers
#include "common/json.hpp"

// standard headers
#include <optional>
#include <string>


using json = nlohmann::json;

class Metadata
{
public:
    struct ArtData
    {
        std::string data;
        std::string extension;

        bool operator==(const ArtData& other) const
        {
            return ((other.data == data) && (other.extension == extension));
        }

        bool operator!=(const ArtData& other) const
        {
            return !(other == *this);
        }
    };

    Metadata() = default;
    Metadata(const json& j);

    /// https://www.musicpd.org/doc/html/protocol.html#tags
    /// the duration of the song
    std::optional<float> duration;
    /// the artist name. Its meaning is not well-defined; see “composer” and “performer” for more specific tags.
    std::optional<std::vector<std::string>> artist;
    /// same as artist, but for sorting. This usually omits prefixes such as “The”.
    std::optional<std::vector<std::string>> artist_sort;
    /// the album name.
    std::optional<std::string> album;
    /// same as album, but for sorting.
    std::optional<std::string> album_sort;
    /// on multi-artist albums, this is the artist name which shall be used for the whole album. The exact meaning of this tag is not well-defined.
    std::optional<std::vector<std::string>> album_artist;
    /// same as albumartist, but for sorting.
    std::optional<std::vector<std::string>> album_artist_sort;
    /// a name for this song. This is not the song title. The exact meaning of this tag is not well-defined. It is often used by badly configured internet radio
    /// stations with broken tags to squeeze both the artist name and the song title in one tag.
    std::optional<std::string> name;
    /// the song’s release date. This is usually a 4-digit year.
    std::optional<std::string> date;
    /// the song’s original release date.
    std::optional<std::string> original_date;
    /// the artist who performed the song.
    std::optional<std::string> performer;
    /// the conductor who conducted the song.
    std::optional<std::string> conductor;
    /// “a work is a distinct intellectual or artistic creation, which can be expressed in the form of one or more audio recordings”
    std::optional<std::string> work;
    /// “used if the sound belongs to a larger category of sounds/music” (from the IDv2.4.0 TIT1 description).
    std::optional<std::string> grouping;
    /// the name of the label or publisher.
    std::optional<std::string> label;
    /// the artist id in the MusicBrainz database.
    std::optional<std::string> musicbrainz_artist_id;
    /// the album id in the MusicBrainz database.
    std::optional<std::string> musicbrainz_album_id;
    /// the album artist id in the MusicBrainz database.
    std::optional<std::string> musicbrainz_album_artist_id;
    /// the track id in the MusicBrainz database.
    std::optional<std::string> musicbrainz_track_id;
    /// the release track id in the MusicBrainz database.
    std::optional<std::string> musicbrainz_release_track_id;
    /// the work id in the MusicBrainz database.
    std::optional<std::string> musicbrainz_work_id;

    /// https://www.freedesktop.org/wiki/Specifications/mpris-spec/metadata/
    /// A unique identity for this track within the context of an MPRIS object (eg: tracklist).
    std::optional<std::string> track_id;
    /// URI: The location of an image representing the track or album. Clients should not assume this will continue to exist when the media player stops giving
    /// out the URL
    std::optional<std::string> art_url;
    /// Base64 encoded data of an image representing the track or album
    std::optional<ArtData> art_data;
    /// The track lyrics
    std::optional<std::string> lyrics;
    /// The speed of the music, in beats per minute
    std::optional<uint16_t> bpm;
    /// Float: An automatically-generated rating, based on things such as how often it has been played. This should be in the range 0.0 to 1.0
    std::optional<float> auto_rating;
    /// A (list of) freeform comment(s)
    std::optional<std::vector<std::string>> comment;
    /// The composer(s) of the track
    std::optional<std::vector<std::string>> composer;
    /// Date/Time: When the track was created. Usually only the year component will be useful
    std::optional<std::string> content_created;
    /// Integer: The disc number on the album that this track is from
    std::optional<uint16_t> disc_number;
    /// Date/Time: When the track was first played
    std::optional<std::string> first_used;
    /// List of Strings: The genre(s) of the track
    std::optional<std::vector<std::string>> genre;
    /// Date/Time: When the track was last played
    std::optional<std::string> last_used;
    /// List of Strings: The lyricist(s) of the track
    std::optional<std::vector<std::string>> lyricist;
    /// String: The track title
    std::optional<std::string> title;
    /// Integer: The track number on the album disc
    std::optional<uint16_t> track_number;
    /// URI: The location of the media file.
    std::optional<std::string> url;
    /// Integer: The number of times the track has been played.
    std::optional<uint16_t> use_count;
    /// Float: A user-specified rating. This should be in the range 0.0 to 1.0.
    std::optional<float> user_rating;

    /// Spotify artist id
    std::optional<std::string> spotify_artist_id;
    /// Spotify track id
    std::optional<std::string> spotify_track_id;

    json toJson() const;
    void fromJson(const json& j);
    bool operator==(const Metadata& other) const;
};