| 1 |
/* |
| 2 |
* Copyright (C) 2013-2018 Team Kodi |
| 3 |
* This file is part of Kodi - https://kodi.tv |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSES/README.md for more information. |
| 7 |
*/ |
| 8 |
|
| 9 |
#pragma once |
| 10 |
|
| 11 |
#include <map> |
| 12 |
#include <string> |
| 13 |
|
| 14 |
using MediaType = std::string; |
| 15 |
|
| 16 |
#define MediaTypeNone "" |
| 17 |
#define MediaTypeMusic "music" |
| 18 |
#define MediaTypeArtist "artist" |
| 19 |
#define MediaTypeAlbum "album" |
| 20 |
#define MediaTypeSong "song" |
| 21 |
#define MediaTypeVideo "video" |
| 22 |
#define MediaTypeVideoCollection "set" |
| 23 |
#define MediaTypeMusicVideo "musicvideo" |
| 24 |
#define MediaTypeMovie "movie" |
| 25 |
#define MediaTypeTvShow "tvshow" |
| 26 |
#define MediaTypeSeason "season" |
| 27 |
#define MediaTypeEpisode "episode" |
| 28 |
#define MediaTypeVideoVersion "videoversion" |
| 29 |
|
| 30 |
constexpr const char* MediaTypeVideoCollections = "sets"; |
| 31 |
constexpr const char* MediaTypeMusicVideos = "musicvideos"; |
| 32 |
constexpr const char* MediaTypeMovies = "movies"; |
| 33 |
constexpr const char* MediaTypeTvShows = "tvshows"; |
| 34 |
constexpr const char* MediaTypeSeasons = "seasons"; |
| 35 |
constexpr const char* MediaTypeEpisodes = "episodes"; |
| 36 |
|
| 37 |
class CMediaTypes |
| 38 |
{ |
| 39 |
public: |
| 40 |
static bool IsValidMediaType(const MediaType &mediaType); |
| 41 |
static bool IsMediaType(const std::string &strMediaType, const MediaType &mediaType); |
| 42 |
static MediaType FromString(const std::string &strMediaType); |
| 43 |
static MediaType ToPlural(const MediaType &mediaType); |
| 44 |
|
| 45 |
static bool IsContainer(const MediaType &mediaType); |
| 46 |
|
| 47 |
static std::string GetLocalization(const MediaType &mediaType); |
| 48 |
static std::string GetPluralLocalization(const MediaType &mediaType); |
| 49 |
static std::string GetCapitalLocalization(const MediaType &mediaType); |
| 50 |
static std::string GetCapitalPluralLocalization(const MediaType &mediaType); |
| 51 |
|
| 52 |
struct MediaTypeInfo |
| 53 |
{ |
| 54 |
MediaTypeInfo(const MediaType &mediaType, const std::string &plural, bool container, |
| 55 |
int localizationSingular, int localizationPlural, |
| 56 |
int localizationSingularCapital, int localizationPluralCapital) |
| 57 |
: mediaType(mediaType), |
| 58 |
plural(plural), |
| 59 |
container(container), |
| 60 |
localizationSingular(localizationSingular), |
| 61 |
localizationPlural(localizationPlural), |
| 62 |
localizationSingularCapital(localizationSingularCapital), |
| 63 |
localizationPluralCapital(localizationPluralCapital) |
| 64 |
{ } |
| 65 |
|
| 66 |
MediaType mediaType; |
| 67 |
std::string plural; |
| 68 |
bool container; |
| 69 |
int localizationSingular; |
| 70 |
int localizationPlural; |
| 71 |
int localizationSingularCapital; |
| 72 |
int localizationPluralCapital; |
| 73 |
}; |
| 74 |
|
| 75 |
private: |
| 76 |
static std::map<std::string, MediaTypeInfo>::const_iterator findMediaType(const std::string &mediaType); |
| 77 |
|
| 78 |
static std::map<std::string, MediaTypeInfo> m_mediaTypes; |
| 79 |
}; |