diff --git a/core/codegen/object_implementation.hbs b/core/codegen/object_implementation.hbs index 4ed675c..0237911 100644 --- a/core/codegen/object_implementation.hbs +++ b/core/codegen/object_implementation.hbs @@ -45,8 +45,17 @@ QJsonObject {{className}}::toJson() const { QJsonObject result; {{#each properties as |property|}} - result["{{property.originalName}}"] = {{supportNamespace}}::toJsonValue<{{property.typeNameWithQualifiers}}>({{property.memberName}}); + {{#if property.isNullable}} + + if (!({{property.nullableCheck}})) { + result["{{property.originalName}}"] = {{supportNamespace}}::toJsonValue<{{property.typeNameWithQualifiers}}>({{property.memberName}}); + } + + {{#else}} + + result["{{property.originalName}}"] = {{supportNamespace}}::toJsonValue<{{property.typeNameWithQualifiers}}>({{property.memberName}}); + {{/if}} {{/each}} return result; diff --git a/core/include/JellyfinQt/apiclient.h b/core/include/JellyfinQt/apiclient.h index b36f369..106ca85 100644 --- a/core/include/JellyfinQt/apiclient.h +++ b/core/include/JellyfinQt/apiclient.h @@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include +#include #include #include #include @@ -85,10 +86,11 @@ class ApiClientPrivate; * * These steps might change. I'm considering decoupling CredentialsManager from this class to clean some code up. */ -class ApiClient : public QObject { +class ApiClient : public QObject, public QQmlParserStatus { friend class WebSocket; friend class PlaybackManager; Q_OBJECT + Q_INTERFACES(QQmlParserStatus) Q_DECLARE_PRIVATE(ApiClient); public: explicit ApiClient(QObject *parent = nullptr); @@ -240,6 +242,9 @@ protected slots: void credManagerUsersListed(const QString &server, QStringList users); void credManagerTokenRetrieved(const QString &server, const QString &user, const QString &token); + void classBegin() override; + void componentComplete() override; + protected: /** * @brief Adds default headers to each request, like authentication headers etc. diff --git a/core/openapigenerator.d b/core/openapigenerator.d index e7fc60b..572ac9d 100755 --- a/core/openapigenerator.d +++ b/core/openapigenerator.d @@ -686,21 +686,30 @@ MetaTypeInfo getType(ref const string name, const ref Node node, const ref Node info.needsLocalImport = true; info.typeName = type; if (type in allSchemas) { - if ("type" in allSchemas[type] - && allSchemas[type]["type"].as!string == "object") { + if ("enum" in allSchemas[type]) { + info.isTypeNullable = true; + info.typeNullableCheck = "== " ~ info.typeName ~ "::EnumNotSet"; + info.typeNullableSetter = "= " ~ info.typeName ~ "::EnumNotSet"; + } else if ("type" in allSchemas[type] + && allSchemas[type]["type"].as!string == "object") { + writefln("Type %s is an object", type); info.needsPointer = true; info.isTypeNullable = true; info.typeNullableCheck = ".isNull()"; info.typeNullableSetter = ".clear()"; - } else if ("enum" in allSchemas[type]) { - info.isTypeNullable = true; - info.typeNullableCheck = "== " ~ info.typeName ~ "::EnumNotSet"; - info.typeNullableSetter = "= " ~ info.typeName ~ "::EnumNotSet"; } } return info; } + // Type is an enumeration + if ("enum" in node) { + info.isTypeNullable = true; + info.typeNullableCheck = "== " ~ info.typeName ~ "::EnumNotSet"; + info.typeNullableSetter = "= " ~ info.typeName ~ "::EnumNotSet"; + return info; + } + // No type information specified. As a fallback, use a QVariant. if (!("type" in node)) { info.typeName = "QVariant"; diff --git a/core/src/apiclient.cpp b/core/src/apiclient.cpp index 214b68b..e3a72a3 100644 --- a/core/src/apiclient.cpp +++ b/core/src/apiclient.cpp @@ -51,7 +51,7 @@ public: bool online = true; QSharedPointer deviceProfile; QSharedPointer clientCapabilities; - QVariantList supportedCommands; + QList supportedCommands; bool authenticated = false; @@ -60,6 +60,8 @@ public: */ QUuid retrieveDeviceId() const; + bool componentBeingParsed = false; + }; ApiClient::ApiClient(QObject *parent) @@ -73,7 +75,6 @@ ApiClient::ApiClient(QObject *parent) connect(d->credManager, &CredentialsManager::serversListed, this, &ApiClient::credManagerServersListed); connect(d->credManager, &CredentialsManager::usersListed, this, &ApiClient::credManagerUsersListed); connect(d->credManager, &CredentialsManager::tokenRetrieved, this, &ApiClient::credManagerTokenRetrieved); - generateDeviceProfile(); connect(d->settings, &ViewModel::Settings::maxStreamingBitRateChanged, this, [d](qint32 newBitrate){ d->deviceProfile->setMaxStreamingBitrate(newBitrate); }); @@ -148,13 +149,29 @@ ViewModel::Settings *ApiClient::settings() const { QVariantList ApiClient::supportedCommands() const { Q_D(const ApiClient); - return d->supportedCommands; + QVariantList result; + result.reserve(d->supportedCommands.size()); + for(auto it = d->supportedCommands.begin(); it != d->supportedCommands.end(); it++) { + result.append(QVariant::fromValue(*it)); + } + return result; } void ApiClient::setSupportedCommands(QVariantList newSupportedCommands) { Q_D(ApiClient); - d->supportedCommands = newSupportedCommands; + d->supportedCommands.clear(); + d->supportedCommands.reserve(newSupportedCommands.size()); + for (int i = 0; i < newSupportedCommands.size(); i++) { + if (newSupportedCommands[i].canConvert()) { + d->supportedCommands.append(newSupportedCommands[i].value()); + } + } + qDebug() << "Supported commands changed: " << d->supportedCommands; emit supportedCommandsChanged(); + + if (!d->componentBeingParsed) { + this->generateDeviceProfile(); + } } QSharedPointer ApiClient::deviceProfile() const { Q_D(const ApiClient); @@ -169,6 +186,22 @@ const QJsonObject ApiClient::clientCapabilities() const { Q_D(const ApiClient); return d->clientCapabilities->toJson(); } + +// QQMLParserStatus implementation +void ApiClient::classBegin() { + Q_D(ApiClient); + d->componentBeingParsed = true; +} + +void ApiClient::componentComplete() { + Q_D(ApiClient); + d->componentBeingParsed = false; + + // Generate the device profile after all properties have been parsed. + generateDeviceProfile(); +} + + //////////////////////////////////////////////////////////////////////////////////////////////////// // BASE HTTP METHODS // //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -397,18 +430,10 @@ void ApiClient::generateDeviceProfile() { deviceProfile->setMaxStreamingBitrate(d->settings->maxStreamingBitRate()); d->deviceProfile = deviceProfile; - QList supportedCommands; - supportedCommands.reserve(d->supportedCommands.size()); - for (int i = 0; i < d->supportedCommands.size(); i++) { - if (d->supportedCommands[i].canConvert()) { - supportedCommands.append(d->supportedCommands[i].value()); - } - } - QSharedPointer clientCapabilities = QSharedPointer::create(); clientCapabilities->setPlayableMediaTypes({"Audio", "Video", "Photo"}); clientCapabilities->setDeviceProfile(deviceProfile); - clientCapabilities->setSupportedCommands(supportedCommands); + clientCapabilities->setSupportedCommands(d->supportedCommands); clientCapabilities->setAppStoreUrl("https://chris.netsoj.nl/projects/harbour-sailfin"); clientCapabilities->setIconUrl("https://chris.netsoj.nl/static/img/logo.png"); clientCapabilities->setSupportsPersistentIdentifier(true); diff --git a/core/src/dto/accessschedule.cpp b/core/src/dto/accessschedule.cpp index 4b2dc16..c66afbd 100644 --- a/core/src/dto/accessschedule.cpp +++ b/core/src/dto/accessschedule.cpp @@ -69,12 +69,12 @@ void AccessSchedule::setFromJson(QJsonObject source) { QJsonObject AccessSchedule::toJson() const { QJsonObject result; - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); - result["DayOfWeek"] = Jellyfin::Support::toJsonValue(m_dayOfWeek); - result["StartHour"] = Jellyfin::Support::toJsonValue(m_startHour); - result["EndHour"] = Jellyfin::Support::toJsonValue(m_endHour); - + + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); + result["DayOfWeek"] = Jellyfin::Support::toJsonValue(m_dayOfWeek); + result["StartHour"] = Jellyfin::Support::toJsonValue(m_startHour); + result["EndHour"] = Jellyfin::Support::toJsonValue(m_endHour); return result; } diff --git a/core/src/dto/activitylogentry.cpp b/core/src/dto/activitylogentry.cpp index c4a5290..49a8e8e 100644 --- a/core/src/dto/activitylogentry.cpp +++ b/core/src/dto/activitylogentry.cpp @@ -84,17 +84,41 @@ void ActivityLogEntry::setFromJson(QJsonObject source) { QJsonObject ActivityLogEntry::toJson() const { QJsonObject result; - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Overview"] = Jellyfin::Support::toJsonValue(m_overview); - result["ShortOverview"] = Jellyfin::Support::toJsonValue(m_shortOverview); - result["Type"] = Jellyfin::Support::toJsonValue(m_type); - result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); - result["Date"] = Jellyfin::Support::toJsonValue(m_date); - result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); - result["UserPrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_userPrimaryImageTag); - result["Severity"] = Jellyfin::Support::toJsonValue(m_severity); - + + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_overview.isNull())) { + result["Overview"] = Jellyfin::Support::toJsonValue(m_overview); + } + + + if (!(m_shortOverview.isNull())) { + result["ShortOverview"] = Jellyfin::Support::toJsonValue(m_shortOverview); + } + + + if (!(m_type.isNull())) { + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + } + + + if (!(m_itemId.isNull())) { + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + } + + result["Date"] = Jellyfin::Support::toJsonValue(m_date); + result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); + + if (!(m_userPrimaryImageTag.isNull())) { + result["UserPrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_userPrimaryImageTag); + } + + result["Severity"] = Jellyfin::Support::toJsonValue(m_severity); return result; } diff --git a/core/src/dto/activitylogentryqueryresult.cpp b/core/src/dto/activitylogentryqueryresult.cpp index 7437ab6..c85917b 100644 --- a/core/src/dto/activitylogentryqueryresult.cpp +++ b/core/src/dto/activitylogentryqueryresult.cpp @@ -63,10 +63,14 @@ void ActivityLogEntryQueryResult::setFromJson(QJsonObject source) { QJsonObject ActivityLogEntryQueryResult::toJson() const { QJsonObject result; - result["Items"] = Jellyfin::Support::toJsonValue>(m_items); - result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); - result["StartIndex"] = Jellyfin::Support::toJsonValue(m_startIndex); - + + + if (!(m_items.size() == 0)) { + result["Items"] = Jellyfin::Support::toJsonValue>(m_items); + } + + result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); + result["StartIndex"] = Jellyfin::Support::toJsonValue(m_startIndex); return result; } diff --git a/core/src/dto/addvirtualfolderdto.cpp b/core/src/dto/addvirtualfolderdto.cpp index 68c23bf..0c756ab 100644 --- a/core/src/dto/addvirtualfolderdto.cpp +++ b/core/src/dto/addvirtualfolderdto.cpp @@ -57,8 +57,8 @@ void AddVirtualFolderDto::setFromJson(QJsonObject source) { QJsonObject AddVirtualFolderDto::toJson() const { QJsonObject result; - result["LibraryOptions"] = Jellyfin::Support::toJsonValue>(m_libraryOptions); - + + result["LibraryOptions"] = Jellyfin::Support::toJsonValue>(m_libraryOptions); return result; } diff --git a/core/src/dto/albuminfo.cpp b/core/src/dto/albuminfo.cpp index a06efd1..9ac3916 100644 --- a/core/src/dto/albuminfo.cpp +++ b/core/src/dto/albuminfo.cpp @@ -93,20 +93,68 @@ void AlbumInfo::setFromJson(QJsonObject source) { QJsonObject AlbumInfo::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Path"] = Jellyfin::Support::toJsonValue(m_path); - result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); - result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); - result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); - result["Year"] = Jellyfin::Support::toJsonValue>(m_year); - result["IndexNumber"] = Jellyfin::Support::toJsonValue>(m_indexNumber); - result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue>(m_parentIndexNumber); - result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); - result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); - result["AlbumArtists"] = Jellyfin::Support::toJsonValue(m_albumArtists); - result["ArtistProviderIds"] = Jellyfin::Support::toJsonValue(m_artistProviderIds); - result["SongInfos"] = Jellyfin::Support::toJsonValue>(m_songInfos); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_path.isNull())) { + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + } + + + if (!(m_metadataLanguage.isNull())) { + result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); + } + + + if (!(m_metadataCountryCode.isNull())) { + result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); + } + + + if (!(m_providerIds.isEmpty())) { + result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); + } + + + if (!(!m_year.has_value())) { + result["Year"] = Jellyfin::Support::toJsonValue>(m_year); + } + + + if (!(!m_indexNumber.has_value())) { + result["IndexNumber"] = Jellyfin::Support::toJsonValue>(m_indexNumber); + } + + + if (!(!m_parentIndexNumber.has_value())) { + result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue>(m_parentIndexNumber); + } + + + if (!(m_premiereDate.isNull())) { + result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); + } + + result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); + + if (!(m_albumArtists.size() == 0)) { + result["AlbumArtists"] = Jellyfin::Support::toJsonValue(m_albumArtists); + } + + + if (!(m_artistProviderIds.isEmpty())) { + result["ArtistProviderIds"] = Jellyfin::Support::toJsonValue(m_artistProviderIds); + } + + + if (!(m_songInfos.size() == 0)) { + result["SongInfos"] = Jellyfin::Support::toJsonValue>(m_songInfos); + } + return result; } diff --git a/core/src/dto/albuminforemotesearchquery.cpp b/core/src/dto/albuminforemotesearchquery.cpp index 9e694bf..650a3d9 100644 --- a/core/src/dto/albuminforemotesearchquery.cpp +++ b/core/src/dto/albuminforemotesearchquery.cpp @@ -66,11 +66,15 @@ void AlbumInfoRemoteSearchQuery::setFromJson(QJsonObject source) { QJsonObject AlbumInfoRemoteSearchQuery::toJson() const { QJsonObject result; - result["SearchInfo"] = Jellyfin::Support::toJsonValue>(m_searchInfo); - result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); - result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); - result["IncludeDisabledProviders"] = Jellyfin::Support::toJsonValue(m_includeDisabledProviders); - + + result["SearchInfo"] = Jellyfin::Support::toJsonValue>(m_searchInfo); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + + if (!(m_searchProviderName.isNull())) { + result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); + } + + result["IncludeDisabledProviders"] = Jellyfin::Support::toJsonValue(m_includeDisabledProviders); return result; } diff --git a/core/src/dto/allthememediaresult.cpp b/core/src/dto/allthememediaresult.cpp index d330d81..7358fc2 100644 --- a/core/src/dto/allthememediaresult.cpp +++ b/core/src/dto/allthememediaresult.cpp @@ -63,10 +63,10 @@ void AllThemeMediaResult::setFromJson(QJsonObject source) { QJsonObject AllThemeMediaResult::toJson() const { QJsonObject result; - result["ThemeVideosResult"] = Jellyfin::Support::toJsonValue>(m_themeVideosResult); - result["ThemeSongsResult"] = Jellyfin::Support::toJsonValue>(m_themeSongsResult); - result["SoundtrackSongsResult"] = Jellyfin::Support::toJsonValue>(m_soundtrackSongsResult); - + + result["ThemeVideosResult"] = Jellyfin::Support::toJsonValue>(m_themeVideosResult); + result["ThemeSongsResult"] = Jellyfin::Support::toJsonValue>(m_themeSongsResult); + result["SoundtrackSongsResult"] = Jellyfin::Support::toJsonValue>(m_soundtrackSongsResult); return result; } diff --git a/core/src/dto/artistinfo.cpp b/core/src/dto/artistinfo.cpp index 4951768..008042c 100644 --- a/core/src/dto/artistinfo.cpp +++ b/core/src/dto/artistinfo.cpp @@ -87,18 +87,58 @@ void ArtistInfo::setFromJson(QJsonObject source) { QJsonObject ArtistInfo::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Path"] = Jellyfin::Support::toJsonValue(m_path); - result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); - result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); - result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); - result["Year"] = Jellyfin::Support::toJsonValue>(m_year); - result["IndexNumber"] = Jellyfin::Support::toJsonValue>(m_indexNumber); - result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue>(m_parentIndexNumber); - result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); - result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); - result["SongInfos"] = Jellyfin::Support::toJsonValue>(m_songInfos); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_path.isNull())) { + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + } + + + if (!(m_metadataLanguage.isNull())) { + result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); + } + + + if (!(m_metadataCountryCode.isNull())) { + result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); + } + + + if (!(m_providerIds.isEmpty())) { + result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); + } + + + if (!(!m_year.has_value())) { + result["Year"] = Jellyfin::Support::toJsonValue>(m_year); + } + + + if (!(!m_indexNumber.has_value())) { + result["IndexNumber"] = Jellyfin::Support::toJsonValue>(m_indexNumber); + } + + + if (!(!m_parentIndexNumber.has_value())) { + result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue>(m_parentIndexNumber); + } + + + if (!(m_premiereDate.isNull())) { + result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); + } + + result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); + + if (!(m_songInfos.size() == 0)) { + result["SongInfos"] = Jellyfin::Support::toJsonValue>(m_songInfos); + } + return result; } diff --git a/core/src/dto/artistinforemotesearchquery.cpp b/core/src/dto/artistinforemotesearchquery.cpp index 983dbf4..3ffa2a0 100644 --- a/core/src/dto/artistinforemotesearchquery.cpp +++ b/core/src/dto/artistinforemotesearchquery.cpp @@ -66,11 +66,15 @@ void ArtistInfoRemoteSearchQuery::setFromJson(QJsonObject source) { QJsonObject ArtistInfoRemoteSearchQuery::toJson() const { QJsonObject result; - result["SearchInfo"] = Jellyfin::Support::toJsonValue>(m_searchInfo); - result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); - result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); - result["IncludeDisabledProviders"] = Jellyfin::Support::toJsonValue(m_includeDisabledProviders); - + + result["SearchInfo"] = Jellyfin::Support::toJsonValue>(m_searchInfo); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + + if (!(m_searchProviderName.isNull())) { + result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); + } + + result["IncludeDisabledProviders"] = Jellyfin::Support::toJsonValue(m_includeDisabledProviders); return result; } diff --git a/core/src/dto/authenticateuserbyname.cpp b/core/src/dto/authenticateuserbyname.cpp index 4e82272..faead69 100644 --- a/core/src/dto/authenticateuserbyname.cpp +++ b/core/src/dto/authenticateuserbyname.cpp @@ -63,10 +63,22 @@ void AuthenticateUserByName::setFromJson(QJsonObject source) { QJsonObject AuthenticateUserByName::toJson() const { QJsonObject result; - result["Username"] = Jellyfin::Support::toJsonValue(m_username); - result["Pw"] = Jellyfin::Support::toJsonValue(m_pw); - result["Password"] = Jellyfin::Support::toJsonValue(m_password); - + + + if (!(m_username.isNull())) { + result["Username"] = Jellyfin::Support::toJsonValue(m_username); + } + + + if (!(m_pw.isNull())) { + result["Pw"] = Jellyfin::Support::toJsonValue(m_pw); + } + + + if (!(m_password.isNull())) { + result["Password"] = Jellyfin::Support::toJsonValue(m_password); + } + return result; } diff --git a/core/src/dto/authenticationinfo.cpp b/core/src/dto/authenticationinfo.cpp index 94e7857..1ff4977 100644 --- a/core/src/dto/authenticationinfo.cpp +++ b/core/src/dto/authenticationinfo.cpp @@ -90,19 +90,47 @@ void AuthenticationInfo::setFromJson(QJsonObject source) { QJsonObject AuthenticationInfo::toJson() const { QJsonObject result; - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["AccessToken"] = Jellyfin::Support::toJsonValue(m_accessToken); - result["DeviceId"] = Jellyfin::Support::toJsonValue(m_deviceId); - result["AppName"] = Jellyfin::Support::toJsonValue(m_appName); - result["AppVersion"] = Jellyfin::Support::toJsonValue(m_appVersion); - result["DeviceName"] = Jellyfin::Support::toJsonValue(m_deviceName); - result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); - result["IsActive"] = Jellyfin::Support::toJsonValue(m_isActive); - result["DateCreated"] = Jellyfin::Support::toJsonValue(m_dateCreated); - result["DateRevoked"] = Jellyfin::Support::toJsonValue(m_dateRevoked); - result["DateLastActivity"] = Jellyfin::Support::toJsonValue(m_dateLastActivity); - result["UserName"] = Jellyfin::Support::toJsonValue(m_userName); - + + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + + if (!(m_accessToken.isNull())) { + result["AccessToken"] = Jellyfin::Support::toJsonValue(m_accessToken); + } + + + if (!(m_deviceId.isNull())) { + result["DeviceId"] = Jellyfin::Support::toJsonValue(m_deviceId); + } + + + if (!(m_appName.isNull())) { + result["AppName"] = Jellyfin::Support::toJsonValue(m_appName); + } + + + if (!(m_appVersion.isNull())) { + result["AppVersion"] = Jellyfin::Support::toJsonValue(m_appVersion); + } + + + if (!(m_deviceName.isNull())) { + result["DeviceName"] = Jellyfin::Support::toJsonValue(m_deviceName); + } + + result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); + result["IsActive"] = Jellyfin::Support::toJsonValue(m_isActive); + result["DateCreated"] = Jellyfin::Support::toJsonValue(m_dateCreated); + + if (!(m_dateRevoked.isNull())) { + result["DateRevoked"] = Jellyfin::Support::toJsonValue(m_dateRevoked); + } + + result["DateLastActivity"] = Jellyfin::Support::toJsonValue(m_dateLastActivity); + + if (!(m_userName.isNull())) { + result["UserName"] = Jellyfin::Support::toJsonValue(m_userName); + } + return result; } diff --git a/core/src/dto/authenticationinfoqueryresult.cpp b/core/src/dto/authenticationinfoqueryresult.cpp index b566397..beff870 100644 --- a/core/src/dto/authenticationinfoqueryresult.cpp +++ b/core/src/dto/authenticationinfoqueryresult.cpp @@ -63,10 +63,14 @@ void AuthenticationInfoQueryResult::setFromJson(QJsonObject source) { QJsonObject AuthenticationInfoQueryResult::toJson() const { QJsonObject result; - result["Items"] = Jellyfin::Support::toJsonValue>(m_items); - result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); - result["StartIndex"] = Jellyfin::Support::toJsonValue(m_startIndex); - + + + if (!(m_items.size() == 0)) { + result["Items"] = Jellyfin::Support::toJsonValue>(m_items); + } + + result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); + result["StartIndex"] = Jellyfin::Support::toJsonValue(m_startIndex); return result; } diff --git a/core/src/dto/authenticationresult.cpp b/core/src/dto/authenticationresult.cpp index e75b842..eb4678d 100644 --- a/core/src/dto/authenticationresult.cpp +++ b/core/src/dto/authenticationresult.cpp @@ -66,11 +66,19 @@ void AuthenticationResult::setFromJson(QJsonObject source) { QJsonObject AuthenticationResult::toJson() const { QJsonObject result; - result["User"] = Jellyfin::Support::toJsonValue>(m_user); - result["SessionInfo"] = Jellyfin::Support::toJsonValue>(m_sessionInfo); - result["AccessToken"] = Jellyfin::Support::toJsonValue(m_accessToken); - result["ServerId"] = Jellyfin::Support::toJsonValue(m_serverId); - + + result["User"] = Jellyfin::Support::toJsonValue>(m_user); + result["SessionInfo"] = Jellyfin::Support::toJsonValue>(m_sessionInfo); + + if (!(m_accessToken.isNull())) { + result["AccessToken"] = Jellyfin::Support::toJsonValue(m_accessToken); + } + + + if (!(m_serverId.isNull())) { + result["ServerId"] = Jellyfin::Support::toJsonValue(m_serverId); + } + return result; } diff --git a/core/src/dto/baseitem.cpp b/core/src/dto/baseitem.cpp index 8b5f155..3f97767 100644 --- a/core/src/dto/baseitem.cpp +++ b/core/src/dto/baseitem.cpp @@ -87,18 +87,38 @@ void BaseItem::setFromJson(QJsonObject source) { QJsonObject BaseItem::toJson() const { QJsonObject result; - result["Size"] = Jellyfin::Support::toJsonValue>(m_size); - result["Container"] = Jellyfin::Support::toJsonValue(m_container); - result["DateLastSaved"] = Jellyfin::Support::toJsonValue(m_dateLastSaved); - result["RemoteTrailers"] = Jellyfin::Support::toJsonValue>(m_remoteTrailers); - result["IsHD"] = Jellyfin::Support::toJsonValue(m_isHD); - result["IsShortcut"] = Jellyfin::Support::toJsonValue(m_isShortcut); - result["ShortcutPath"] = Jellyfin::Support::toJsonValue(m_shortcutPath); - result["Width"] = Jellyfin::Support::toJsonValue(m_width); - result["Height"] = Jellyfin::Support::toJsonValue(m_height); - result["ExtraIds"] = Jellyfin::Support::toJsonValue(m_extraIds); - result["SupportsExternalTransfer"] = Jellyfin::Support::toJsonValue(m_supportsExternalTransfer); - + + + if (!(!m_size.has_value())) { + result["Size"] = Jellyfin::Support::toJsonValue>(m_size); + } + + + if (!(m_container.isNull())) { + result["Container"] = Jellyfin::Support::toJsonValue(m_container); + } + + result["DateLastSaved"] = Jellyfin::Support::toJsonValue(m_dateLastSaved); + + if (!(m_remoteTrailers.size() == 0)) { + result["RemoteTrailers"] = Jellyfin::Support::toJsonValue>(m_remoteTrailers); + } + + result["IsHD"] = Jellyfin::Support::toJsonValue(m_isHD); + result["IsShortcut"] = Jellyfin::Support::toJsonValue(m_isShortcut); + + if (!(m_shortcutPath.isNull())) { + result["ShortcutPath"] = Jellyfin::Support::toJsonValue(m_shortcutPath); + } + + result["Width"] = Jellyfin::Support::toJsonValue(m_width); + result["Height"] = Jellyfin::Support::toJsonValue(m_height); + + if (!(m_extraIds.size() == 0)) { + result["ExtraIds"] = Jellyfin::Support::toJsonValue(m_extraIds); + } + + result["SupportsExternalTransfer"] = Jellyfin::Support::toJsonValue(m_supportsExternalTransfer); return result; } diff --git a/core/src/dto/baseitemdto.cpp b/core/src/dto/baseitemdto.cpp index 8128f12..49008cf 100644 --- a/core/src/dto/baseitemdto.cpp +++ b/core/src/dto/baseitemdto.cpp @@ -507,158 +507,718 @@ void BaseItemDto::setFromJson(QJsonObject source) { QJsonObject BaseItemDto::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["OriginalTitle"] = Jellyfin::Support::toJsonValue(m_originalTitle); - result["ServerId"] = Jellyfin::Support::toJsonValue(m_serverId); - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["Etag"] = Jellyfin::Support::toJsonValue(m_etag); - result["SourceType"] = Jellyfin::Support::toJsonValue(m_sourceType); - result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); - result["DateCreated"] = Jellyfin::Support::toJsonValue(m_dateCreated); - result["DateLastMediaAdded"] = Jellyfin::Support::toJsonValue(m_dateLastMediaAdded); - result["ExtraType"] = Jellyfin::Support::toJsonValue(m_extraType); - result["AirsBeforeSeasonNumber"] = Jellyfin::Support::toJsonValue>(m_airsBeforeSeasonNumber); - result["AirsAfterSeasonNumber"] = Jellyfin::Support::toJsonValue>(m_airsAfterSeasonNumber); - result["AirsBeforeEpisodeNumber"] = Jellyfin::Support::toJsonValue>(m_airsBeforeEpisodeNumber); - result["CanDelete"] = Jellyfin::Support::toJsonValue>(m_canDelete); - result["CanDownload"] = Jellyfin::Support::toJsonValue>(m_canDownload); - result["HasSubtitles"] = Jellyfin::Support::toJsonValue>(m_hasSubtitles); - result["PreferredMetadataLanguage"] = Jellyfin::Support::toJsonValue(m_preferredMetadataLanguage); - result["PreferredMetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_preferredMetadataCountryCode); - result["SupportsSync"] = Jellyfin::Support::toJsonValue>(m_supportsSync); - result["Container"] = Jellyfin::Support::toJsonValue(m_container); - result["SortName"] = Jellyfin::Support::toJsonValue(m_sortName); - result["ForcedSortName"] = Jellyfin::Support::toJsonValue(m_forcedSortName); - result["Video3DFormat"] = Jellyfin::Support::toJsonValue(m_video3DFormat); - result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); - result["ExternalUrls"] = Jellyfin::Support::toJsonValue>(m_externalUrls); - result["MediaSources"] = Jellyfin::Support::toJsonValue>(m_mediaSources); - result["CriticRating"] = Jellyfin::Support::toJsonValue>(m_criticRating); - result["ProductionLocations"] = Jellyfin::Support::toJsonValue(m_productionLocations); - result["Path"] = Jellyfin::Support::toJsonValue(m_path); - result["EnableMediaSourceDisplay"] = Jellyfin::Support::toJsonValue>(m_enableMediaSourceDisplay); - result["OfficialRating"] = Jellyfin::Support::toJsonValue(m_officialRating); - result["CustomRating"] = Jellyfin::Support::toJsonValue(m_customRating); - result["ChannelId"] = Jellyfin::Support::toJsonValue(m_channelId); - result["ChannelName"] = Jellyfin::Support::toJsonValue(m_channelName); - result["Overview"] = Jellyfin::Support::toJsonValue(m_overview); - result["Taglines"] = Jellyfin::Support::toJsonValue(m_taglines); - result["Genres"] = Jellyfin::Support::toJsonValue(m_genres); - result["CommunityRating"] = Jellyfin::Support::toJsonValue>(m_communityRating); - result["CumulativeRunTimeTicks"] = Jellyfin::Support::toJsonValue>(m_cumulativeRunTimeTicks); - result["RunTimeTicks"] = Jellyfin::Support::toJsonValue>(m_runTimeTicks); - result["PlayAccess"] = Jellyfin::Support::toJsonValue(m_playAccess); - result["AspectRatio"] = Jellyfin::Support::toJsonValue(m_aspectRatio); - result["ProductionYear"] = Jellyfin::Support::toJsonValue>(m_productionYear); - result["IsPlaceHolder"] = Jellyfin::Support::toJsonValue>(m_isPlaceHolder); - result["Number"] = Jellyfin::Support::toJsonValue(m_number); - result["ChannelNumber"] = Jellyfin::Support::toJsonValue(m_channelNumber); - result["IndexNumber"] = Jellyfin::Support::toJsonValue>(m_indexNumber); - result["IndexNumberEnd"] = Jellyfin::Support::toJsonValue>(m_indexNumberEnd); - result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue>(m_parentIndexNumber); - result["RemoteTrailers"] = Jellyfin::Support::toJsonValue>(m_remoteTrailers); - result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); - result["IsHD"] = Jellyfin::Support::toJsonValue>(m_isHD); - result["IsFolder"] = Jellyfin::Support::toJsonValue>(m_isFolder); - result["ParentId"] = Jellyfin::Support::toJsonValue(m_parentId); - result["Type"] = Jellyfin::Support::toJsonValue(m_type); - result["People"] = Jellyfin::Support::toJsonValue>(m_people); - result["Studios"] = Jellyfin::Support::toJsonValue>(m_studios); - result["GenreItems"] = Jellyfin::Support::toJsonValue>(m_genreItems); - result["ParentLogoItemId"] = Jellyfin::Support::toJsonValue(m_parentLogoItemId); - result["ParentBackdropItemId"] = Jellyfin::Support::toJsonValue(m_parentBackdropItemId); - result["ParentBackdropImageTags"] = Jellyfin::Support::toJsonValue(m_parentBackdropImageTags); - result["LocalTrailerCount"] = Jellyfin::Support::toJsonValue>(m_localTrailerCount); - result["UserData"] = Jellyfin::Support::toJsonValue>(m_userData); - result["RecursiveItemCount"] = Jellyfin::Support::toJsonValue>(m_recursiveItemCount); - result["ChildCount"] = Jellyfin::Support::toJsonValue>(m_childCount); - result["SeriesName"] = Jellyfin::Support::toJsonValue(m_seriesName); - result["SeriesId"] = Jellyfin::Support::toJsonValue(m_seriesId); - result["SeasonId"] = Jellyfin::Support::toJsonValue(m_seasonId); - result["SpecialFeatureCount"] = Jellyfin::Support::toJsonValue>(m_specialFeatureCount); - result["DisplayPreferencesId"] = Jellyfin::Support::toJsonValue(m_displayPreferencesId); - result["Status"] = Jellyfin::Support::toJsonValue(m_status); - result["AirTime"] = Jellyfin::Support::toJsonValue(m_airTime); - result["AirDays"] = Jellyfin::Support::toJsonValue>(m_airDays); - result["Tags"] = Jellyfin::Support::toJsonValue(m_tags); - result["PrimaryImageAspectRatio"] = Jellyfin::Support::toJsonValue>(m_primaryImageAspectRatio); - result["Artists"] = Jellyfin::Support::toJsonValue(m_artists); - result["ArtistItems"] = Jellyfin::Support::toJsonValue>(m_artistItems); - result["Album"] = Jellyfin::Support::toJsonValue(m_album); - result["CollectionType"] = Jellyfin::Support::toJsonValue(m_collectionType); - result["DisplayOrder"] = Jellyfin::Support::toJsonValue(m_displayOrder); - result["AlbumId"] = Jellyfin::Support::toJsonValue(m_albumId); - result["AlbumPrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_albumPrimaryImageTag); - result["SeriesPrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_seriesPrimaryImageTag); - result["AlbumArtist"] = Jellyfin::Support::toJsonValue(m_albumArtist); - result["AlbumArtists"] = Jellyfin::Support::toJsonValue>(m_albumArtists); - result["SeasonName"] = Jellyfin::Support::toJsonValue(m_seasonName); - result["MediaStreams"] = Jellyfin::Support::toJsonValue>(m_mediaStreams); - result["VideoType"] = Jellyfin::Support::toJsonValue(m_videoType); - result["PartCount"] = Jellyfin::Support::toJsonValue>(m_partCount); - result["MediaSourceCount"] = Jellyfin::Support::toJsonValue>(m_mediaSourceCount); - result["ImageTags"] = Jellyfin::Support::toJsonValue(m_imageTags); - result["BackdropImageTags"] = Jellyfin::Support::toJsonValue(m_backdropImageTags); - result["ScreenshotImageTags"] = Jellyfin::Support::toJsonValue(m_screenshotImageTags); - result["ParentLogoImageTag"] = Jellyfin::Support::toJsonValue(m_parentLogoImageTag); - result["ParentArtItemId"] = Jellyfin::Support::toJsonValue(m_parentArtItemId); - result["ParentArtImageTag"] = Jellyfin::Support::toJsonValue(m_parentArtImageTag); - result["SeriesThumbImageTag"] = Jellyfin::Support::toJsonValue(m_seriesThumbImageTag); - result["ImageBlurHashes"] = Jellyfin::Support::toJsonValue(m_imageBlurHashes); - result["SeriesStudio"] = Jellyfin::Support::toJsonValue(m_seriesStudio); - result["ParentThumbItemId"] = Jellyfin::Support::toJsonValue(m_parentThumbItemId); - result["ParentThumbImageTag"] = Jellyfin::Support::toJsonValue(m_parentThumbImageTag); - result["ParentPrimaryImageItemId"] = Jellyfin::Support::toJsonValue(m_parentPrimaryImageItemId); - result["ParentPrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_parentPrimaryImageTag); - result["Chapters"] = Jellyfin::Support::toJsonValue>(m_chapters); - result["LocationType"] = Jellyfin::Support::toJsonValue(m_locationType); - result["IsoType"] = Jellyfin::Support::toJsonValue(m_isoType); - result["MediaType"] = Jellyfin::Support::toJsonValue(m_mediaType); - result["EndDate"] = Jellyfin::Support::toJsonValue(m_endDate); - result["LockedFields"] = Jellyfin::Support::toJsonValue>(m_lockedFields); - result["TrailerCount"] = Jellyfin::Support::toJsonValue>(m_trailerCount); - result["MovieCount"] = Jellyfin::Support::toJsonValue>(m_movieCount); - result["SeriesCount"] = Jellyfin::Support::toJsonValue>(m_seriesCount); - result["ProgramCount"] = Jellyfin::Support::toJsonValue>(m_programCount); - result["EpisodeCount"] = Jellyfin::Support::toJsonValue>(m_episodeCount); - result["SongCount"] = Jellyfin::Support::toJsonValue>(m_songCount); - result["AlbumCount"] = Jellyfin::Support::toJsonValue>(m_albumCount); - result["ArtistCount"] = Jellyfin::Support::toJsonValue>(m_artistCount); - result["MusicVideoCount"] = Jellyfin::Support::toJsonValue>(m_musicVideoCount); - result["LockData"] = Jellyfin::Support::toJsonValue>(m_lockData); - result["Width"] = Jellyfin::Support::toJsonValue>(m_width); - result["Height"] = Jellyfin::Support::toJsonValue>(m_height); - result["CameraMake"] = Jellyfin::Support::toJsonValue(m_cameraMake); - result["CameraModel"] = Jellyfin::Support::toJsonValue(m_cameraModel); - result["Software"] = Jellyfin::Support::toJsonValue(m_software); - result["ExposureTime"] = Jellyfin::Support::toJsonValue>(m_exposureTime); - result["FocalLength"] = Jellyfin::Support::toJsonValue>(m_focalLength); - result["ImageOrientation"] = Jellyfin::Support::toJsonValue(m_imageOrientation); - result["Aperture"] = Jellyfin::Support::toJsonValue>(m_aperture); - result["ShutterSpeed"] = Jellyfin::Support::toJsonValue>(m_shutterSpeed); - result["Latitude"] = Jellyfin::Support::toJsonValue>(m_latitude); - result["Longitude"] = Jellyfin::Support::toJsonValue>(m_longitude); - result["Altitude"] = Jellyfin::Support::toJsonValue>(m_altitude); - result["IsoSpeedRating"] = Jellyfin::Support::toJsonValue>(m_isoSpeedRating); - result["SeriesTimerId"] = Jellyfin::Support::toJsonValue(m_seriesTimerId); - result["ProgramId"] = Jellyfin::Support::toJsonValue(m_programId); - result["ChannelPrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_channelPrimaryImageTag); - result["StartDate"] = Jellyfin::Support::toJsonValue(m_startDate); - result["CompletionPercentage"] = Jellyfin::Support::toJsonValue>(m_completionPercentage); - result["IsRepeat"] = Jellyfin::Support::toJsonValue>(m_isRepeat); - result["EpisodeTitle"] = Jellyfin::Support::toJsonValue(m_episodeTitle); - result["ChannelType"] = Jellyfin::Support::toJsonValue(m_channelType); - result["Audio"] = Jellyfin::Support::toJsonValue(m_audio); - result["IsMovie"] = Jellyfin::Support::toJsonValue>(m_isMovie); - result["IsSports"] = Jellyfin::Support::toJsonValue>(m_isSports); - result["IsSeries"] = Jellyfin::Support::toJsonValue>(m_isSeries); - result["IsLive"] = Jellyfin::Support::toJsonValue>(m_isLive); - result["IsNews"] = Jellyfin::Support::toJsonValue>(m_isNews); - result["IsKids"] = Jellyfin::Support::toJsonValue>(m_isKids); - result["IsPremiere"] = Jellyfin::Support::toJsonValue>(m_isPremiere); - result["TimerId"] = Jellyfin::Support::toJsonValue(m_timerId); - result["CurrentProgram"] = Jellyfin::Support::toJsonValue>(m_currentProgram); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_originalTitle.isNull())) { + result["OriginalTitle"] = Jellyfin::Support::toJsonValue(m_originalTitle); + } + + + if (!(m_serverId.isNull())) { + result["ServerId"] = Jellyfin::Support::toJsonValue(m_serverId); + } + + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + + if (!(m_etag.isNull())) { + result["Etag"] = Jellyfin::Support::toJsonValue(m_etag); + } + + + if (!(m_sourceType.isNull())) { + result["SourceType"] = Jellyfin::Support::toJsonValue(m_sourceType); + } + + + if (!(m_playlistItemId.isNull())) { + result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); + } + + + if (!(m_dateCreated.isNull())) { + result["DateCreated"] = Jellyfin::Support::toJsonValue(m_dateCreated); + } + + + if (!(m_dateLastMediaAdded.isNull())) { + result["DateLastMediaAdded"] = Jellyfin::Support::toJsonValue(m_dateLastMediaAdded); + } + + + if (!(m_extraType.isNull())) { + result["ExtraType"] = Jellyfin::Support::toJsonValue(m_extraType); + } + + + if (!(!m_airsBeforeSeasonNumber.has_value())) { + result["AirsBeforeSeasonNumber"] = Jellyfin::Support::toJsonValue>(m_airsBeforeSeasonNumber); + } + + + if (!(!m_airsAfterSeasonNumber.has_value())) { + result["AirsAfterSeasonNumber"] = Jellyfin::Support::toJsonValue>(m_airsAfterSeasonNumber); + } + + + if (!(!m_airsBeforeEpisodeNumber.has_value())) { + result["AirsBeforeEpisodeNumber"] = Jellyfin::Support::toJsonValue>(m_airsBeforeEpisodeNumber); + } + + + if (!(!m_canDelete.has_value())) { + result["CanDelete"] = Jellyfin::Support::toJsonValue>(m_canDelete); + } + + + if (!(!m_canDownload.has_value())) { + result["CanDownload"] = Jellyfin::Support::toJsonValue>(m_canDownload); + } + + + if (!(!m_hasSubtitles.has_value())) { + result["HasSubtitles"] = Jellyfin::Support::toJsonValue>(m_hasSubtitles); + } + + + if (!(m_preferredMetadataLanguage.isNull())) { + result["PreferredMetadataLanguage"] = Jellyfin::Support::toJsonValue(m_preferredMetadataLanguage); + } + + + if (!(m_preferredMetadataCountryCode.isNull())) { + result["PreferredMetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_preferredMetadataCountryCode); + } + + + if (!(!m_supportsSync.has_value())) { + result["SupportsSync"] = Jellyfin::Support::toJsonValue>(m_supportsSync); + } + + + if (!(m_container.isNull())) { + result["Container"] = Jellyfin::Support::toJsonValue(m_container); + } + + + if (!(m_sortName.isNull())) { + result["SortName"] = Jellyfin::Support::toJsonValue(m_sortName); + } + + + if (!(m_forcedSortName.isNull())) { + result["ForcedSortName"] = Jellyfin::Support::toJsonValue(m_forcedSortName); + } + + result["Video3DFormat"] = Jellyfin::Support::toJsonValue(m_video3DFormat); + + if (!(m_premiereDate.isNull())) { + result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); + } + + + if (!(m_externalUrls.size() == 0)) { + result["ExternalUrls"] = Jellyfin::Support::toJsonValue>(m_externalUrls); + } + + + if (!(m_mediaSources.size() == 0)) { + result["MediaSources"] = Jellyfin::Support::toJsonValue>(m_mediaSources); + } + + + if (!(!m_criticRating.has_value())) { + result["CriticRating"] = Jellyfin::Support::toJsonValue>(m_criticRating); + } + + + if (!(m_productionLocations.size() == 0)) { + result["ProductionLocations"] = Jellyfin::Support::toJsonValue(m_productionLocations); + } + + + if (!(m_path.isNull())) { + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + } + + + if (!(!m_enableMediaSourceDisplay.has_value())) { + result["EnableMediaSourceDisplay"] = Jellyfin::Support::toJsonValue>(m_enableMediaSourceDisplay); + } + + + if (!(m_officialRating.isNull())) { + result["OfficialRating"] = Jellyfin::Support::toJsonValue(m_officialRating); + } + + + if (!(m_customRating.isNull())) { + result["CustomRating"] = Jellyfin::Support::toJsonValue(m_customRating); + } + + + if (!(m_channelId.isNull())) { + result["ChannelId"] = Jellyfin::Support::toJsonValue(m_channelId); + } + + + if (!(m_channelName.isNull())) { + result["ChannelName"] = Jellyfin::Support::toJsonValue(m_channelName); + } + + + if (!(m_overview.isNull())) { + result["Overview"] = Jellyfin::Support::toJsonValue(m_overview); + } + + + if (!(m_taglines.size() == 0)) { + result["Taglines"] = Jellyfin::Support::toJsonValue(m_taglines); + } + + + if (!(m_genres.size() == 0)) { + result["Genres"] = Jellyfin::Support::toJsonValue(m_genres); + } + + + if (!(!m_communityRating.has_value())) { + result["CommunityRating"] = Jellyfin::Support::toJsonValue>(m_communityRating); + } + + + if (!(!m_cumulativeRunTimeTicks.has_value())) { + result["CumulativeRunTimeTicks"] = Jellyfin::Support::toJsonValue>(m_cumulativeRunTimeTicks); + } + + + if (!(!m_runTimeTicks.has_value())) { + result["RunTimeTicks"] = Jellyfin::Support::toJsonValue>(m_runTimeTicks); + } + + result["PlayAccess"] = Jellyfin::Support::toJsonValue(m_playAccess); + + if (!(m_aspectRatio.isNull())) { + result["AspectRatio"] = Jellyfin::Support::toJsonValue(m_aspectRatio); + } + + + if (!(!m_productionYear.has_value())) { + result["ProductionYear"] = Jellyfin::Support::toJsonValue>(m_productionYear); + } + + + if (!(!m_isPlaceHolder.has_value())) { + result["IsPlaceHolder"] = Jellyfin::Support::toJsonValue>(m_isPlaceHolder); + } + + + if (!(m_number.isNull())) { + result["Number"] = Jellyfin::Support::toJsonValue(m_number); + } + + + if (!(m_channelNumber.isNull())) { + result["ChannelNumber"] = Jellyfin::Support::toJsonValue(m_channelNumber); + } + + + if (!(!m_indexNumber.has_value())) { + result["IndexNumber"] = Jellyfin::Support::toJsonValue>(m_indexNumber); + } + + + if (!(!m_indexNumberEnd.has_value())) { + result["IndexNumberEnd"] = Jellyfin::Support::toJsonValue>(m_indexNumberEnd); + } + + + if (!(!m_parentIndexNumber.has_value())) { + result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue>(m_parentIndexNumber); + } + + + if (!(m_remoteTrailers.size() == 0)) { + result["RemoteTrailers"] = Jellyfin::Support::toJsonValue>(m_remoteTrailers); + } + + + if (!(m_providerIds.isEmpty())) { + result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); + } + + + if (!(!m_isHD.has_value())) { + result["IsHD"] = Jellyfin::Support::toJsonValue>(m_isHD); + } + + + if (!(!m_isFolder.has_value())) { + result["IsFolder"] = Jellyfin::Support::toJsonValue>(m_isFolder); + } + + + if (!(m_parentId.isNull())) { + result["ParentId"] = Jellyfin::Support::toJsonValue(m_parentId); + } + + + if (!(m_type.isNull())) { + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + } + + + if (!(m_people.size() == 0)) { + result["People"] = Jellyfin::Support::toJsonValue>(m_people); + } + + + if (!(m_studios.size() == 0)) { + result["Studios"] = Jellyfin::Support::toJsonValue>(m_studios); + } + + + if (!(m_genreItems.size() == 0)) { + result["GenreItems"] = Jellyfin::Support::toJsonValue>(m_genreItems); + } + + + if (!(m_parentLogoItemId.isNull())) { + result["ParentLogoItemId"] = Jellyfin::Support::toJsonValue(m_parentLogoItemId); + } + + + if (!(m_parentBackdropItemId.isNull())) { + result["ParentBackdropItemId"] = Jellyfin::Support::toJsonValue(m_parentBackdropItemId); + } + + + if (!(m_parentBackdropImageTags.size() == 0)) { + result["ParentBackdropImageTags"] = Jellyfin::Support::toJsonValue(m_parentBackdropImageTags); + } + + + if (!(!m_localTrailerCount.has_value())) { + result["LocalTrailerCount"] = Jellyfin::Support::toJsonValue>(m_localTrailerCount); + } + + result["UserData"] = Jellyfin::Support::toJsonValue>(m_userData); + + if (!(!m_recursiveItemCount.has_value())) { + result["RecursiveItemCount"] = Jellyfin::Support::toJsonValue>(m_recursiveItemCount); + } + + + if (!(!m_childCount.has_value())) { + result["ChildCount"] = Jellyfin::Support::toJsonValue>(m_childCount); + } + + + if (!(m_seriesName.isNull())) { + result["SeriesName"] = Jellyfin::Support::toJsonValue(m_seriesName); + } + + + if (!(m_seriesId.isNull())) { + result["SeriesId"] = Jellyfin::Support::toJsonValue(m_seriesId); + } + + + if (!(m_seasonId.isNull())) { + result["SeasonId"] = Jellyfin::Support::toJsonValue(m_seasonId); + } + + + if (!(!m_specialFeatureCount.has_value())) { + result["SpecialFeatureCount"] = Jellyfin::Support::toJsonValue>(m_specialFeatureCount); + } + + + if (!(m_displayPreferencesId.isNull())) { + result["DisplayPreferencesId"] = Jellyfin::Support::toJsonValue(m_displayPreferencesId); + } + + + if (!(m_status.isNull())) { + result["Status"] = Jellyfin::Support::toJsonValue(m_status); + } + + + if (!(m_airTime.isNull())) { + result["AirTime"] = Jellyfin::Support::toJsonValue(m_airTime); + } + + + if (!(m_airDays.size() == 0)) { + result["AirDays"] = Jellyfin::Support::toJsonValue>(m_airDays); + } + + + if (!(m_tags.size() == 0)) { + result["Tags"] = Jellyfin::Support::toJsonValue(m_tags); + } + + + if (!(!m_primaryImageAspectRatio.has_value())) { + result["PrimaryImageAspectRatio"] = Jellyfin::Support::toJsonValue>(m_primaryImageAspectRatio); + } + + + if (!(m_artists.size() == 0)) { + result["Artists"] = Jellyfin::Support::toJsonValue(m_artists); + } + + + if (!(m_artistItems.size() == 0)) { + result["ArtistItems"] = Jellyfin::Support::toJsonValue>(m_artistItems); + } + + + if (!(m_album.isNull())) { + result["Album"] = Jellyfin::Support::toJsonValue(m_album); + } + + + if (!(m_collectionType.isNull())) { + result["CollectionType"] = Jellyfin::Support::toJsonValue(m_collectionType); + } + + + if (!(m_displayOrder.isNull())) { + result["DisplayOrder"] = Jellyfin::Support::toJsonValue(m_displayOrder); + } + + + if (!(m_albumId.isNull())) { + result["AlbumId"] = Jellyfin::Support::toJsonValue(m_albumId); + } + + + if (!(m_albumPrimaryImageTag.isNull())) { + result["AlbumPrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_albumPrimaryImageTag); + } + + + if (!(m_seriesPrimaryImageTag.isNull())) { + result["SeriesPrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_seriesPrimaryImageTag); + } + + + if (!(m_albumArtist.isNull())) { + result["AlbumArtist"] = Jellyfin::Support::toJsonValue(m_albumArtist); + } + + + if (!(m_albumArtists.size() == 0)) { + result["AlbumArtists"] = Jellyfin::Support::toJsonValue>(m_albumArtists); + } + + + if (!(m_seasonName.isNull())) { + result["SeasonName"] = Jellyfin::Support::toJsonValue(m_seasonName); + } + + + if (!(m_mediaStreams.size() == 0)) { + result["MediaStreams"] = Jellyfin::Support::toJsonValue>(m_mediaStreams); + } + + result["VideoType"] = Jellyfin::Support::toJsonValue(m_videoType); + + if (!(!m_partCount.has_value())) { + result["PartCount"] = Jellyfin::Support::toJsonValue>(m_partCount); + } + + + if (!(!m_mediaSourceCount.has_value())) { + result["MediaSourceCount"] = Jellyfin::Support::toJsonValue>(m_mediaSourceCount); + } + + + if (!(m_imageTags.isEmpty())) { + result["ImageTags"] = Jellyfin::Support::toJsonValue(m_imageTags); + } + + + if (!(m_backdropImageTags.size() == 0)) { + result["BackdropImageTags"] = Jellyfin::Support::toJsonValue(m_backdropImageTags); + } + + + if (!(m_screenshotImageTags.size() == 0)) { + result["ScreenshotImageTags"] = Jellyfin::Support::toJsonValue(m_screenshotImageTags); + } + + + if (!(m_parentLogoImageTag.isNull())) { + result["ParentLogoImageTag"] = Jellyfin::Support::toJsonValue(m_parentLogoImageTag); + } + + + if (!(m_parentArtItemId.isNull())) { + result["ParentArtItemId"] = Jellyfin::Support::toJsonValue(m_parentArtItemId); + } + + + if (!(m_parentArtImageTag.isNull())) { + result["ParentArtImageTag"] = Jellyfin::Support::toJsonValue(m_parentArtImageTag); + } + + + if (!(m_seriesThumbImageTag.isNull())) { + result["SeriesThumbImageTag"] = Jellyfin::Support::toJsonValue(m_seriesThumbImageTag); + } + + + if (!(m_imageBlurHashes.isEmpty())) { + result["ImageBlurHashes"] = Jellyfin::Support::toJsonValue(m_imageBlurHashes); + } + + + if (!(m_seriesStudio.isNull())) { + result["SeriesStudio"] = Jellyfin::Support::toJsonValue(m_seriesStudio); + } + + + if (!(m_parentThumbItemId.isNull())) { + result["ParentThumbItemId"] = Jellyfin::Support::toJsonValue(m_parentThumbItemId); + } + + + if (!(m_parentThumbImageTag.isNull())) { + result["ParentThumbImageTag"] = Jellyfin::Support::toJsonValue(m_parentThumbImageTag); + } + + + if (!(m_parentPrimaryImageItemId.isNull())) { + result["ParentPrimaryImageItemId"] = Jellyfin::Support::toJsonValue(m_parentPrimaryImageItemId); + } + + + if (!(m_parentPrimaryImageTag.isNull())) { + result["ParentPrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_parentPrimaryImageTag); + } + + + if (!(m_chapters.size() == 0)) { + result["Chapters"] = Jellyfin::Support::toJsonValue>(m_chapters); + } + + result["LocationType"] = Jellyfin::Support::toJsonValue(m_locationType); + result["IsoType"] = Jellyfin::Support::toJsonValue(m_isoType); + + if (!(m_mediaType.isNull())) { + result["MediaType"] = Jellyfin::Support::toJsonValue(m_mediaType); + } + + + if (!(m_endDate.isNull())) { + result["EndDate"] = Jellyfin::Support::toJsonValue(m_endDate); + } + + + if (!(m_lockedFields.size() == 0)) { + result["LockedFields"] = Jellyfin::Support::toJsonValue>(m_lockedFields); + } + + + if (!(!m_trailerCount.has_value())) { + result["TrailerCount"] = Jellyfin::Support::toJsonValue>(m_trailerCount); + } + + + if (!(!m_movieCount.has_value())) { + result["MovieCount"] = Jellyfin::Support::toJsonValue>(m_movieCount); + } + + + if (!(!m_seriesCount.has_value())) { + result["SeriesCount"] = Jellyfin::Support::toJsonValue>(m_seriesCount); + } + + + if (!(!m_programCount.has_value())) { + result["ProgramCount"] = Jellyfin::Support::toJsonValue>(m_programCount); + } + + + if (!(!m_episodeCount.has_value())) { + result["EpisodeCount"] = Jellyfin::Support::toJsonValue>(m_episodeCount); + } + + + if (!(!m_songCount.has_value())) { + result["SongCount"] = Jellyfin::Support::toJsonValue>(m_songCount); + } + + + if (!(!m_albumCount.has_value())) { + result["AlbumCount"] = Jellyfin::Support::toJsonValue>(m_albumCount); + } + + + if (!(!m_artistCount.has_value())) { + result["ArtistCount"] = Jellyfin::Support::toJsonValue>(m_artistCount); + } + + + if (!(!m_musicVideoCount.has_value())) { + result["MusicVideoCount"] = Jellyfin::Support::toJsonValue>(m_musicVideoCount); + } + + + if (!(!m_lockData.has_value())) { + result["LockData"] = Jellyfin::Support::toJsonValue>(m_lockData); + } + + + if (!(!m_width.has_value())) { + result["Width"] = Jellyfin::Support::toJsonValue>(m_width); + } + + + if (!(!m_height.has_value())) { + result["Height"] = Jellyfin::Support::toJsonValue>(m_height); + } + + + if (!(m_cameraMake.isNull())) { + result["CameraMake"] = Jellyfin::Support::toJsonValue(m_cameraMake); + } + + + if (!(m_cameraModel.isNull())) { + result["CameraModel"] = Jellyfin::Support::toJsonValue(m_cameraModel); + } + + + if (!(m_software.isNull())) { + result["Software"] = Jellyfin::Support::toJsonValue(m_software); + } + + + if (!(!m_exposureTime.has_value())) { + result["ExposureTime"] = Jellyfin::Support::toJsonValue>(m_exposureTime); + } + + + if (!(!m_focalLength.has_value())) { + result["FocalLength"] = Jellyfin::Support::toJsonValue>(m_focalLength); + } + + result["ImageOrientation"] = Jellyfin::Support::toJsonValue(m_imageOrientation); + + if (!(!m_aperture.has_value())) { + result["Aperture"] = Jellyfin::Support::toJsonValue>(m_aperture); + } + + + if (!(!m_shutterSpeed.has_value())) { + result["ShutterSpeed"] = Jellyfin::Support::toJsonValue>(m_shutterSpeed); + } + + + if (!(!m_latitude.has_value())) { + result["Latitude"] = Jellyfin::Support::toJsonValue>(m_latitude); + } + + + if (!(!m_longitude.has_value())) { + result["Longitude"] = Jellyfin::Support::toJsonValue>(m_longitude); + } + + + if (!(!m_altitude.has_value())) { + result["Altitude"] = Jellyfin::Support::toJsonValue>(m_altitude); + } + + + if (!(!m_isoSpeedRating.has_value())) { + result["IsoSpeedRating"] = Jellyfin::Support::toJsonValue>(m_isoSpeedRating); + } + + + if (!(m_seriesTimerId.isNull())) { + result["SeriesTimerId"] = Jellyfin::Support::toJsonValue(m_seriesTimerId); + } + + + if (!(m_programId.isNull())) { + result["ProgramId"] = Jellyfin::Support::toJsonValue(m_programId); + } + + + if (!(m_channelPrimaryImageTag.isNull())) { + result["ChannelPrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_channelPrimaryImageTag); + } + + + if (!(m_startDate.isNull())) { + result["StartDate"] = Jellyfin::Support::toJsonValue(m_startDate); + } + + + if (!(!m_completionPercentage.has_value())) { + result["CompletionPercentage"] = Jellyfin::Support::toJsonValue>(m_completionPercentage); + } + + + if (!(!m_isRepeat.has_value())) { + result["IsRepeat"] = Jellyfin::Support::toJsonValue>(m_isRepeat); + } + + + if (!(m_episodeTitle.isNull())) { + result["EpisodeTitle"] = Jellyfin::Support::toJsonValue(m_episodeTitle); + } + + result["ChannelType"] = Jellyfin::Support::toJsonValue(m_channelType); + result["Audio"] = Jellyfin::Support::toJsonValue(m_audio); + + if (!(!m_isMovie.has_value())) { + result["IsMovie"] = Jellyfin::Support::toJsonValue>(m_isMovie); + } + + + if (!(!m_isSports.has_value())) { + result["IsSports"] = Jellyfin::Support::toJsonValue>(m_isSports); + } + + + if (!(!m_isSeries.has_value())) { + result["IsSeries"] = Jellyfin::Support::toJsonValue>(m_isSeries); + } + + + if (!(!m_isLive.has_value())) { + result["IsLive"] = Jellyfin::Support::toJsonValue>(m_isLive); + } + + + if (!(!m_isNews.has_value())) { + result["IsNews"] = Jellyfin::Support::toJsonValue>(m_isNews); + } + + + if (!(!m_isKids.has_value())) { + result["IsKids"] = Jellyfin::Support::toJsonValue>(m_isKids); + } + + + if (!(!m_isPremiere.has_value())) { + result["IsPremiere"] = Jellyfin::Support::toJsonValue>(m_isPremiere); + } + + + if (!(m_timerId.isNull())) { + result["TimerId"] = Jellyfin::Support::toJsonValue(m_timerId); + } + + result["CurrentProgram"] = Jellyfin::Support::toJsonValue>(m_currentProgram); return result; } diff --git a/core/src/dto/baseitemdtoqueryresult.cpp b/core/src/dto/baseitemdtoqueryresult.cpp index 480d155..9919a87 100644 --- a/core/src/dto/baseitemdtoqueryresult.cpp +++ b/core/src/dto/baseitemdtoqueryresult.cpp @@ -63,10 +63,14 @@ void BaseItemDtoQueryResult::setFromJson(QJsonObject source) { QJsonObject BaseItemDtoQueryResult::toJson() const { QJsonObject result; - result["Items"] = Jellyfin::Support::toJsonValue>(m_items); - result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); - result["StartIndex"] = Jellyfin::Support::toJsonValue(m_startIndex); - + + + if (!(m_items.size() == 0)) { + result["Items"] = Jellyfin::Support::toJsonValue>(m_items); + } + + result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); + result["StartIndex"] = Jellyfin::Support::toJsonValue(m_startIndex); return result; } diff --git a/core/src/dto/baseitemperson.cpp b/core/src/dto/baseitemperson.cpp index a4b294c..a838d0f 100644 --- a/core/src/dto/baseitemperson.cpp +++ b/core/src/dto/baseitemperson.cpp @@ -72,13 +72,37 @@ void BaseItemPerson::setFromJson(QJsonObject source) { QJsonObject BaseItemPerson::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["Role"] = Jellyfin::Support::toJsonValue(m_role); - result["Type"] = Jellyfin::Support::toJsonValue(m_type); - result["PrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_primaryImageTag); - result["ImageBlurHashes"] = Jellyfin::Support::toJsonValue(m_imageBlurHashes); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_jellyfinId.isNull())) { + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + } + + + if (!(m_role.isNull())) { + result["Role"] = Jellyfin::Support::toJsonValue(m_role); + } + + + if (!(m_type.isNull())) { + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + } + + + if (!(m_primaryImageTag.isNull())) { + result["PrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_primaryImageTag); + } + + + if (!(m_imageBlurHashes.isEmpty())) { + result["ImageBlurHashes"] = Jellyfin::Support::toJsonValue(m_imageBlurHashes); + } + return result; } diff --git a/core/src/dto/bookinfo.cpp b/core/src/dto/bookinfo.cpp index d3aba66..ddd9e20 100644 --- a/core/src/dto/bookinfo.cpp +++ b/core/src/dto/bookinfo.cpp @@ -87,18 +87,58 @@ void BookInfo::setFromJson(QJsonObject source) { QJsonObject BookInfo::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Path"] = Jellyfin::Support::toJsonValue(m_path); - result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); - result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); - result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); - result["Year"] = Jellyfin::Support::toJsonValue>(m_year); - result["IndexNumber"] = Jellyfin::Support::toJsonValue>(m_indexNumber); - result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue>(m_parentIndexNumber); - result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); - result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); - result["SeriesName"] = Jellyfin::Support::toJsonValue(m_seriesName); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_path.isNull())) { + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + } + + + if (!(m_metadataLanguage.isNull())) { + result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); + } + + + if (!(m_metadataCountryCode.isNull())) { + result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); + } + + + if (!(m_providerIds.isEmpty())) { + result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); + } + + + if (!(!m_year.has_value())) { + result["Year"] = Jellyfin::Support::toJsonValue>(m_year); + } + + + if (!(!m_indexNumber.has_value())) { + result["IndexNumber"] = Jellyfin::Support::toJsonValue>(m_indexNumber); + } + + + if (!(!m_parentIndexNumber.has_value())) { + result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue>(m_parentIndexNumber); + } + + + if (!(m_premiereDate.isNull())) { + result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); + } + + result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); + + if (!(m_seriesName.isNull())) { + result["SeriesName"] = Jellyfin::Support::toJsonValue(m_seriesName); + } + return result; } diff --git a/core/src/dto/bookinforemotesearchquery.cpp b/core/src/dto/bookinforemotesearchquery.cpp index aae807a..ab70513 100644 --- a/core/src/dto/bookinforemotesearchquery.cpp +++ b/core/src/dto/bookinforemotesearchquery.cpp @@ -66,11 +66,15 @@ void BookInfoRemoteSearchQuery::setFromJson(QJsonObject source) { QJsonObject BookInfoRemoteSearchQuery::toJson() const { QJsonObject result; - result["SearchInfo"] = Jellyfin::Support::toJsonValue>(m_searchInfo); - result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); - result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); - result["IncludeDisabledProviders"] = Jellyfin::Support::toJsonValue(m_includeDisabledProviders); - + + result["SearchInfo"] = Jellyfin::Support::toJsonValue>(m_searchInfo); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + + if (!(m_searchProviderName.isNull())) { + result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); + } + + result["IncludeDisabledProviders"] = Jellyfin::Support::toJsonValue(m_includeDisabledProviders); return result; } diff --git a/core/src/dto/boxsetinfo.cpp b/core/src/dto/boxsetinfo.cpp index 985e0d2..354342e 100644 --- a/core/src/dto/boxsetinfo.cpp +++ b/core/src/dto/boxsetinfo.cpp @@ -84,17 +84,53 @@ void BoxSetInfo::setFromJson(QJsonObject source) { QJsonObject BoxSetInfo::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Path"] = Jellyfin::Support::toJsonValue(m_path); - result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); - result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); - result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); - result["Year"] = Jellyfin::Support::toJsonValue>(m_year); - result["IndexNumber"] = Jellyfin::Support::toJsonValue>(m_indexNumber); - result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue>(m_parentIndexNumber); - result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); - result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_path.isNull())) { + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + } + + + if (!(m_metadataLanguage.isNull())) { + result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); + } + + + if (!(m_metadataCountryCode.isNull())) { + result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); + } + + + if (!(m_providerIds.isEmpty())) { + result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); + } + + + if (!(!m_year.has_value())) { + result["Year"] = Jellyfin::Support::toJsonValue>(m_year); + } + + + if (!(!m_indexNumber.has_value())) { + result["IndexNumber"] = Jellyfin::Support::toJsonValue>(m_indexNumber); + } + + + if (!(!m_parentIndexNumber.has_value())) { + result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue>(m_parentIndexNumber); + } + + + if (!(m_premiereDate.isNull())) { + result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); + } + + result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); return result; } diff --git a/core/src/dto/boxsetinforemotesearchquery.cpp b/core/src/dto/boxsetinforemotesearchquery.cpp index b988710..0cf4432 100644 --- a/core/src/dto/boxsetinforemotesearchquery.cpp +++ b/core/src/dto/boxsetinforemotesearchquery.cpp @@ -66,11 +66,15 @@ void BoxSetInfoRemoteSearchQuery::setFromJson(QJsonObject source) { QJsonObject BoxSetInfoRemoteSearchQuery::toJson() const { QJsonObject result; - result["SearchInfo"] = Jellyfin::Support::toJsonValue>(m_searchInfo); - result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); - result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); - result["IncludeDisabledProviders"] = Jellyfin::Support::toJsonValue(m_includeDisabledProviders); - + + result["SearchInfo"] = Jellyfin::Support::toJsonValue>(m_searchInfo); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + + if (!(m_searchProviderName.isNull())) { + result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); + } + + result["IncludeDisabledProviders"] = Jellyfin::Support::toJsonValue(m_includeDisabledProviders); return result; } diff --git a/core/src/dto/brandingoptions.cpp b/core/src/dto/brandingoptions.cpp index 7af9c7d..7a7f6b6 100644 --- a/core/src/dto/brandingoptions.cpp +++ b/core/src/dto/brandingoptions.cpp @@ -60,9 +60,17 @@ void BrandingOptions::setFromJson(QJsonObject source) { QJsonObject BrandingOptions::toJson() const { QJsonObject result; - result["LoginDisclaimer"] = Jellyfin::Support::toJsonValue(m_loginDisclaimer); - result["CustomCss"] = Jellyfin::Support::toJsonValue(m_customCss); - + + + if (!(m_loginDisclaimer.isNull())) { + result["LoginDisclaimer"] = Jellyfin::Support::toJsonValue(m_loginDisclaimer); + } + + + if (!(m_customCss.isNull())) { + result["CustomCss"] = Jellyfin::Support::toJsonValue(m_customCss); + } + return result; } diff --git a/core/src/dto/bufferrequestdto.cpp b/core/src/dto/bufferrequestdto.cpp index 6ec3237..e4363dd 100644 --- a/core/src/dto/bufferrequestdto.cpp +++ b/core/src/dto/bufferrequestdto.cpp @@ -66,11 +66,11 @@ void BufferRequestDto::setFromJson(QJsonObject source) { QJsonObject BufferRequestDto::toJson() const { QJsonObject result; - result["When"] = Jellyfin::Support::toJsonValue(m_when); - result["PositionTicks"] = Jellyfin::Support::toJsonValue(m_positionTicks); - result["IsPlaying"] = Jellyfin::Support::toJsonValue(m_isPlaying); - result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); - + + result["When"] = Jellyfin::Support::toJsonValue(m_when); + result["PositionTicks"] = Jellyfin::Support::toJsonValue(m_positionTicks); + result["IsPlaying"] = Jellyfin::Support::toJsonValue(m_isPlaying); + result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); return result; } diff --git a/core/src/dto/channelfeatures.cpp b/core/src/dto/channelfeatures.cpp index a9ad1f5..08cc3b4 100644 --- a/core/src/dto/channelfeatures.cpp +++ b/core/src/dto/channelfeatures.cpp @@ -90,19 +90,47 @@ void ChannelFeatures::setFromJson(QJsonObject source) { QJsonObject ChannelFeatures::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["CanSearch"] = Jellyfin::Support::toJsonValue(m_canSearch); - result["MediaTypes"] = Jellyfin::Support::toJsonValue>(m_mediaTypes); - result["ContentTypes"] = Jellyfin::Support::toJsonValue>(m_contentTypes); - result["MaxPageSize"] = Jellyfin::Support::toJsonValue>(m_maxPageSize); - result["AutoRefreshLevels"] = Jellyfin::Support::toJsonValue>(m_autoRefreshLevels); - result["DefaultSortFields"] = Jellyfin::Support::toJsonValue>(m_defaultSortFields); - result["SupportsSortOrderToggle"] = Jellyfin::Support::toJsonValue(m_supportsSortOrderToggle); - result["SupportsLatestMedia"] = Jellyfin::Support::toJsonValue(m_supportsLatestMedia); - result["CanFilter"] = Jellyfin::Support::toJsonValue(m_canFilter); - result["SupportsContentDownloading"] = Jellyfin::Support::toJsonValue(m_supportsContentDownloading); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_jellyfinId.isNull())) { + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + } + + result["CanSearch"] = Jellyfin::Support::toJsonValue(m_canSearch); + + if (!(m_mediaTypes.size() == 0)) { + result["MediaTypes"] = Jellyfin::Support::toJsonValue>(m_mediaTypes); + } + + + if (!(m_contentTypes.size() == 0)) { + result["ContentTypes"] = Jellyfin::Support::toJsonValue>(m_contentTypes); + } + + + if (!(!m_maxPageSize.has_value())) { + result["MaxPageSize"] = Jellyfin::Support::toJsonValue>(m_maxPageSize); + } + + + if (!(!m_autoRefreshLevels.has_value())) { + result["AutoRefreshLevels"] = Jellyfin::Support::toJsonValue>(m_autoRefreshLevels); + } + + + if (!(m_defaultSortFields.size() == 0)) { + result["DefaultSortFields"] = Jellyfin::Support::toJsonValue>(m_defaultSortFields); + } + + result["SupportsSortOrderToggle"] = Jellyfin::Support::toJsonValue(m_supportsSortOrderToggle); + result["SupportsLatestMedia"] = Jellyfin::Support::toJsonValue(m_supportsLatestMedia); + result["CanFilter"] = Jellyfin::Support::toJsonValue(m_canFilter); + result["SupportsContentDownloading"] = Jellyfin::Support::toJsonValue(m_supportsContentDownloading); return result; } diff --git a/core/src/dto/channelmappingoptionsdto.cpp b/core/src/dto/channelmappingoptionsdto.cpp index badf3d4..b248361 100644 --- a/core/src/dto/channelmappingoptionsdto.cpp +++ b/core/src/dto/channelmappingoptionsdto.cpp @@ -66,11 +66,27 @@ void ChannelMappingOptionsDto::setFromJson(QJsonObject source) { QJsonObject ChannelMappingOptionsDto::toJson() const { QJsonObject result; - result["TunerChannels"] = Jellyfin::Support::toJsonValue>(m_tunerChannels); - result["ProviderChannels"] = Jellyfin::Support::toJsonValue>(m_providerChannels); - result["Mappings"] = Jellyfin::Support::toJsonValue>(m_mappings); - result["ProviderName"] = Jellyfin::Support::toJsonValue(m_providerName); - + + + if (!(m_tunerChannels.size() == 0)) { + result["TunerChannels"] = Jellyfin::Support::toJsonValue>(m_tunerChannels); + } + + + if (!(m_providerChannels.size() == 0)) { + result["ProviderChannels"] = Jellyfin::Support::toJsonValue>(m_providerChannels); + } + + + if (!(m_mappings.size() == 0)) { + result["Mappings"] = Jellyfin::Support::toJsonValue>(m_mappings); + } + + + if (!(m_providerName.isNull())) { + result["ProviderName"] = Jellyfin::Support::toJsonValue(m_providerName); + } + return result; } diff --git a/core/src/dto/chapterinfo.cpp b/core/src/dto/chapterinfo.cpp index da84f4e..c91d80b 100644 --- a/core/src/dto/chapterinfo.cpp +++ b/core/src/dto/chapterinfo.cpp @@ -69,12 +69,24 @@ void ChapterInfo::setFromJson(QJsonObject source) { QJsonObject ChapterInfo::toJson() const { QJsonObject result; - result["StartPositionTicks"] = Jellyfin::Support::toJsonValue(m_startPositionTicks); - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["ImagePath"] = Jellyfin::Support::toJsonValue(m_imagePath); - result["ImageDateModified"] = Jellyfin::Support::toJsonValue(m_imageDateModified); - result["ImageTag"] = Jellyfin::Support::toJsonValue(m_imageTag); - + + result["StartPositionTicks"] = Jellyfin::Support::toJsonValue(m_startPositionTicks); + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_imagePath.isNull())) { + result["ImagePath"] = Jellyfin::Support::toJsonValue(m_imagePath); + } + + result["ImageDateModified"] = Jellyfin::Support::toJsonValue(m_imageDateModified); + + if (!(m_imageTag.isNull())) { + result["ImageTag"] = Jellyfin::Support::toJsonValue(m_imageTag); + } + return result; } diff --git a/core/src/dto/clientcapabilities.cpp b/core/src/dto/clientcapabilities.cpp index 57ed707..5c8d5f4 100644 --- a/core/src/dto/clientcapabilities.cpp +++ b/core/src/dto/clientcapabilities.cpp @@ -84,17 +84,37 @@ void ClientCapabilities::setFromJson(QJsonObject source) { QJsonObject ClientCapabilities::toJson() const { QJsonObject result; - result["PlayableMediaTypes"] = Jellyfin::Support::toJsonValue(m_playableMediaTypes); - result["SupportedCommands"] = Jellyfin::Support::toJsonValue>(m_supportedCommands); - result["SupportsMediaControl"] = Jellyfin::Support::toJsonValue(m_supportsMediaControl); - result["SupportsContentUploading"] = Jellyfin::Support::toJsonValue(m_supportsContentUploading); - result["MessageCallbackUrl"] = Jellyfin::Support::toJsonValue(m_messageCallbackUrl); - result["SupportsPersistentIdentifier"] = Jellyfin::Support::toJsonValue(m_supportsPersistentIdentifier); - result["SupportsSync"] = Jellyfin::Support::toJsonValue(m_supportsSync); - result["DeviceProfile"] = Jellyfin::Support::toJsonValue>(m_deviceProfile); - result["AppStoreUrl"] = Jellyfin::Support::toJsonValue(m_appStoreUrl); - result["IconUrl"] = Jellyfin::Support::toJsonValue(m_iconUrl); - + + + if (!(m_playableMediaTypes.size() == 0)) { + result["PlayableMediaTypes"] = Jellyfin::Support::toJsonValue(m_playableMediaTypes); + } + + + if (!(m_supportedCommands.size() == 0)) { + result["SupportedCommands"] = Jellyfin::Support::toJsonValue>(m_supportedCommands); + } + + result["SupportsMediaControl"] = Jellyfin::Support::toJsonValue(m_supportsMediaControl); + result["SupportsContentUploading"] = Jellyfin::Support::toJsonValue(m_supportsContentUploading); + + if (!(m_messageCallbackUrl.isNull())) { + result["MessageCallbackUrl"] = Jellyfin::Support::toJsonValue(m_messageCallbackUrl); + } + + result["SupportsPersistentIdentifier"] = Jellyfin::Support::toJsonValue(m_supportsPersistentIdentifier); + result["SupportsSync"] = Jellyfin::Support::toJsonValue(m_supportsSync); + result["DeviceProfile"] = Jellyfin::Support::toJsonValue>(m_deviceProfile); + + if (!(m_appStoreUrl.isNull())) { + result["AppStoreUrl"] = Jellyfin::Support::toJsonValue(m_appStoreUrl); + } + + + if (!(m_iconUrl.isNull())) { + result["IconUrl"] = Jellyfin::Support::toJsonValue(m_iconUrl); + } + return result; } diff --git a/core/src/dto/clientcapabilitiesdto.cpp b/core/src/dto/clientcapabilitiesdto.cpp index 9d860ef..b179c57 100644 --- a/core/src/dto/clientcapabilitiesdto.cpp +++ b/core/src/dto/clientcapabilitiesdto.cpp @@ -84,17 +84,37 @@ void ClientCapabilitiesDto::setFromJson(QJsonObject source) { QJsonObject ClientCapabilitiesDto::toJson() const { QJsonObject result; - result["PlayableMediaTypes"] = Jellyfin::Support::toJsonValue(m_playableMediaTypes); - result["SupportedCommands"] = Jellyfin::Support::toJsonValue>(m_supportedCommands); - result["SupportsMediaControl"] = Jellyfin::Support::toJsonValue(m_supportsMediaControl); - result["SupportsContentUploading"] = Jellyfin::Support::toJsonValue(m_supportsContentUploading); - result["MessageCallbackUrl"] = Jellyfin::Support::toJsonValue(m_messageCallbackUrl); - result["SupportsPersistentIdentifier"] = Jellyfin::Support::toJsonValue(m_supportsPersistentIdentifier); - result["SupportsSync"] = Jellyfin::Support::toJsonValue(m_supportsSync); - result["DeviceProfile"] = Jellyfin::Support::toJsonValue>(m_deviceProfile); - result["AppStoreUrl"] = Jellyfin::Support::toJsonValue(m_appStoreUrl); - result["IconUrl"] = Jellyfin::Support::toJsonValue(m_iconUrl); - + + + if (!(m_playableMediaTypes.size() == 0)) { + result["PlayableMediaTypes"] = Jellyfin::Support::toJsonValue(m_playableMediaTypes); + } + + + if (!(m_supportedCommands.size() == 0)) { + result["SupportedCommands"] = Jellyfin::Support::toJsonValue>(m_supportedCommands); + } + + result["SupportsMediaControl"] = Jellyfin::Support::toJsonValue(m_supportsMediaControl); + result["SupportsContentUploading"] = Jellyfin::Support::toJsonValue(m_supportsContentUploading); + + if (!(m_messageCallbackUrl.isNull())) { + result["MessageCallbackUrl"] = Jellyfin::Support::toJsonValue(m_messageCallbackUrl); + } + + result["SupportsPersistentIdentifier"] = Jellyfin::Support::toJsonValue(m_supportsPersistentIdentifier); + result["SupportsSync"] = Jellyfin::Support::toJsonValue(m_supportsSync); + result["DeviceProfile"] = Jellyfin::Support::toJsonValue>(m_deviceProfile); + + if (!(m_appStoreUrl.isNull())) { + result["AppStoreUrl"] = Jellyfin::Support::toJsonValue(m_appStoreUrl); + } + + + if (!(m_iconUrl.isNull())) { + result["IconUrl"] = Jellyfin::Support::toJsonValue(m_iconUrl); + } + return result; } diff --git a/core/src/dto/codecprofile.cpp b/core/src/dto/codecprofile.cpp index 530fc6e..6d7ed82 100644 --- a/core/src/dto/codecprofile.cpp +++ b/core/src/dto/codecprofile.cpp @@ -69,12 +69,28 @@ void CodecProfile::setFromJson(QJsonObject source) { QJsonObject CodecProfile::toJson() const { QJsonObject result; - result["Type"] = Jellyfin::Support::toJsonValue(m_type); - result["Conditions"] = Jellyfin::Support::toJsonValue>(m_conditions); - result["ApplyConditions"] = Jellyfin::Support::toJsonValue>(m_applyConditions); - result["Codec"] = Jellyfin::Support::toJsonValue(m_codec); - result["Container"] = Jellyfin::Support::toJsonValue(m_container); - + + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + + if (!(m_conditions.size() == 0)) { + result["Conditions"] = Jellyfin::Support::toJsonValue>(m_conditions); + } + + + if (!(m_applyConditions.size() == 0)) { + result["ApplyConditions"] = Jellyfin::Support::toJsonValue>(m_applyConditions); + } + + + if (!(m_codec.isNull())) { + result["Codec"] = Jellyfin::Support::toJsonValue(m_codec); + } + + + if (!(m_container.isNull())) { + result["Container"] = Jellyfin::Support::toJsonValue(m_container); + } + return result; } diff --git a/core/src/dto/collectioncreationresult.cpp b/core/src/dto/collectioncreationresult.cpp index 6169e3b..b0b0f3b 100644 --- a/core/src/dto/collectioncreationresult.cpp +++ b/core/src/dto/collectioncreationresult.cpp @@ -57,8 +57,8 @@ void CollectionCreationResult::setFromJson(QJsonObject source) { QJsonObject CollectionCreationResult::toJson() const { QJsonObject result; - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - + + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); return result; } diff --git a/core/src/dto/configurationpageinfo.cpp b/core/src/dto/configurationpageinfo.cpp index 2f105ab..7f88ba8 100644 --- a/core/src/dto/configurationpageinfo.cpp +++ b/core/src/dto/configurationpageinfo.cpp @@ -75,14 +75,34 @@ void ConfigurationPageInfo::setFromJson(QJsonObject source) { QJsonObject ConfigurationPageInfo::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["EnableInMainMenu"] = Jellyfin::Support::toJsonValue(m_enableInMainMenu); - result["MenuSection"] = Jellyfin::Support::toJsonValue(m_menuSection); - result["MenuIcon"] = Jellyfin::Support::toJsonValue(m_menuIcon); - result["DisplayName"] = Jellyfin::Support::toJsonValue(m_displayName); - result["ConfigurationPageType"] = Jellyfin::Support::toJsonValue(m_configurationPageType); - result["PluginId"] = Jellyfin::Support::toJsonValue(m_pluginId); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + result["EnableInMainMenu"] = Jellyfin::Support::toJsonValue(m_enableInMainMenu); + + if (!(m_menuSection.isNull())) { + result["MenuSection"] = Jellyfin::Support::toJsonValue(m_menuSection); + } + + + if (!(m_menuIcon.isNull())) { + result["MenuIcon"] = Jellyfin::Support::toJsonValue(m_menuIcon); + } + + + if (!(m_displayName.isNull())) { + result["DisplayName"] = Jellyfin::Support::toJsonValue(m_displayName); + } + + result["ConfigurationPageType"] = Jellyfin::Support::toJsonValue(m_configurationPageType); + + if (!(m_pluginId.isNull())) { + result["PluginId"] = Jellyfin::Support::toJsonValue(m_pluginId); + } + return result; } diff --git a/core/src/dto/containerprofile.cpp b/core/src/dto/containerprofile.cpp index 7b0de6a..c898d9d 100644 --- a/core/src/dto/containerprofile.cpp +++ b/core/src/dto/containerprofile.cpp @@ -63,10 +63,18 @@ void ContainerProfile::setFromJson(QJsonObject source) { QJsonObject ContainerProfile::toJson() const { QJsonObject result; - result["Type"] = Jellyfin::Support::toJsonValue(m_type); - result["Conditions"] = Jellyfin::Support::toJsonValue>(m_conditions); - result["Container"] = Jellyfin::Support::toJsonValue(m_container); - + + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + + if (!(m_conditions.size() == 0)) { + result["Conditions"] = Jellyfin::Support::toJsonValue>(m_conditions); + } + + + if (!(m_container.isNull())) { + result["Container"] = Jellyfin::Support::toJsonValue(m_container); + } + return result; } diff --git a/core/src/dto/controlresponse.cpp b/core/src/dto/controlresponse.cpp index 6f91ed0..73fe7bb 100644 --- a/core/src/dto/controlresponse.cpp +++ b/core/src/dto/controlresponse.cpp @@ -63,10 +63,18 @@ void ControlResponse::setFromJson(QJsonObject source) { QJsonObject ControlResponse::toJson() const { QJsonObject result; - result["Headers"] = Jellyfin::Support::toJsonValue(m_headers); - result["Xml"] = Jellyfin::Support::toJsonValue(m_xml); - result["IsSuccessful"] = Jellyfin::Support::toJsonValue(m_isSuccessful); - + + + if (!(m_headers.isEmpty())) { + result["Headers"] = Jellyfin::Support::toJsonValue(m_headers); + } + + + if (!(m_xml.isNull())) { + result["Xml"] = Jellyfin::Support::toJsonValue(m_xml); + } + + result["IsSuccessful"] = Jellyfin::Support::toJsonValue(m_isSuccessful); return result; } diff --git a/core/src/dto/countryinfo.cpp b/core/src/dto/countryinfo.cpp index c3f349a..3ffad34 100644 --- a/core/src/dto/countryinfo.cpp +++ b/core/src/dto/countryinfo.cpp @@ -66,11 +66,27 @@ void CountryInfo::setFromJson(QJsonObject source) { QJsonObject CountryInfo::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["DisplayName"] = Jellyfin::Support::toJsonValue(m_displayName); - result["TwoLetterISORegionName"] = Jellyfin::Support::toJsonValue(m_twoLetterISORegionName); - result["ThreeLetterISORegionName"] = Jellyfin::Support::toJsonValue(m_threeLetterISORegionName); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_displayName.isNull())) { + result["DisplayName"] = Jellyfin::Support::toJsonValue(m_displayName); + } + + + if (!(m_twoLetterISORegionName.isNull())) { + result["TwoLetterISORegionName"] = Jellyfin::Support::toJsonValue(m_twoLetterISORegionName); + } + + + if (!(m_threeLetterISORegionName.isNull())) { + result["ThreeLetterISORegionName"] = Jellyfin::Support::toJsonValue(m_threeLetterISORegionName); + } + return result; } diff --git a/core/src/dto/createplaylistdto.cpp b/core/src/dto/createplaylistdto.cpp index 0cf76a0..c4e611f 100644 --- a/core/src/dto/createplaylistdto.cpp +++ b/core/src/dto/createplaylistdto.cpp @@ -66,11 +66,27 @@ void CreatePlaylistDto::setFromJson(QJsonObject source) { QJsonObject CreatePlaylistDto::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Ids"] = Jellyfin::Support::toJsonValue(m_ids); - result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); - result["MediaType"] = Jellyfin::Support::toJsonValue(m_mediaType); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_ids.size() == 0)) { + result["Ids"] = Jellyfin::Support::toJsonValue(m_ids); + } + + + if (!(m_userId.isNull())) { + result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); + } + + + if (!(m_mediaType.isNull())) { + result["MediaType"] = Jellyfin::Support::toJsonValue(m_mediaType); + } + return result; } diff --git a/core/src/dto/createuserbyname.cpp b/core/src/dto/createuserbyname.cpp index e3d3b0c..d4074bb 100644 --- a/core/src/dto/createuserbyname.cpp +++ b/core/src/dto/createuserbyname.cpp @@ -60,9 +60,17 @@ void CreateUserByName::setFromJson(QJsonObject source) { QJsonObject CreateUserByName::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Password"] = Jellyfin::Support::toJsonValue(m_password); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_password.isNull())) { + result["Password"] = Jellyfin::Support::toJsonValue(m_password); + } + return result; } diff --git a/core/src/dto/culturedto.cpp b/core/src/dto/culturedto.cpp index 530556d..469e48f 100644 --- a/core/src/dto/culturedto.cpp +++ b/core/src/dto/culturedto.cpp @@ -69,12 +69,32 @@ void CultureDto::setFromJson(QJsonObject source) { QJsonObject CultureDto::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["DisplayName"] = Jellyfin::Support::toJsonValue(m_displayName); - result["TwoLetterISOLanguageName"] = Jellyfin::Support::toJsonValue(m_twoLetterISOLanguageName); - result["ThreeLetterISOLanguageName"] = Jellyfin::Support::toJsonValue(m_threeLetterISOLanguageName); - result["ThreeLetterISOLanguageNames"] = Jellyfin::Support::toJsonValue(m_threeLetterISOLanguageNames); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_displayName.isNull())) { + result["DisplayName"] = Jellyfin::Support::toJsonValue(m_displayName); + } + + + if (!(m_twoLetterISOLanguageName.isNull())) { + result["TwoLetterISOLanguageName"] = Jellyfin::Support::toJsonValue(m_twoLetterISOLanguageName); + } + + + if (!(m_threeLetterISOLanguageName.isNull())) { + result["ThreeLetterISOLanguageName"] = Jellyfin::Support::toJsonValue(m_threeLetterISOLanguageName); + } + + + if (!(m_threeLetterISOLanguageNames.size() == 0)) { + result["ThreeLetterISOLanguageNames"] = Jellyfin::Support::toJsonValue(m_threeLetterISOLanguageNames); + } + return result; } diff --git a/core/src/dto/defaultdirectorybrowserinfodto.cpp b/core/src/dto/defaultdirectorybrowserinfodto.cpp index 4c32b2f..16d7243 100644 --- a/core/src/dto/defaultdirectorybrowserinfodto.cpp +++ b/core/src/dto/defaultdirectorybrowserinfodto.cpp @@ -57,8 +57,12 @@ void DefaultDirectoryBrowserInfoDto::setFromJson(QJsonObject source) { QJsonObject DefaultDirectoryBrowserInfoDto::toJson() const { QJsonObject result; - result["Path"] = Jellyfin::Support::toJsonValue(m_path); - + + + if (!(m_path.isNull())) { + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + } + return result; } diff --git a/core/src/dto/deviceidentification.cpp b/core/src/dto/deviceidentification.cpp index 5b20d2e..a3bf50e 100644 --- a/core/src/dto/deviceidentification.cpp +++ b/core/src/dto/deviceidentification.cpp @@ -81,16 +81,52 @@ void DeviceIdentification::setFromJson(QJsonObject source) { QJsonObject DeviceIdentification::toJson() const { QJsonObject result; - result["FriendlyName"] = Jellyfin::Support::toJsonValue(m_friendlyName); - result["ModelNumber"] = Jellyfin::Support::toJsonValue(m_modelNumber); - result["SerialNumber"] = Jellyfin::Support::toJsonValue(m_serialNumber); - result["ModelName"] = Jellyfin::Support::toJsonValue(m_modelName); - result["ModelDescription"] = Jellyfin::Support::toJsonValue(m_modelDescription); - result["ModelUrl"] = Jellyfin::Support::toJsonValue(m_modelUrl); - result["Manufacturer"] = Jellyfin::Support::toJsonValue(m_manufacturer); - result["ManufacturerUrl"] = Jellyfin::Support::toJsonValue(m_manufacturerUrl); - result["Headers"] = Jellyfin::Support::toJsonValue>(m_headers); - + + + if (!(m_friendlyName.isNull())) { + result["FriendlyName"] = Jellyfin::Support::toJsonValue(m_friendlyName); + } + + + if (!(m_modelNumber.isNull())) { + result["ModelNumber"] = Jellyfin::Support::toJsonValue(m_modelNumber); + } + + + if (!(m_serialNumber.isNull())) { + result["SerialNumber"] = Jellyfin::Support::toJsonValue(m_serialNumber); + } + + + if (!(m_modelName.isNull())) { + result["ModelName"] = Jellyfin::Support::toJsonValue(m_modelName); + } + + + if (!(m_modelDescription.isNull())) { + result["ModelDescription"] = Jellyfin::Support::toJsonValue(m_modelDescription); + } + + + if (!(m_modelUrl.isNull())) { + result["ModelUrl"] = Jellyfin::Support::toJsonValue(m_modelUrl); + } + + + if (!(m_manufacturer.isNull())) { + result["Manufacturer"] = Jellyfin::Support::toJsonValue(m_manufacturer); + } + + + if (!(m_manufacturerUrl.isNull())) { + result["ManufacturerUrl"] = Jellyfin::Support::toJsonValue(m_manufacturerUrl); + } + + + if (!(m_headers.size() == 0)) { + result["Headers"] = Jellyfin::Support::toJsonValue>(m_headers); + } + return result; } diff --git a/core/src/dto/deviceinfo.cpp b/core/src/dto/deviceinfo.cpp index 34a6c09..e7cc4fb 100644 --- a/core/src/dto/deviceinfo.cpp +++ b/core/src/dto/deviceinfo.cpp @@ -81,16 +81,40 @@ void DeviceInfo::setFromJson(QJsonObject source) { QJsonObject DeviceInfo::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["LastUserName"] = Jellyfin::Support::toJsonValue(m_lastUserName); - result["AppName"] = Jellyfin::Support::toJsonValue(m_appName); - result["AppVersion"] = Jellyfin::Support::toJsonValue(m_appVersion); - result["LastUserId"] = Jellyfin::Support::toJsonValue(m_lastUserId); - result["DateLastActivity"] = Jellyfin::Support::toJsonValue(m_dateLastActivity); - result["Capabilities"] = Jellyfin::Support::toJsonValue>(m_capabilities); - result["IconUrl"] = Jellyfin::Support::toJsonValue(m_iconUrl); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_jellyfinId.isNull())) { + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + } + + + if (!(m_lastUserName.isNull())) { + result["LastUserName"] = Jellyfin::Support::toJsonValue(m_lastUserName); + } + + + if (!(m_appName.isNull())) { + result["AppName"] = Jellyfin::Support::toJsonValue(m_appName); + } + + + if (!(m_appVersion.isNull())) { + result["AppVersion"] = Jellyfin::Support::toJsonValue(m_appVersion); + } + + result["LastUserId"] = Jellyfin::Support::toJsonValue(m_lastUserId); + result["DateLastActivity"] = Jellyfin::Support::toJsonValue(m_dateLastActivity); + result["Capabilities"] = Jellyfin::Support::toJsonValue>(m_capabilities); + + if (!(m_iconUrl.isNull())) { + result["IconUrl"] = Jellyfin::Support::toJsonValue(m_iconUrl); + } + return result; } diff --git a/core/src/dto/deviceinfoqueryresult.cpp b/core/src/dto/deviceinfoqueryresult.cpp index 5c23812..3440003 100644 --- a/core/src/dto/deviceinfoqueryresult.cpp +++ b/core/src/dto/deviceinfoqueryresult.cpp @@ -63,10 +63,14 @@ void DeviceInfoQueryResult::setFromJson(QJsonObject source) { QJsonObject DeviceInfoQueryResult::toJson() const { QJsonObject result; - result["Items"] = Jellyfin::Support::toJsonValue>(m_items); - result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); - result["StartIndex"] = Jellyfin::Support::toJsonValue(m_startIndex); - + + + if (!(m_items.size() == 0)) { + result["Items"] = Jellyfin::Support::toJsonValue>(m_items); + } + + result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); + result["StartIndex"] = Jellyfin::Support::toJsonValue(m_startIndex); return result; } diff --git a/core/src/dto/deviceoptions.cpp b/core/src/dto/deviceoptions.cpp index ef94c04..4238131 100644 --- a/core/src/dto/deviceoptions.cpp +++ b/core/src/dto/deviceoptions.cpp @@ -57,8 +57,12 @@ void DeviceOptions::setFromJson(QJsonObject source) { QJsonObject DeviceOptions::toJson() const { QJsonObject result; - result["CustomName"] = Jellyfin::Support::toJsonValue(m_customName); - + + + if (!(m_customName.isNull())) { + result["CustomName"] = Jellyfin::Support::toJsonValue(m_customName); + } + return result; } diff --git a/core/src/dto/deviceprofile.cpp b/core/src/dto/deviceprofile.cpp index a456ac8..aa668da 100644 --- a/core/src/dto/deviceprofile.cpp +++ b/core/src/dto/deviceprofile.cpp @@ -171,46 +171,158 @@ void DeviceProfile::setFromJson(QJsonObject source) { QJsonObject DeviceProfile::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["Identification"] = Jellyfin::Support::toJsonValue>(m_identification); - result["FriendlyName"] = Jellyfin::Support::toJsonValue(m_friendlyName); - result["Manufacturer"] = Jellyfin::Support::toJsonValue(m_manufacturer); - result["ManufacturerUrl"] = Jellyfin::Support::toJsonValue(m_manufacturerUrl); - result["ModelName"] = Jellyfin::Support::toJsonValue(m_modelName); - result["ModelDescription"] = Jellyfin::Support::toJsonValue(m_modelDescription); - result["ModelNumber"] = Jellyfin::Support::toJsonValue(m_modelNumber); - result["ModelUrl"] = Jellyfin::Support::toJsonValue(m_modelUrl); - result["SerialNumber"] = Jellyfin::Support::toJsonValue(m_serialNumber); - result["EnableAlbumArtInDidl"] = Jellyfin::Support::toJsonValue(m_enableAlbumArtInDidl); - result["EnableSingleAlbumArtLimit"] = Jellyfin::Support::toJsonValue(m_enableSingleAlbumArtLimit); - result["EnableSingleSubtitleLimit"] = Jellyfin::Support::toJsonValue(m_enableSingleSubtitleLimit); - result["SupportedMediaTypes"] = Jellyfin::Support::toJsonValue(m_supportedMediaTypes); - result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); - result["AlbumArtPn"] = Jellyfin::Support::toJsonValue(m_albumArtPn); - result["MaxAlbumArtWidth"] = Jellyfin::Support::toJsonValue(m_maxAlbumArtWidth); - result["MaxAlbumArtHeight"] = Jellyfin::Support::toJsonValue(m_maxAlbumArtHeight); - result["MaxIconWidth"] = Jellyfin::Support::toJsonValue>(m_maxIconWidth); - result["MaxIconHeight"] = Jellyfin::Support::toJsonValue>(m_maxIconHeight); - result["MaxStreamingBitrate"] = Jellyfin::Support::toJsonValue>(m_maxStreamingBitrate); - result["MaxStaticBitrate"] = Jellyfin::Support::toJsonValue>(m_maxStaticBitrate); - result["MusicStreamingTranscodingBitrate"] = Jellyfin::Support::toJsonValue>(m_musicStreamingTranscodingBitrate); - result["MaxStaticMusicBitrate"] = Jellyfin::Support::toJsonValue>(m_maxStaticMusicBitrate); - result["SonyAggregationFlags"] = Jellyfin::Support::toJsonValue(m_sonyAggregationFlags); - result["ProtocolInfo"] = Jellyfin::Support::toJsonValue(m_protocolInfo); - result["TimelineOffsetSeconds"] = Jellyfin::Support::toJsonValue(m_timelineOffsetSeconds); - result["RequiresPlainVideoItems"] = Jellyfin::Support::toJsonValue(m_requiresPlainVideoItems); - result["RequiresPlainFolders"] = Jellyfin::Support::toJsonValue(m_requiresPlainFolders); - result["EnableMSMediaReceiverRegistrar"] = Jellyfin::Support::toJsonValue(m_enableMSMediaReceiverRegistrar); - result["IgnoreTranscodeByteRangeRequests"] = Jellyfin::Support::toJsonValue(m_ignoreTranscodeByteRangeRequests); - result["XmlRootAttributes"] = Jellyfin::Support::toJsonValue>(m_xmlRootAttributes); - result["DirectPlayProfiles"] = Jellyfin::Support::toJsonValue>(m_directPlayProfiles); - result["TranscodingProfiles"] = Jellyfin::Support::toJsonValue>(m_transcodingProfiles); - result["ContainerProfiles"] = Jellyfin::Support::toJsonValue>(m_containerProfiles); - result["CodecProfiles"] = Jellyfin::Support::toJsonValue>(m_codecProfiles); - result["ResponseProfiles"] = Jellyfin::Support::toJsonValue>(m_responseProfiles); - result["SubtitleProfiles"] = Jellyfin::Support::toJsonValue>(m_subtitleProfiles); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_jellyfinId.isNull())) { + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + } + + result["Identification"] = Jellyfin::Support::toJsonValue>(m_identification); + + if (!(m_friendlyName.isNull())) { + result["FriendlyName"] = Jellyfin::Support::toJsonValue(m_friendlyName); + } + + + if (!(m_manufacturer.isNull())) { + result["Manufacturer"] = Jellyfin::Support::toJsonValue(m_manufacturer); + } + + + if (!(m_manufacturerUrl.isNull())) { + result["ManufacturerUrl"] = Jellyfin::Support::toJsonValue(m_manufacturerUrl); + } + + + if (!(m_modelName.isNull())) { + result["ModelName"] = Jellyfin::Support::toJsonValue(m_modelName); + } + + + if (!(m_modelDescription.isNull())) { + result["ModelDescription"] = Jellyfin::Support::toJsonValue(m_modelDescription); + } + + + if (!(m_modelNumber.isNull())) { + result["ModelNumber"] = Jellyfin::Support::toJsonValue(m_modelNumber); + } + + + if (!(m_modelUrl.isNull())) { + result["ModelUrl"] = Jellyfin::Support::toJsonValue(m_modelUrl); + } + + + if (!(m_serialNumber.isNull())) { + result["SerialNumber"] = Jellyfin::Support::toJsonValue(m_serialNumber); + } + + result["EnableAlbumArtInDidl"] = Jellyfin::Support::toJsonValue(m_enableAlbumArtInDidl); + result["EnableSingleAlbumArtLimit"] = Jellyfin::Support::toJsonValue(m_enableSingleAlbumArtLimit); + result["EnableSingleSubtitleLimit"] = Jellyfin::Support::toJsonValue(m_enableSingleSubtitleLimit); + + if (!(m_supportedMediaTypes.isNull())) { + result["SupportedMediaTypes"] = Jellyfin::Support::toJsonValue(m_supportedMediaTypes); + } + + + if (!(m_userId.isNull())) { + result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); + } + + + if (!(m_albumArtPn.isNull())) { + result["AlbumArtPn"] = Jellyfin::Support::toJsonValue(m_albumArtPn); + } + + result["MaxAlbumArtWidth"] = Jellyfin::Support::toJsonValue(m_maxAlbumArtWidth); + result["MaxAlbumArtHeight"] = Jellyfin::Support::toJsonValue(m_maxAlbumArtHeight); + + if (!(!m_maxIconWidth.has_value())) { + result["MaxIconWidth"] = Jellyfin::Support::toJsonValue>(m_maxIconWidth); + } + + + if (!(!m_maxIconHeight.has_value())) { + result["MaxIconHeight"] = Jellyfin::Support::toJsonValue>(m_maxIconHeight); + } + + + if (!(!m_maxStreamingBitrate.has_value())) { + result["MaxStreamingBitrate"] = Jellyfin::Support::toJsonValue>(m_maxStreamingBitrate); + } + + + if (!(!m_maxStaticBitrate.has_value())) { + result["MaxStaticBitrate"] = Jellyfin::Support::toJsonValue>(m_maxStaticBitrate); + } + + + if (!(!m_musicStreamingTranscodingBitrate.has_value())) { + result["MusicStreamingTranscodingBitrate"] = Jellyfin::Support::toJsonValue>(m_musicStreamingTranscodingBitrate); + } + + + if (!(!m_maxStaticMusicBitrate.has_value())) { + result["MaxStaticMusicBitrate"] = Jellyfin::Support::toJsonValue>(m_maxStaticMusicBitrate); + } + + + if (!(m_sonyAggregationFlags.isNull())) { + result["SonyAggregationFlags"] = Jellyfin::Support::toJsonValue(m_sonyAggregationFlags); + } + + + if (!(m_protocolInfo.isNull())) { + result["ProtocolInfo"] = Jellyfin::Support::toJsonValue(m_protocolInfo); + } + + result["TimelineOffsetSeconds"] = Jellyfin::Support::toJsonValue(m_timelineOffsetSeconds); + result["RequiresPlainVideoItems"] = Jellyfin::Support::toJsonValue(m_requiresPlainVideoItems); + result["RequiresPlainFolders"] = Jellyfin::Support::toJsonValue(m_requiresPlainFolders); + result["EnableMSMediaReceiverRegistrar"] = Jellyfin::Support::toJsonValue(m_enableMSMediaReceiverRegistrar); + result["IgnoreTranscodeByteRangeRequests"] = Jellyfin::Support::toJsonValue(m_ignoreTranscodeByteRangeRequests); + + if (!(m_xmlRootAttributes.size() == 0)) { + result["XmlRootAttributes"] = Jellyfin::Support::toJsonValue>(m_xmlRootAttributes); + } + + + if (!(m_directPlayProfiles.size() == 0)) { + result["DirectPlayProfiles"] = Jellyfin::Support::toJsonValue>(m_directPlayProfiles); + } + + + if (!(m_transcodingProfiles.size() == 0)) { + result["TranscodingProfiles"] = Jellyfin::Support::toJsonValue>(m_transcodingProfiles); + } + + + if (!(m_containerProfiles.size() == 0)) { + result["ContainerProfiles"] = Jellyfin::Support::toJsonValue>(m_containerProfiles); + } + + + if (!(m_codecProfiles.size() == 0)) { + result["CodecProfiles"] = Jellyfin::Support::toJsonValue>(m_codecProfiles); + } + + + if (!(m_responseProfiles.size() == 0)) { + result["ResponseProfiles"] = Jellyfin::Support::toJsonValue>(m_responseProfiles); + } + + + if (!(m_subtitleProfiles.size() == 0)) { + result["SubtitleProfiles"] = Jellyfin::Support::toJsonValue>(m_subtitleProfiles); + } + return result; } diff --git a/core/src/dto/deviceprofileinfo.cpp b/core/src/dto/deviceprofileinfo.cpp index 6587e42..4ba0884 100644 --- a/core/src/dto/deviceprofileinfo.cpp +++ b/core/src/dto/deviceprofileinfo.cpp @@ -63,10 +63,18 @@ void DeviceProfileInfo::setFromJson(QJsonObject source) { QJsonObject DeviceProfileInfo::toJson() const { QJsonObject result; - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Type"] = Jellyfin::Support::toJsonValue(m_type); - + + + if (!(m_jellyfinId.isNull())) { + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + } + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + result["Type"] = Jellyfin::Support::toJsonValue(m_type); return result; } diff --git a/core/src/dto/directplayprofile.cpp b/core/src/dto/directplayprofile.cpp index 472e2eb..af33e29 100644 --- a/core/src/dto/directplayprofile.cpp +++ b/core/src/dto/directplayprofile.cpp @@ -66,11 +66,23 @@ void DirectPlayProfile::setFromJson(QJsonObject source) { QJsonObject DirectPlayProfile::toJson() const { QJsonObject result; - result["Container"] = Jellyfin::Support::toJsonValue(m_container); - result["AudioCodec"] = Jellyfin::Support::toJsonValue(m_audioCodec); - result["VideoCodec"] = Jellyfin::Support::toJsonValue(m_videoCodec); - result["Type"] = Jellyfin::Support::toJsonValue(m_type); - + + + if (!(m_container.isNull())) { + result["Container"] = Jellyfin::Support::toJsonValue(m_container); + } + + + if (!(m_audioCodec.isNull())) { + result["AudioCodec"] = Jellyfin::Support::toJsonValue(m_audioCodec); + } + + + if (!(m_videoCodec.isNull())) { + result["VideoCodec"] = Jellyfin::Support::toJsonValue(m_videoCodec); + } + + result["Type"] = Jellyfin::Support::toJsonValue(m_type); return result; } diff --git a/core/src/dto/displaypreferencesdto.cpp b/core/src/dto/displaypreferencesdto.cpp index 82afdc3..f987cd6 100644 --- a/core/src/dto/displaypreferencesdto.cpp +++ b/core/src/dto/displaypreferencesdto.cpp @@ -96,21 +96,45 @@ void DisplayPreferencesDto::setFromJson(QJsonObject source) { QJsonObject DisplayPreferencesDto::toJson() const { QJsonObject result; - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["ViewType"] = Jellyfin::Support::toJsonValue(m_viewType); - result["SortBy"] = Jellyfin::Support::toJsonValue(m_sortBy); - result["IndexBy"] = Jellyfin::Support::toJsonValue(m_indexBy); - result["RememberIndexing"] = Jellyfin::Support::toJsonValue(m_rememberIndexing); - result["PrimaryImageHeight"] = Jellyfin::Support::toJsonValue(m_primaryImageHeight); - result["PrimaryImageWidth"] = Jellyfin::Support::toJsonValue(m_primaryImageWidth); - result["CustomPrefs"] = Jellyfin::Support::toJsonValue(m_customPrefs); - result["ScrollDirection"] = Jellyfin::Support::toJsonValue(m_scrollDirection); - result["ShowBackdrop"] = Jellyfin::Support::toJsonValue(m_showBackdrop); - result["RememberSorting"] = Jellyfin::Support::toJsonValue(m_rememberSorting); - result["SortOrder"] = Jellyfin::Support::toJsonValue(m_sortOrder); - result["ShowSidebar"] = Jellyfin::Support::toJsonValue(m_showSidebar); - result["Client"] = Jellyfin::Support::toJsonValue(m_client); - + + + if (!(m_jellyfinId.isNull())) { + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + } + + + if (!(m_viewType.isNull())) { + result["ViewType"] = Jellyfin::Support::toJsonValue(m_viewType); + } + + + if (!(m_sortBy.isNull())) { + result["SortBy"] = Jellyfin::Support::toJsonValue(m_sortBy); + } + + + if (!(m_indexBy.isNull())) { + result["IndexBy"] = Jellyfin::Support::toJsonValue(m_indexBy); + } + + result["RememberIndexing"] = Jellyfin::Support::toJsonValue(m_rememberIndexing); + result["PrimaryImageHeight"] = Jellyfin::Support::toJsonValue(m_primaryImageHeight); + result["PrimaryImageWidth"] = Jellyfin::Support::toJsonValue(m_primaryImageWidth); + + if (!(m_customPrefs.isEmpty())) { + result["CustomPrefs"] = Jellyfin::Support::toJsonValue(m_customPrefs); + } + + result["ScrollDirection"] = Jellyfin::Support::toJsonValue(m_scrollDirection); + result["ShowBackdrop"] = Jellyfin::Support::toJsonValue(m_showBackdrop); + result["RememberSorting"] = Jellyfin::Support::toJsonValue(m_rememberSorting); + result["SortOrder"] = Jellyfin::Support::toJsonValue(m_sortOrder); + result["ShowSidebar"] = Jellyfin::Support::toJsonValue(m_showSidebar); + + if (!(m_client.isNull())) { + result["Client"] = Jellyfin::Support::toJsonValue(m_client); + } + return result; } diff --git a/core/src/dto/endpointinfo.cpp b/core/src/dto/endpointinfo.cpp index 8c392bb..7086a84 100644 --- a/core/src/dto/endpointinfo.cpp +++ b/core/src/dto/endpointinfo.cpp @@ -60,9 +60,9 @@ void EndPointInfo::setFromJson(QJsonObject source) { QJsonObject EndPointInfo::toJson() const { QJsonObject result; - result["IsLocal"] = Jellyfin::Support::toJsonValue(m_isLocal); - result["IsInNetwork"] = Jellyfin::Support::toJsonValue(m_isInNetwork); - + + result["IsLocal"] = Jellyfin::Support::toJsonValue(m_isLocal); + result["IsInNetwork"] = Jellyfin::Support::toJsonValue(m_isInNetwork); return result; } diff --git a/core/src/dto/externalidinfo.cpp b/core/src/dto/externalidinfo.cpp index 1f3b8fb..98cdf29 100644 --- a/core/src/dto/externalidinfo.cpp +++ b/core/src/dto/externalidinfo.cpp @@ -66,11 +66,23 @@ void ExternalIdInfo::setFromJson(QJsonObject source) { QJsonObject ExternalIdInfo::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Key"] = Jellyfin::Support::toJsonValue(m_key); - result["Type"] = Jellyfin::Support::toJsonValue(m_type); - result["UrlFormatString"] = Jellyfin::Support::toJsonValue(m_urlFormatString); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_key.isNull())) { + result["Key"] = Jellyfin::Support::toJsonValue(m_key); + } + + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + + if (!(m_urlFormatString.isNull())) { + result["UrlFormatString"] = Jellyfin::Support::toJsonValue(m_urlFormatString); + } + return result; } diff --git a/core/src/dto/externalurl.cpp b/core/src/dto/externalurl.cpp index 7840d2b..7d7cc20 100644 --- a/core/src/dto/externalurl.cpp +++ b/core/src/dto/externalurl.cpp @@ -60,9 +60,17 @@ void ExternalUrl::setFromJson(QJsonObject source) { QJsonObject ExternalUrl::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Url"] = Jellyfin::Support::toJsonValue(m_url); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_url.isNull())) { + result["Url"] = Jellyfin::Support::toJsonValue(m_url); + } + return result; } diff --git a/core/src/dto/filesystementryinfo.cpp b/core/src/dto/filesystementryinfo.cpp index a904612..7304a6a 100644 --- a/core/src/dto/filesystementryinfo.cpp +++ b/core/src/dto/filesystementryinfo.cpp @@ -63,10 +63,18 @@ void FileSystemEntryInfo::setFromJson(QJsonObject source) { QJsonObject FileSystemEntryInfo::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Path"] = Jellyfin::Support::toJsonValue(m_path); - result["Type"] = Jellyfin::Support::toJsonValue(m_type); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_path.isNull())) { + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + } + + result["Type"] = Jellyfin::Support::toJsonValue(m_type); return result; } diff --git a/core/src/dto/fontfile.cpp b/core/src/dto/fontfile.cpp index 8811d70..3ca5ef4 100644 --- a/core/src/dto/fontfile.cpp +++ b/core/src/dto/fontfile.cpp @@ -66,11 +66,15 @@ void FontFile::setFromJson(QJsonObject source) { QJsonObject FontFile::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Size"] = Jellyfin::Support::toJsonValue(m_size); - result["DateCreated"] = Jellyfin::Support::toJsonValue(m_dateCreated); - result["DateModified"] = Jellyfin::Support::toJsonValue(m_dateModified); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + result["Size"] = Jellyfin::Support::toJsonValue(m_size); + result["DateCreated"] = Jellyfin::Support::toJsonValue(m_dateCreated); + result["DateModified"] = Jellyfin::Support::toJsonValue(m_dateModified); return result; } diff --git a/core/src/dto/forgotpassworddto.cpp b/core/src/dto/forgotpassworddto.cpp index 4fb7cbc..e424725 100644 --- a/core/src/dto/forgotpassworddto.cpp +++ b/core/src/dto/forgotpassworddto.cpp @@ -57,8 +57,8 @@ void ForgotPasswordDto::setFromJson(QJsonObject source) { QJsonObject ForgotPasswordDto::toJson() const { QJsonObject result; - result["EnteredUsername"] = Jellyfin::Support::toJsonValue(m_enteredUsername); - + + result["EnteredUsername"] = Jellyfin::Support::toJsonValue(m_enteredUsername); return result; } diff --git a/core/src/dto/forgotpasswordresult.cpp b/core/src/dto/forgotpasswordresult.cpp index 32737a1..f7defd3 100644 --- a/core/src/dto/forgotpasswordresult.cpp +++ b/core/src/dto/forgotpasswordresult.cpp @@ -63,10 +63,18 @@ void ForgotPasswordResult::setFromJson(QJsonObject source) { QJsonObject ForgotPasswordResult::toJson() const { QJsonObject result; - result["Action"] = Jellyfin::Support::toJsonValue(m_action); - result["PinFile"] = Jellyfin::Support::toJsonValue(m_pinFile); - result["PinExpirationDate"] = Jellyfin::Support::toJsonValue(m_pinExpirationDate); - + + result["Action"] = Jellyfin::Support::toJsonValue(m_action); + + if (!(m_pinFile.isNull())) { + result["PinFile"] = Jellyfin::Support::toJsonValue(m_pinFile); + } + + + if (!(m_pinExpirationDate.isNull())) { + result["PinExpirationDate"] = Jellyfin::Support::toJsonValue(m_pinExpirationDate); + } + return result; } diff --git a/core/src/dto/generalcommand.cpp b/core/src/dto/generalcommand.cpp index 05dfada..97f4da3 100644 --- a/core/src/dto/generalcommand.cpp +++ b/core/src/dto/generalcommand.cpp @@ -63,10 +63,14 @@ void GeneralCommand::setFromJson(QJsonObject source) { QJsonObject GeneralCommand::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["ControllingUserId"] = Jellyfin::Support::toJsonValue(m_controllingUserId); - result["Arguments"] = Jellyfin::Support::toJsonValue(m_arguments); - + + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["ControllingUserId"] = Jellyfin::Support::toJsonValue(m_controllingUserId); + + if (!(m_arguments.isEmpty())) { + result["Arguments"] = Jellyfin::Support::toJsonValue(m_arguments); + } + return result; } diff --git a/core/src/dto/getprogramsdto.cpp b/core/src/dto/getprogramsdto.cpp index b72ab61..24fcb7f 100644 --- a/core/src/dto/getprogramsdto.cpp +++ b/core/src/dto/getprogramsdto.cpp @@ -135,34 +135,130 @@ void GetProgramsDto::setFromJson(QJsonObject source) { QJsonObject GetProgramsDto::toJson() const { QJsonObject result; - result["ChannelIds"] = Jellyfin::Support::toJsonValue(m_channelIds); - result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); - result["MinStartDate"] = Jellyfin::Support::toJsonValue(m_minStartDate); - result["HasAired"] = Jellyfin::Support::toJsonValue>(m_hasAired); - result["IsAiring"] = Jellyfin::Support::toJsonValue>(m_isAiring); - result["MaxStartDate"] = Jellyfin::Support::toJsonValue(m_maxStartDate); - result["MinEndDate"] = Jellyfin::Support::toJsonValue(m_minEndDate); - result["MaxEndDate"] = Jellyfin::Support::toJsonValue(m_maxEndDate); - result["IsMovie"] = Jellyfin::Support::toJsonValue>(m_isMovie); - result["IsSeries"] = Jellyfin::Support::toJsonValue>(m_isSeries); - result["IsNews"] = Jellyfin::Support::toJsonValue>(m_isNews); - result["IsKids"] = Jellyfin::Support::toJsonValue>(m_isKids); - result["IsSports"] = Jellyfin::Support::toJsonValue>(m_isSports); - result["StartIndex"] = Jellyfin::Support::toJsonValue>(m_startIndex); - result["Limit"] = Jellyfin::Support::toJsonValue>(m_limit); - result["SortBy"] = Jellyfin::Support::toJsonValue(m_sortBy); - result["SortOrder"] = Jellyfin::Support::toJsonValue(m_sortOrder); - result["Genres"] = Jellyfin::Support::toJsonValue(m_genres); - result["GenreIds"] = Jellyfin::Support::toJsonValue(m_genreIds); - result["EnableImages"] = Jellyfin::Support::toJsonValue>(m_enableImages); - result["EnableTotalRecordCount"] = Jellyfin::Support::toJsonValue(m_enableTotalRecordCount); - result["ImageTypeLimit"] = Jellyfin::Support::toJsonValue>(m_imageTypeLimit); - result["EnableImageTypes"] = Jellyfin::Support::toJsonValue>(m_enableImageTypes); - result["EnableUserData"] = Jellyfin::Support::toJsonValue>(m_enableUserData); - result["SeriesTimerId"] = Jellyfin::Support::toJsonValue(m_seriesTimerId); - result["LibrarySeriesId"] = Jellyfin::Support::toJsonValue(m_librarySeriesId); - result["Fields"] = Jellyfin::Support::toJsonValue>(m_fields); - + + + if (!(m_channelIds.size() == 0)) { + result["ChannelIds"] = Jellyfin::Support::toJsonValue(m_channelIds); + } + + result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); + + if (!(m_minStartDate.isNull())) { + result["MinStartDate"] = Jellyfin::Support::toJsonValue(m_minStartDate); + } + + + if (!(!m_hasAired.has_value())) { + result["HasAired"] = Jellyfin::Support::toJsonValue>(m_hasAired); + } + + + if (!(!m_isAiring.has_value())) { + result["IsAiring"] = Jellyfin::Support::toJsonValue>(m_isAiring); + } + + + if (!(m_maxStartDate.isNull())) { + result["MaxStartDate"] = Jellyfin::Support::toJsonValue(m_maxStartDate); + } + + + if (!(m_minEndDate.isNull())) { + result["MinEndDate"] = Jellyfin::Support::toJsonValue(m_minEndDate); + } + + + if (!(m_maxEndDate.isNull())) { + result["MaxEndDate"] = Jellyfin::Support::toJsonValue(m_maxEndDate); + } + + + if (!(!m_isMovie.has_value())) { + result["IsMovie"] = Jellyfin::Support::toJsonValue>(m_isMovie); + } + + + if (!(!m_isSeries.has_value())) { + result["IsSeries"] = Jellyfin::Support::toJsonValue>(m_isSeries); + } + + + if (!(!m_isNews.has_value())) { + result["IsNews"] = Jellyfin::Support::toJsonValue>(m_isNews); + } + + + if (!(!m_isKids.has_value())) { + result["IsKids"] = Jellyfin::Support::toJsonValue>(m_isKids); + } + + + if (!(!m_isSports.has_value())) { + result["IsSports"] = Jellyfin::Support::toJsonValue>(m_isSports); + } + + + if (!(!m_startIndex.has_value())) { + result["StartIndex"] = Jellyfin::Support::toJsonValue>(m_startIndex); + } + + + if (!(!m_limit.has_value())) { + result["Limit"] = Jellyfin::Support::toJsonValue>(m_limit); + } + + + if (!(m_sortBy.isNull())) { + result["SortBy"] = Jellyfin::Support::toJsonValue(m_sortBy); + } + + + if (!(m_sortOrder.isNull())) { + result["SortOrder"] = Jellyfin::Support::toJsonValue(m_sortOrder); + } + + + if (!(m_genres.size() == 0)) { + result["Genres"] = Jellyfin::Support::toJsonValue(m_genres); + } + + + if (!(m_genreIds.size() == 0)) { + result["GenreIds"] = Jellyfin::Support::toJsonValue(m_genreIds); + } + + + if (!(!m_enableImages.has_value())) { + result["EnableImages"] = Jellyfin::Support::toJsonValue>(m_enableImages); + } + + result["EnableTotalRecordCount"] = Jellyfin::Support::toJsonValue(m_enableTotalRecordCount); + + if (!(!m_imageTypeLimit.has_value())) { + result["ImageTypeLimit"] = Jellyfin::Support::toJsonValue>(m_imageTypeLimit); + } + + + if (!(m_enableImageTypes.size() == 0)) { + result["EnableImageTypes"] = Jellyfin::Support::toJsonValue>(m_enableImageTypes); + } + + + if (!(!m_enableUserData.has_value())) { + result["EnableUserData"] = Jellyfin::Support::toJsonValue>(m_enableUserData); + } + + + if (!(m_seriesTimerId.isNull())) { + result["SeriesTimerId"] = Jellyfin::Support::toJsonValue(m_seriesTimerId); + } + + result["LibrarySeriesId"] = Jellyfin::Support::toJsonValue(m_librarySeriesId); + + if (!(m_fields.size() == 0)) { + result["Fields"] = Jellyfin::Support::toJsonValue>(m_fields); + } + return result; } diff --git a/core/src/dto/groupinfodto.cpp b/core/src/dto/groupinfodto.cpp index 1be160f..ccd555d 100644 --- a/core/src/dto/groupinfodto.cpp +++ b/core/src/dto/groupinfodto.cpp @@ -69,12 +69,20 @@ void GroupInfoDto::setFromJson(QJsonObject source) { QJsonObject GroupInfoDto::toJson() const { QJsonObject result; - result["GroupId"] = Jellyfin::Support::toJsonValue(m_groupId); - result["GroupName"] = Jellyfin::Support::toJsonValue(m_groupName); - result["State"] = Jellyfin::Support::toJsonValue(m_state); - result["Participants"] = Jellyfin::Support::toJsonValue(m_participants); - result["LastUpdatedAt"] = Jellyfin::Support::toJsonValue(m_lastUpdatedAt); - + + result["GroupId"] = Jellyfin::Support::toJsonValue(m_groupId); + + if (!(m_groupName.isNull())) { + result["GroupName"] = Jellyfin::Support::toJsonValue(m_groupName); + } + + result["State"] = Jellyfin::Support::toJsonValue(m_state); + + if (!(m_participants.size() == 0)) { + result["Participants"] = Jellyfin::Support::toJsonValue(m_participants); + } + + result["LastUpdatedAt"] = Jellyfin::Support::toJsonValue(m_lastUpdatedAt); return result; } diff --git a/core/src/dto/guideinfo.cpp b/core/src/dto/guideinfo.cpp index a2636cd..c62dbd7 100644 --- a/core/src/dto/guideinfo.cpp +++ b/core/src/dto/guideinfo.cpp @@ -60,9 +60,9 @@ void GuideInfo::setFromJson(QJsonObject source) { QJsonObject GuideInfo::toJson() const { QJsonObject result; - result["StartDate"] = Jellyfin::Support::toJsonValue(m_startDate); - result["EndDate"] = Jellyfin::Support::toJsonValue(m_endDate); - + + result["StartDate"] = Jellyfin::Support::toJsonValue(m_startDate); + result["EndDate"] = Jellyfin::Support::toJsonValue(m_endDate); return result; } diff --git a/core/src/dto/httpheaderinfo.cpp b/core/src/dto/httpheaderinfo.cpp index b04fc59..64db4f4 100644 --- a/core/src/dto/httpheaderinfo.cpp +++ b/core/src/dto/httpheaderinfo.cpp @@ -63,10 +63,18 @@ void HttpHeaderInfo::setFromJson(QJsonObject source) { QJsonObject HttpHeaderInfo::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Value"] = Jellyfin::Support::toJsonValue(m_value); - result["Match"] = Jellyfin::Support::toJsonValue(m_match); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_value.isNull())) { + result["Value"] = Jellyfin::Support::toJsonValue(m_value); + } + + result["Match"] = Jellyfin::Support::toJsonValue(m_match); return result; } diff --git a/core/src/dto/ignorewaitrequestdto.cpp b/core/src/dto/ignorewaitrequestdto.cpp index f49efe2..a519a1f 100644 --- a/core/src/dto/ignorewaitrequestdto.cpp +++ b/core/src/dto/ignorewaitrequestdto.cpp @@ -57,8 +57,8 @@ void IgnoreWaitRequestDto::setFromJson(QJsonObject source) { QJsonObject IgnoreWaitRequestDto::toJson() const { QJsonObject result; - result["IgnoreWait"] = Jellyfin::Support::toJsonValue(m_ignoreWait); - + + result["IgnoreWait"] = Jellyfin::Support::toJsonValue(m_ignoreWait); return result; } diff --git a/core/src/dto/imagebynameinfo.cpp b/core/src/dto/imagebynameinfo.cpp index 1f976c8..61a06d7 100644 --- a/core/src/dto/imagebynameinfo.cpp +++ b/core/src/dto/imagebynameinfo.cpp @@ -69,12 +69,28 @@ void ImageByNameInfo::setFromJson(QJsonObject source) { QJsonObject ImageByNameInfo::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Theme"] = Jellyfin::Support::toJsonValue(m_theme); - result["Context"] = Jellyfin::Support::toJsonValue(m_context); - result["FileLength"] = Jellyfin::Support::toJsonValue(m_fileLength); - result["Format"] = Jellyfin::Support::toJsonValue(m_format); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_theme.isNull())) { + result["Theme"] = Jellyfin::Support::toJsonValue(m_theme); + } + + + if (!(m_context.isNull())) { + result["Context"] = Jellyfin::Support::toJsonValue(m_context); + } + + result["FileLength"] = Jellyfin::Support::toJsonValue(m_fileLength); + + if (!(m_format.isNull())) { + result["Format"] = Jellyfin::Support::toJsonValue(m_format); + } + return result; } diff --git a/core/src/dto/imageinfo.cpp b/core/src/dto/imageinfo.cpp index da03c0f..a278593 100644 --- a/core/src/dto/imageinfo.cpp +++ b/core/src/dto/imageinfo.cpp @@ -78,15 +78,39 @@ void ImageInfo::setFromJson(QJsonObject source) { QJsonObject ImageInfo::toJson() const { QJsonObject result; - result["ImageType"] = Jellyfin::Support::toJsonValue(m_imageType); - result["ImageIndex"] = Jellyfin::Support::toJsonValue>(m_imageIndex); - result["ImageTag"] = Jellyfin::Support::toJsonValue(m_imageTag); - result["Path"] = Jellyfin::Support::toJsonValue(m_path); - result["BlurHash"] = Jellyfin::Support::toJsonValue(m_blurHash); - result["Height"] = Jellyfin::Support::toJsonValue>(m_height); - result["Width"] = Jellyfin::Support::toJsonValue>(m_width); - result["Size"] = Jellyfin::Support::toJsonValue(m_size); - + + result["ImageType"] = Jellyfin::Support::toJsonValue(m_imageType); + + if (!(!m_imageIndex.has_value())) { + result["ImageIndex"] = Jellyfin::Support::toJsonValue>(m_imageIndex); + } + + + if (!(m_imageTag.isNull())) { + result["ImageTag"] = Jellyfin::Support::toJsonValue(m_imageTag); + } + + + if (!(m_path.isNull())) { + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + } + + + if (!(m_blurHash.isNull())) { + result["BlurHash"] = Jellyfin::Support::toJsonValue(m_blurHash); + } + + + if (!(!m_height.has_value())) { + result["Height"] = Jellyfin::Support::toJsonValue>(m_height); + } + + + if (!(!m_width.has_value())) { + result["Width"] = Jellyfin::Support::toJsonValue>(m_width); + } + + result["Size"] = Jellyfin::Support::toJsonValue(m_size); return result; } diff --git a/core/src/dto/imageoption.cpp b/core/src/dto/imageoption.cpp index f643bbf..a6c5a2d 100644 --- a/core/src/dto/imageoption.cpp +++ b/core/src/dto/imageoption.cpp @@ -63,10 +63,10 @@ void ImageOption::setFromJson(QJsonObject source) { QJsonObject ImageOption::toJson() const { QJsonObject result; - result["Type"] = Jellyfin::Support::toJsonValue(m_type); - result["Limit"] = Jellyfin::Support::toJsonValue(m_limit); - result["MinWidth"] = Jellyfin::Support::toJsonValue(m_minWidth); - + + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + result["Limit"] = Jellyfin::Support::toJsonValue(m_limit); + result["MinWidth"] = Jellyfin::Support::toJsonValue(m_minWidth); return result; } diff --git a/core/src/dto/imageproviderinfo.cpp b/core/src/dto/imageproviderinfo.cpp index 30b9955..e667656 100644 --- a/core/src/dto/imageproviderinfo.cpp +++ b/core/src/dto/imageproviderinfo.cpp @@ -60,9 +60,17 @@ void ImageProviderInfo::setFromJson(QJsonObject source) { QJsonObject ImageProviderInfo::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["SupportedImages"] = Jellyfin::Support::toJsonValue>(m_supportedImages); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_supportedImages.size() == 0)) { + result["SupportedImages"] = Jellyfin::Support::toJsonValue>(m_supportedImages); + } + return result; } diff --git a/core/src/dto/installationinfo.cpp b/core/src/dto/installationinfo.cpp index b74c90a..0a49536 100644 --- a/core/src/dto/installationinfo.cpp +++ b/core/src/dto/installationinfo.cpp @@ -72,13 +72,29 @@ void InstallationInfo::setFromJson(QJsonObject source) { QJsonObject InstallationInfo::toJson() const { QJsonObject result; - result["Guid"] = Jellyfin::Support::toJsonValue(m_guid); - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Version"] = Jellyfin::Support::toJsonValue>(m_version); - result["Changelog"] = Jellyfin::Support::toJsonValue(m_changelog); - result["SourceUrl"] = Jellyfin::Support::toJsonValue(m_sourceUrl); - result["Checksum"] = Jellyfin::Support::toJsonValue(m_checksum); - + + result["Guid"] = Jellyfin::Support::toJsonValue(m_guid); + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + result["Version"] = Jellyfin::Support::toJsonValue>(m_version); + + if (!(m_changelog.isNull())) { + result["Changelog"] = Jellyfin::Support::toJsonValue(m_changelog); + } + + + if (!(m_sourceUrl.isNull())) { + result["SourceUrl"] = Jellyfin::Support::toJsonValue(m_sourceUrl); + } + + + if (!(m_checksum.isNull())) { + result["Checksum"] = Jellyfin::Support::toJsonValue(m_checksum); + } + return result; } diff --git a/core/src/dto/iplugin.cpp b/core/src/dto/iplugin.cpp index 8275799..a1b2653 100644 --- a/core/src/dto/iplugin.cpp +++ b/core/src/dto/iplugin.cpp @@ -75,14 +75,30 @@ void IPlugin::setFromJson(QJsonObject source) { QJsonObject IPlugin::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Description"] = Jellyfin::Support::toJsonValue(m_description); - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["Version"] = Jellyfin::Support::toJsonValue>(m_version); - result["AssemblyFilePath"] = Jellyfin::Support::toJsonValue(m_assemblyFilePath); - result["CanUninstall"] = Jellyfin::Support::toJsonValue(m_canUninstall); - result["DataFolderPath"] = Jellyfin::Support::toJsonValue(m_dataFolderPath); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_description.isNull())) { + result["Description"] = Jellyfin::Support::toJsonValue(m_description); + } + + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["Version"] = Jellyfin::Support::toJsonValue>(m_version); + + if (!(m_assemblyFilePath.isNull())) { + result["AssemblyFilePath"] = Jellyfin::Support::toJsonValue(m_assemblyFilePath); + } + + result["CanUninstall"] = Jellyfin::Support::toJsonValue(m_canUninstall); + + if (!(m_dataFolderPath.isNull())) { + result["DataFolderPath"] = Jellyfin::Support::toJsonValue(m_dataFolderPath); + } + return result; } diff --git a/core/src/dto/itemcounts.cpp b/core/src/dto/itemcounts.cpp index 88f1f53..99630cb 100644 --- a/core/src/dto/itemcounts.cpp +++ b/core/src/dto/itemcounts.cpp @@ -90,19 +90,19 @@ void ItemCounts::setFromJson(QJsonObject source) { QJsonObject ItemCounts::toJson() const { QJsonObject result; - result["MovieCount"] = Jellyfin::Support::toJsonValue(m_movieCount); - result["SeriesCount"] = Jellyfin::Support::toJsonValue(m_seriesCount); - result["EpisodeCount"] = Jellyfin::Support::toJsonValue(m_episodeCount); - result["ArtistCount"] = Jellyfin::Support::toJsonValue(m_artistCount); - result["ProgramCount"] = Jellyfin::Support::toJsonValue(m_programCount); - result["TrailerCount"] = Jellyfin::Support::toJsonValue(m_trailerCount); - result["SongCount"] = Jellyfin::Support::toJsonValue(m_songCount); - result["AlbumCount"] = Jellyfin::Support::toJsonValue(m_albumCount); - result["MusicVideoCount"] = Jellyfin::Support::toJsonValue(m_musicVideoCount); - result["BoxSetCount"] = Jellyfin::Support::toJsonValue(m_boxSetCount); - result["BookCount"] = Jellyfin::Support::toJsonValue(m_bookCount); - result["ItemCount"] = Jellyfin::Support::toJsonValue(m_itemCount); - + + result["MovieCount"] = Jellyfin::Support::toJsonValue(m_movieCount); + result["SeriesCount"] = Jellyfin::Support::toJsonValue(m_seriesCount); + result["EpisodeCount"] = Jellyfin::Support::toJsonValue(m_episodeCount); + result["ArtistCount"] = Jellyfin::Support::toJsonValue(m_artistCount); + result["ProgramCount"] = Jellyfin::Support::toJsonValue(m_programCount); + result["TrailerCount"] = Jellyfin::Support::toJsonValue(m_trailerCount); + result["SongCount"] = Jellyfin::Support::toJsonValue(m_songCount); + result["AlbumCount"] = Jellyfin::Support::toJsonValue(m_albumCount); + result["MusicVideoCount"] = Jellyfin::Support::toJsonValue(m_musicVideoCount); + result["BoxSetCount"] = Jellyfin::Support::toJsonValue(m_boxSetCount); + result["BookCount"] = Jellyfin::Support::toJsonValue(m_bookCount); + result["ItemCount"] = Jellyfin::Support::toJsonValue(m_itemCount); return result; } diff --git a/core/src/dto/joingrouprequestdto.cpp b/core/src/dto/joingrouprequestdto.cpp index ed38b28..503687f 100644 --- a/core/src/dto/joingrouprequestdto.cpp +++ b/core/src/dto/joingrouprequestdto.cpp @@ -57,8 +57,8 @@ void JoinGroupRequestDto::setFromJson(QJsonObject source) { QJsonObject JoinGroupRequestDto::toJson() const { QJsonObject result; - result["GroupId"] = Jellyfin::Support::toJsonValue(m_groupId); - + + result["GroupId"] = Jellyfin::Support::toJsonValue(m_groupId); return result; } diff --git a/core/src/dto/libraryoptioninfodto.cpp b/core/src/dto/libraryoptioninfodto.cpp index 28e9beb..983f88e 100644 --- a/core/src/dto/libraryoptioninfodto.cpp +++ b/core/src/dto/libraryoptioninfodto.cpp @@ -60,9 +60,13 @@ void LibraryOptionInfoDto::setFromJson(QJsonObject source) { QJsonObject LibraryOptionInfoDto::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["DefaultEnabled"] = Jellyfin::Support::toJsonValue(m_defaultEnabled); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + result["DefaultEnabled"] = Jellyfin::Support::toJsonValue(m_defaultEnabled); return result; } diff --git a/core/src/dto/libraryoptions.cpp b/core/src/dto/libraryoptions.cpp index 688f1d5..447d906 100644 --- a/core/src/dto/libraryoptions.cpp +++ b/core/src/dto/libraryoptions.cpp @@ -129,32 +129,76 @@ void LibraryOptions::setFromJson(QJsonObject source) { QJsonObject LibraryOptions::toJson() const { QJsonObject result; - result["EnablePhotos"] = Jellyfin::Support::toJsonValue(m_enablePhotos); - result["EnableRealtimeMonitor"] = Jellyfin::Support::toJsonValue(m_enableRealtimeMonitor); - result["EnableChapterImageExtraction"] = Jellyfin::Support::toJsonValue(m_enableChapterImageExtraction); - result["ExtractChapterImagesDuringLibraryScan"] = Jellyfin::Support::toJsonValue(m_extractChapterImagesDuringLibraryScan); - result["PathInfos"] = Jellyfin::Support::toJsonValue>(m_pathInfos); - result["SaveLocalMetadata"] = Jellyfin::Support::toJsonValue(m_saveLocalMetadata); - result["EnableInternetProviders"] = Jellyfin::Support::toJsonValue(m_enableInternetProviders); - result["EnableAutomaticSeriesGrouping"] = Jellyfin::Support::toJsonValue(m_enableAutomaticSeriesGrouping); - result["EnableEmbeddedTitles"] = Jellyfin::Support::toJsonValue(m_enableEmbeddedTitles); - result["EnableEmbeddedEpisodeInfos"] = Jellyfin::Support::toJsonValue(m_enableEmbeddedEpisodeInfos); - result["AutomaticRefreshIntervalDays"] = Jellyfin::Support::toJsonValue(m_automaticRefreshIntervalDays); - result["PreferredMetadataLanguage"] = Jellyfin::Support::toJsonValue(m_preferredMetadataLanguage); - result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); - result["SeasonZeroDisplayName"] = Jellyfin::Support::toJsonValue(m_seasonZeroDisplayName); - result["MetadataSavers"] = Jellyfin::Support::toJsonValue(m_metadataSavers); - result["DisabledLocalMetadataReaders"] = Jellyfin::Support::toJsonValue(m_disabledLocalMetadataReaders); - result["LocalMetadataReaderOrder"] = Jellyfin::Support::toJsonValue(m_localMetadataReaderOrder); - result["DisabledSubtitleFetchers"] = Jellyfin::Support::toJsonValue(m_disabledSubtitleFetchers); - result["SubtitleFetcherOrder"] = Jellyfin::Support::toJsonValue(m_subtitleFetcherOrder); - result["SkipSubtitlesIfEmbeddedSubtitlesPresent"] = Jellyfin::Support::toJsonValue(m_skipSubtitlesIfEmbeddedSubtitlesPresent); - result["SkipSubtitlesIfAudioTrackMatches"] = Jellyfin::Support::toJsonValue(m_skipSubtitlesIfAudioTrackMatches); - result["SubtitleDownloadLanguages"] = Jellyfin::Support::toJsonValue(m_subtitleDownloadLanguages); - result["RequirePerfectSubtitleMatch"] = Jellyfin::Support::toJsonValue(m_requirePerfectSubtitleMatch); - result["SaveSubtitlesWithMedia"] = Jellyfin::Support::toJsonValue(m_saveSubtitlesWithMedia); - result["TypeOptions"] = Jellyfin::Support::toJsonValue>(m_typeOptions); - + + result["EnablePhotos"] = Jellyfin::Support::toJsonValue(m_enablePhotos); + result["EnableRealtimeMonitor"] = Jellyfin::Support::toJsonValue(m_enableRealtimeMonitor); + result["EnableChapterImageExtraction"] = Jellyfin::Support::toJsonValue(m_enableChapterImageExtraction); + result["ExtractChapterImagesDuringLibraryScan"] = Jellyfin::Support::toJsonValue(m_extractChapterImagesDuringLibraryScan); + + if (!(m_pathInfos.size() == 0)) { + result["PathInfos"] = Jellyfin::Support::toJsonValue>(m_pathInfos); + } + + result["SaveLocalMetadata"] = Jellyfin::Support::toJsonValue(m_saveLocalMetadata); + result["EnableInternetProviders"] = Jellyfin::Support::toJsonValue(m_enableInternetProviders); + result["EnableAutomaticSeriesGrouping"] = Jellyfin::Support::toJsonValue(m_enableAutomaticSeriesGrouping); + result["EnableEmbeddedTitles"] = Jellyfin::Support::toJsonValue(m_enableEmbeddedTitles); + result["EnableEmbeddedEpisodeInfos"] = Jellyfin::Support::toJsonValue(m_enableEmbeddedEpisodeInfos); + result["AutomaticRefreshIntervalDays"] = Jellyfin::Support::toJsonValue(m_automaticRefreshIntervalDays); + + if (!(m_preferredMetadataLanguage.isNull())) { + result["PreferredMetadataLanguage"] = Jellyfin::Support::toJsonValue(m_preferredMetadataLanguage); + } + + + if (!(m_metadataCountryCode.isNull())) { + result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); + } + + + if (!(m_seasonZeroDisplayName.isNull())) { + result["SeasonZeroDisplayName"] = Jellyfin::Support::toJsonValue(m_seasonZeroDisplayName); + } + + + if (!(m_metadataSavers.size() == 0)) { + result["MetadataSavers"] = Jellyfin::Support::toJsonValue(m_metadataSavers); + } + + + if (!(m_disabledLocalMetadataReaders.size() == 0)) { + result["DisabledLocalMetadataReaders"] = Jellyfin::Support::toJsonValue(m_disabledLocalMetadataReaders); + } + + + if (!(m_localMetadataReaderOrder.size() == 0)) { + result["LocalMetadataReaderOrder"] = Jellyfin::Support::toJsonValue(m_localMetadataReaderOrder); + } + + + if (!(m_disabledSubtitleFetchers.size() == 0)) { + result["DisabledSubtitleFetchers"] = Jellyfin::Support::toJsonValue(m_disabledSubtitleFetchers); + } + + + if (!(m_subtitleFetcherOrder.size() == 0)) { + result["SubtitleFetcherOrder"] = Jellyfin::Support::toJsonValue(m_subtitleFetcherOrder); + } + + result["SkipSubtitlesIfEmbeddedSubtitlesPresent"] = Jellyfin::Support::toJsonValue(m_skipSubtitlesIfEmbeddedSubtitlesPresent); + result["SkipSubtitlesIfAudioTrackMatches"] = Jellyfin::Support::toJsonValue(m_skipSubtitlesIfAudioTrackMatches); + + if (!(m_subtitleDownloadLanguages.size() == 0)) { + result["SubtitleDownloadLanguages"] = Jellyfin::Support::toJsonValue(m_subtitleDownloadLanguages); + } + + result["RequirePerfectSubtitleMatch"] = Jellyfin::Support::toJsonValue(m_requirePerfectSubtitleMatch); + result["SaveSubtitlesWithMedia"] = Jellyfin::Support::toJsonValue(m_saveSubtitlesWithMedia); + + if (!(m_typeOptions.size() == 0)) { + result["TypeOptions"] = Jellyfin::Support::toJsonValue>(m_typeOptions); + } + return result; } diff --git a/core/src/dto/libraryoptionsresultdto.cpp b/core/src/dto/libraryoptionsresultdto.cpp index 2c8ac3a..33626dd 100644 --- a/core/src/dto/libraryoptionsresultdto.cpp +++ b/core/src/dto/libraryoptionsresultdto.cpp @@ -66,11 +66,27 @@ void LibraryOptionsResultDto::setFromJson(QJsonObject source) { QJsonObject LibraryOptionsResultDto::toJson() const { QJsonObject result; - result["MetadataSavers"] = Jellyfin::Support::toJsonValue>(m_metadataSavers); - result["MetadataReaders"] = Jellyfin::Support::toJsonValue>(m_metadataReaders); - result["SubtitleFetchers"] = Jellyfin::Support::toJsonValue>(m_subtitleFetchers); - result["TypeOptions"] = Jellyfin::Support::toJsonValue>(m_typeOptions); - + + + if (!(m_metadataSavers.size() == 0)) { + result["MetadataSavers"] = Jellyfin::Support::toJsonValue>(m_metadataSavers); + } + + + if (!(m_metadataReaders.size() == 0)) { + result["MetadataReaders"] = Jellyfin::Support::toJsonValue>(m_metadataReaders); + } + + + if (!(m_subtitleFetchers.size() == 0)) { + result["SubtitleFetchers"] = Jellyfin::Support::toJsonValue>(m_subtitleFetchers); + } + + + if (!(m_typeOptions.size() == 0)) { + result["TypeOptions"] = Jellyfin::Support::toJsonValue>(m_typeOptions); + } + return result; } diff --git a/core/src/dto/librarytypeoptionsdto.cpp b/core/src/dto/librarytypeoptionsdto.cpp index e09d7dc..73371c9 100644 --- a/core/src/dto/librarytypeoptionsdto.cpp +++ b/core/src/dto/librarytypeoptionsdto.cpp @@ -69,12 +69,32 @@ void LibraryTypeOptionsDto::setFromJson(QJsonObject source) { QJsonObject LibraryTypeOptionsDto::toJson() const { QJsonObject result; - result["Type"] = Jellyfin::Support::toJsonValue(m_type); - result["MetadataFetchers"] = Jellyfin::Support::toJsonValue>(m_metadataFetchers); - result["ImageFetchers"] = Jellyfin::Support::toJsonValue>(m_imageFetchers); - result["SupportedImageTypes"] = Jellyfin::Support::toJsonValue>(m_supportedImageTypes); - result["DefaultImageOptions"] = Jellyfin::Support::toJsonValue>(m_defaultImageOptions); - + + + if (!(m_type.isNull())) { + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + } + + + if (!(m_metadataFetchers.size() == 0)) { + result["MetadataFetchers"] = Jellyfin::Support::toJsonValue>(m_metadataFetchers); + } + + + if (!(m_imageFetchers.size() == 0)) { + result["ImageFetchers"] = Jellyfin::Support::toJsonValue>(m_imageFetchers); + } + + + if (!(m_supportedImageTypes.size() == 0)) { + result["SupportedImageTypes"] = Jellyfin::Support::toJsonValue>(m_supportedImageTypes); + } + + + if (!(m_defaultImageOptions.size() == 0)) { + result["DefaultImageOptions"] = Jellyfin::Support::toJsonValue>(m_defaultImageOptions); + } + return result; } diff --git a/core/src/dto/libraryupdateinfo.cpp b/core/src/dto/libraryupdateinfo.cpp index 2e3d74d..3c970ca 100644 --- a/core/src/dto/libraryupdateinfo.cpp +++ b/core/src/dto/libraryupdateinfo.cpp @@ -75,14 +75,38 @@ void LibraryUpdateInfo::setFromJson(QJsonObject source) { QJsonObject LibraryUpdateInfo::toJson() const { QJsonObject result; - result["FoldersAddedTo"] = Jellyfin::Support::toJsonValue(m_foldersAddedTo); - result["FoldersRemovedFrom"] = Jellyfin::Support::toJsonValue(m_foldersRemovedFrom); - result["ItemsAdded"] = Jellyfin::Support::toJsonValue(m_itemsAdded); - result["ItemsRemoved"] = Jellyfin::Support::toJsonValue(m_itemsRemoved); - result["ItemsUpdated"] = Jellyfin::Support::toJsonValue(m_itemsUpdated); - result["CollectionFolders"] = Jellyfin::Support::toJsonValue(m_collectionFolders); - result["IsEmpty"] = Jellyfin::Support::toJsonValue(m_isEmpty); - + + + if (!(m_foldersAddedTo.size() == 0)) { + result["FoldersAddedTo"] = Jellyfin::Support::toJsonValue(m_foldersAddedTo); + } + + + if (!(m_foldersRemovedFrom.size() == 0)) { + result["FoldersRemovedFrom"] = Jellyfin::Support::toJsonValue(m_foldersRemovedFrom); + } + + + if (!(m_itemsAdded.size() == 0)) { + result["ItemsAdded"] = Jellyfin::Support::toJsonValue(m_itemsAdded); + } + + + if (!(m_itemsRemoved.size() == 0)) { + result["ItemsRemoved"] = Jellyfin::Support::toJsonValue(m_itemsRemoved); + } + + + if (!(m_itemsUpdated.size() == 0)) { + result["ItemsUpdated"] = Jellyfin::Support::toJsonValue(m_itemsUpdated); + } + + + if (!(m_collectionFolders.size() == 0)) { + result["CollectionFolders"] = Jellyfin::Support::toJsonValue(m_collectionFolders); + } + + result["IsEmpty"] = Jellyfin::Support::toJsonValue(m_isEmpty); return result; } diff --git a/core/src/dto/listingsproviderinfo.cpp b/core/src/dto/listingsproviderinfo.cpp index 5451190..1f97af9 100644 --- a/core/src/dto/listingsproviderinfo.cpp +++ b/core/src/dto/listingsproviderinfo.cpp @@ -108,25 +108,93 @@ void ListingsProviderInfo::setFromJson(QJsonObject source) { QJsonObject ListingsProviderInfo::toJson() const { QJsonObject result; - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["Type"] = Jellyfin::Support::toJsonValue(m_type); - result["Username"] = Jellyfin::Support::toJsonValue(m_username); - result["Password"] = Jellyfin::Support::toJsonValue(m_password); - result["ListingsId"] = Jellyfin::Support::toJsonValue(m_listingsId); - result["ZipCode"] = Jellyfin::Support::toJsonValue(m_zipCode); - result["Country"] = Jellyfin::Support::toJsonValue(m_country); - result["Path"] = Jellyfin::Support::toJsonValue(m_path); - result["EnabledTuners"] = Jellyfin::Support::toJsonValue(m_enabledTuners); - result["EnableAllTuners"] = Jellyfin::Support::toJsonValue(m_enableAllTuners); - result["NewsCategories"] = Jellyfin::Support::toJsonValue(m_newsCategories); - result["SportsCategories"] = Jellyfin::Support::toJsonValue(m_sportsCategories); - result["KidsCategories"] = Jellyfin::Support::toJsonValue(m_kidsCategories); - result["MovieCategories"] = Jellyfin::Support::toJsonValue(m_movieCategories); - result["ChannelMappings"] = Jellyfin::Support::toJsonValue>(m_channelMappings); - result["MoviePrefix"] = Jellyfin::Support::toJsonValue(m_moviePrefix); - result["PreferredLanguage"] = Jellyfin::Support::toJsonValue(m_preferredLanguage); - result["UserAgent"] = Jellyfin::Support::toJsonValue(m_userAgent); - + + + if (!(m_jellyfinId.isNull())) { + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + } + + + if (!(m_type.isNull())) { + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + } + + + if (!(m_username.isNull())) { + result["Username"] = Jellyfin::Support::toJsonValue(m_username); + } + + + if (!(m_password.isNull())) { + result["Password"] = Jellyfin::Support::toJsonValue(m_password); + } + + + if (!(m_listingsId.isNull())) { + result["ListingsId"] = Jellyfin::Support::toJsonValue(m_listingsId); + } + + + if (!(m_zipCode.isNull())) { + result["ZipCode"] = Jellyfin::Support::toJsonValue(m_zipCode); + } + + + if (!(m_country.isNull())) { + result["Country"] = Jellyfin::Support::toJsonValue(m_country); + } + + + if (!(m_path.isNull())) { + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + } + + + if (!(m_enabledTuners.size() == 0)) { + result["EnabledTuners"] = Jellyfin::Support::toJsonValue(m_enabledTuners); + } + + result["EnableAllTuners"] = Jellyfin::Support::toJsonValue(m_enableAllTuners); + + if (!(m_newsCategories.size() == 0)) { + result["NewsCategories"] = Jellyfin::Support::toJsonValue(m_newsCategories); + } + + + if (!(m_sportsCategories.size() == 0)) { + result["SportsCategories"] = Jellyfin::Support::toJsonValue(m_sportsCategories); + } + + + if (!(m_kidsCategories.size() == 0)) { + result["KidsCategories"] = Jellyfin::Support::toJsonValue(m_kidsCategories); + } + + + if (!(m_movieCategories.size() == 0)) { + result["MovieCategories"] = Jellyfin::Support::toJsonValue(m_movieCategories); + } + + + if (!(m_channelMappings.size() == 0)) { + result["ChannelMappings"] = Jellyfin::Support::toJsonValue>(m_channelMappings); + } + + + if (!(m_moviePrefix.isNull())) { + result["MoviePrefix"] = Jellyfin::Support::toJsonValue(m_moviePrefix); + } + + + if (!(m_preferredLanguage.isNull())) { + result["PreferredLanguage"] = Jellyfin::Support::toJsonValue(m_preferredLanguage); + } + + + if (!(m_userAgent.isNull())) { + result["UserAgent"] = Jellyfin::Support::toJsonValue(m_userAgent); + } + return result; } diff --git a/core/src/dto/livestreamresponse.cpp b/core/src/dto/livestreamresponse.cpp index 9bb8eb3..cff7626 100644 --- a/core/src/dto/livestreamresponse.cpp +++ b/core/src/dto/livestreamresponse.cpp @@ -57,8 +57,8 @@ void LiveStreamResponse::setFromJson(QJsonObject source) { QJsonObject LiveStreamResponse::toJson() const { QJsonObject result; - result["MediaSource"] = Jellyfin::Support::toJsonValue>(m_mediaSource); - + + result["MediaSource"] = Jellyfin::Support::toJsonValue>(m_mediaSource); return result; } diff --git a/core/src/dto/livetvinfo.cpp b/core/src/dto/livetvinfo.cpp index 49bb5bb..a1a65c8 100644 --- a/core/src/dto/livetvinfo.cpp +++ b/core/src/dto/livetvinfo.cpp @@ -63,10 +63,18 @@ void LiveTvInfo::setFromJson(QJsonObject source) { QJsonObject LiveTvInfo::toJson() const { QJsonObject result; - result["Services"] = Jellyfin::Support::toJsonValue>(m_services); - result["IsEnabled"] = Jellyfin::Support::toJsonValue(m_isEnabled); - result["EnabledUsers"] = Jellyfin::Support::toJsonValue(m_enabledUsers); - + + + if (!(m_services.size() == 0)) { + result["Services"] = Jellyfin::Support::toJsonValue>(m_services); + } + + result["IsEnabled"] = Jellyfin::Support::toJsonValue(m_isEnabled); + + if (!(m_enabledUsers.size() == 0)) { + result["EnabledUsers"] = Jellyfin::Support::toJsonValue(m_enabledUsers); + } + return result; } diff --git a/core/src/dto/livetvserviceinfo.cpp b/core/src/dto/livetvserviceinfo.cpp index 93ce481..75cc9bd 100644 --- a/core/src/dto/livetvserviceinfo.cpp +++ b/core/src/dto/livetvserviceinfo.cpp @@ -78,15 +78,35 @@ void LiveTvServiceInfo::setFromJson(QJsonObject source) { QJsonObject LiveTvServiceInfo::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["HomePageUrl"] = Jellyfin::Support::toJsonValue(m_homePageUrl); - result["Status"] = Jellyfin::Support::toJsonValue(m_status); - result["StatusMessage"] = Jellyfin::Support::toJsonValue(m_statusMessage); - result["Version"] = Jellyfin::Support::toJsonValue(m_version); - result["HasUpdateAvailable"] = Jellyfin::Support::toJsonValue(m_hasUpdateAvailable); - result["IsVisible"] = Jellyfin::Support::toJsonValue(m_isVisible); - result["Tuners"] = Jellyfin::Support::toJsonValue(m_tuners); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_homePageUrl.isNull())) { + result["HomePageUrl"] = Jellyfin::Support::toJsonValue(m_homePageUrl); + } + + result["Status"] = Jellyfin::Support::toJsonValue(m_status); + + if (!(m_statusMessage.isNull())) { + result["StatusMessage"] = Jellyfin::Support::toJsonValue(m_statusMessage); + } + + + if (!(m_version.isNull())) { + result["Version"] = Jellyfin::Support::toJsonValue(m_version); + } + + result["HasUpdateAvailable"] = Jellyfin::Support::toJsonValue(m_hasUpdateAvailable); + result["IsVisible"] = Jellyfin::Support::toJsonValue(m_isVisible); + + if (!(m_tuners.size() == 0)) { + result["Tuners"] = Jellyfin::Support::toJsonValue(m_tuners); + } + return result; } diff --git a/core/src/dto/localizationoption.cpp b/core/src/dto/localizationoption.cpp index f12bb54..d33e1f4 100644 --- a/core/src/dto/localizationoption.cpp +++ b/core/src/dto/localizationoption.cpp @@ -60,9 +60,17 @@ void LocalizationOption::setFromJson(QJsonObject source) { QJsonObject LocalizationOption::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Value"] = Jellyfin::Support::toJsonValue(m_value); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_value.isNull())) { + result["Value"] = Jellyfin::Support::toJsonValue(m_value); + } + return result; } diff --git a/core/src/dto/logfile.cpp b/core/src/dto/logfile.cpp index 92c721c..ca8a7c1 100644 --- a/core/src/dto/logfile.cpp +++ b/core/src/dto/logfile.cpp @@ -66,11 +66,15 @@ void LogFile::setFromJson(QJsonObject source) { QJsonObject LogFile::toJson() const { QJsonObject result; - result["DateCreated"] = Jellyfin::Support::toJsonValue(m_dateCreated); - result["DateModified"] = Jellyfin::Support::toJsonValue(m_dateModified); - result["Size"] = Jellyfin::Support::toJsonValue(m_size); - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - + + result["DateCreated"] = Jellyfin::Support::toJsonValue(m_dateCreated); + result["DateModified"] = Jellyfin::Support::toJsonValue(m_dateModified); + result["Size"] = Jellyfin::Support::toJsonValue(m_size); + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + return result; } diff --git a/core/src/dto/mediaattachment.cpp b/core/src/dto/mediaattachment.cpp index f9c5281..f6f10f1 100644 --- a/core/src/dto/mediaattachment.cpp +++ b/core/src/dto/mediaattachment.cpp @@ -75,14 +75,38 @@ void MediaAttachment::setFromJson(QJsonObject source) { QJsonObject MediaAttachment::toJson() const { QJsonObject result; - result["Codec"] = Jellyfin::Support::toJsonValue(m_codec); - result["CodecTag"] = Jellyfin::Support::toJsonValue(m_codecTag); - result["Comment"] = Jellyfin::Support::toJsonValue(m_comment); - result["Index"] = Jellyfin::Support::toJsonValue(m_index); - result["FileName"] = Jellyfin::Support::toJsonValue(m_fileName); - result["MimeType"] = Jellyfin::Support::toJsonValue(m_mimeType); - result["DeliveryUrl"] = Jellyfin::Support::toJsonValue(m_deliveryUrl); - + + + if (!(m_codec.isNull())) { + result["Codec"] = Jellyfin::Support::toJsonValue(m_codec); + } + + + if (!(m_codecTag.isNull())) { + result["CodecTag"] = Jellyfin::Support::toJsonValue(m_codecTag); + } + + + if (!(m_comment.isNull())) { + result["Comment"] = Jellyfin::Support::toJsonValue(m_comment); + } + + result["Index"] = Jellyfin::Support::toJsonValue(m_index); + + if (!(m_fileName.isNull())) { + result["FileName"] = Jellyfin::Support::toJsonValue(m_fileName); + } + + + if (!(m_mimeType.isNull())) { + result["MimeType"] = Jellyfin::Support::toJsonValue(m_mimeType); + } + + + if (!(m_deliveryUrl.isNull())) { + result["DeliveryUrl"] = Jellyfin::Support::toJsonValue(m_deliveryUrl); + } + return result; } diff --git a/core/src/dto/mediaencoderpathdto.cpp b/core/src/dto/mediaencoderpathdto.cpp index 7e21988..47b8931 100644 --- a/core/src/dto/mediaencoderpathdto.cpp +++ b/core/src/dto/mediaencoderpathdto.cpp @@ -60,9 +60,17 @@ void MediaEncoderPathDto::setFromJson(QJsonObject source) { QJsonObject MediaEncoderPathDto::toJson() const { QJsonObject result; - result["Path"] = Jellyfin::Support::toJsonValue(m_path); - result["PathType"] = Jellyfin::Support::toJsonValue(m_pathType); - + + + if (!(m_path.isNull())) { + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + } + + + if (!(m_pathType.isNull())) { + result["PathType"] = Jellyfin::Support::toJsonValue(m_pathType); + } + return result; } diff --git a/core/src/dto/mediapathdto.cpp b/core/src/dto/mediapathdto.cpp index 332c945..18d330f 100644 --- a/core/src/dto/mediapathdto.cpp +++ b/core/src/dto/mediapathdto.cpp @@ -63,10 +63,14 @@ void MediaPathDto::setFromJson(QJsonObject source) { QJsonObject MediaPathDto::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Path"] = Jellyfin::Support::toJsonValue(m_path); - result["PathInfo"] = Jellyfin::Support::toJsonValue>(m_pathInfo); - + + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + + if (!(m_path.isNull())) { + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + } + + result["PathInfo"] = Jellyfin::Support::toJsonValue>(m_pathInfo); return result; } diff --git a/core/src/dto/mediapathinfo.cpp b/core/src/dto/mediapathinfo.cpp index e9573b7..cef6ac6 100644 --- a/core/src/dto/mediapathinfo.cpp +++ b/core/src/dto/mediapathinfo.cpp @@ -60,9 +60,17 @@ void MediaPathInfo::setFromJson(QJsonObject source) { QJsonObject MediaPathInfo::toJson() const { QJsonObject result; - result["Path"] = Jellyfin::Support::toJsonValue(m_path); - result["NetworkPath"] = Jellyfin::Support::toJsonValue(m_networkPath); - + + + if (!(m_path.isNull())) { + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + } + + + if (!(m_networkPath.isNull())) { + result["NetworkPath"] = Jellyfin::Support::toJsonValue(m_networkPath); + } + return result; } diff --git a/core/src/dto/mediasourceinfo.cpp b/core/src/dto/mediasourceinfo.cpp index 46c54aa..5360025 100644 --- a/core/src/dto/mediasourceinfo.cpp +++ b/core/src/dto/mediasourceinfo.cpp @@ -180,49 +180,137 @@ void MediaSourceInfo::setFromJson(QJsonObject source) { QJsonObject MediaSourceInfo::toJson() const { QJsonObject result; - result["Protocol"] = Jellyfin::Support::toJsonValue(m_protocol); - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["Path"] = Jellyfin::Support::toJsonValue(m_path); - result["EncoderPath"] = Jellyfin::Support::toJsonValue(m_encoderPath); - result["EncoderProtocol"] = Jellyfin::Support::toJsonValue(m_encoderProtocol); - result["Type"] = Jellyfin::Support::toJsonValue(m_type); - result["Container"] = Jellyfin::Support::toJsonValue(m_container); - result["Size"] = Jellyfin::Support::toJsonValue>(m_size); - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["IsRemote"] = Jellyfin::Support::toJsonValue(m_isRemote); - result["ETag"] = Jellyfin::Support::toJsonValue(m_eTag); - result["RunTimeTicks"] = Jellyfin::Support::toJsonValue>(m_runTimeTicks); - result["ReadAtNativeFramerate"] = Jellyfin::Support::toJsonValue(m_readAtNativeFramerate); - result["IgnoreDts"] = Jellyfin::Support::toJsonValue(m_ignoreDts); - result["IgnoreIndex"] = Jellyfin::Support::toJsonValue(m_ignoreIndex); - result["GenPtsInput"] = Jellyfin::Support::toJsonValue(m_genPtsInput); - result["SupportsTranscoding"] = Jellyfin::Support::toJsonValue(m_supportsTranscoding); - result["SupportsDirectStream"] = Jellyfin::Support::toJsonValue(m_supportsDirectStream); - result["SupportsDirectPlay"] = Jellyfin::Support::toJsonValue(m_supportsDirectPlay); - result["IsInfiniteStream"] = Jellyfin::Support::toJsonValue(m_isInfiniteStream); - result["RequiresOpening"] = Jellyfin::Support::toJsonValue(m_requiresOpening); - result["OpenToken"] = Jellyfin::Support::toJsonValue(m_openToken); - result["RequiresClosing"] = Jellyfin::Support::toJsonValue(m_requiresClosing); - result["LiveStreamId"] = Jellyfin::Support::toJsonValue(m_liveStreamId); - result["BufferMs"] = Jellyfin::Support::toJsonValue>(m_bufferMs); - result["RequiresLooping"] = Jellyfin::Support::toJsonValue(m_requiresLooping); - result["SupportsProbing"] = Jellyfin::Support::toJsonValue(m_supportsProbing); - result["VideoType"] = Jellyfin::Support::toJsonValue(m_videoType); - result["IsoType"] = Jellyfin::Support::toJsonValue(m_isoType); - result["Video3DFormat"] = Jellyfin::Support::toJsonValue(m_video3DFormat); - result["MediaStreams"] = Jellyfin::Support::toJsonValue>(m_mediaStreams); - result["MediaAttachments"] = Jellyfin::Support::toJsonValue>(m_mediaAttachments); - result["Formats"] = Jellyfin::Support::toJsonValue(m_formats); - result["Bitrate"] = Jellyfin::Support::toJsonValue>(m_bitrate); - result["Timestamp"] = Jellyfin::Support::toJsonValue(m_timestamp); - result["RequiredHttpHeaders"] = Jellyfin::Support::toJsonValue(m_requiredHttpHeaders); - result["TranscodingUrl"] = Jellyfin::Support::toJsonValue(m_transcodingUrl); - result["TranscodingSubProtocol"] = Jellyfin::Support::toJsonValue(m_transcodingSubProtocol); - result["TranscodingContainer"] = Jellyfin::Support::toJsonValue(m_transcodingContainer); - result["AnalyzeDurationMs"] = Jellyfin::Support::toJsonValue>(m_analyzeDurationMs); - result["DefaultAudioStreamIndex"] = Jellyfin::Support::toJsonValue>(m_defaultAudioStreamIndex); - result["DefaultSubtitleStreamIndex"] = Jellyfin::Support::toJsonValue>(m_defaultSubtitleStreamIndex); - + + result["Protocol"] = Jellyfin::Support::toJsonValue(m_protocol); + + if (!(m_jellyfinId.isNull())) { + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + } + + + if (!(m_path.isNull())) { + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + } + + + if (!(m_encoderPath.isNull())) { + result["EncoderPath"] = Jellyfin::Support::toJsonValue(m_encoderPath); + } + + result["EncoderProtocol"] = Jellyfin::Support::toJsonValue(m_encoderProtocol); + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + + if (!(m_container.isNull())) { + result["Container"] = Jellyfin::Support::toJsonValue(m_container); + } + + + if (!(!m_size.has_value())) { + result["Size"] = Jellyfin::Support::toJsonValue>(m_size); + } + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + result["IsRemote"] = Jellyfin::Support::toJsonValue(m_isRemote); + + if (!(m_eTag.isNull())) { + result["ETag"] = Jellyfin::Support::toJsonValue(m_eTag); + } + + + if (!(!m_runTimeTicks.has_value())) { + result["RunTimeTicks"] = Jellyfin::Support::toJsonValue>(m_runTimeTicks); + } + + result["ReadAtNativeFramerate"] = Jellyfin::Support::toJsonValue(m_readAtNativeFramerate); + result["IgnoreDts"] = Jellyfin::Support::toJsonValue(m_ignoreDts); + result["IgnoreIndex"] = Jellyfin::Support::toJsonValue(m_ignoreIndex); + result["GenPtsInput"] = Jellyfin::Support::toJsonValue(m_genPtsInput); + result["SupportsTranscoding"] = Jellyfin::Support::toJsonValue(m_supportsTranscoding); + result["SupportsDirectStream"] = Jellyfin::Support::toJsonValue(m_supportsDirectStream); + result["SupportsDirectPlay"] = Jellyfin::Support::toJsonValue(m_supportsDirectPlay); + result["IsInfiniteStream"] = Jellyfin::Support::toJsonValue(m_isInfiniteStream); + result["RequiresOpening"] = Jellyfin::Support::toJsonValue(m_requiresOpening); + + if (!(m_openToken.isNull())) { + result["OpenToken"] = Jellyfin::Support::toJsonValue(m_openToken); + } + + result["RequiresClosing"] = Jellyfin::Support::toJsonValue(m_requiresClosing); + + if (!(m_liveStreamId.isNull())) { + result["LiveStreamId"] = Jellyfin::Support::toJsonValue(m_liveStreamId); + } + + + if (!(!m_bufferMs.has_value())) { + result["BufferMs"] = Jellyfin::Support::toJsonValue>(m_bufferMs); + } + + result["RequiresLooping"] = Jellyfin::Support::toJsonValue(m_requiresLooping); + result["SupportsProbing"] = Jellyfin::Support::toJsonValue(m_supportsProbing); + result["VideoType"] = Jellyfin::Support::toJsonValue(m_videoType); + result["IsoType"] = Jellyfin::Support::toJsonValue(m_isoType); + result["Video3DFormat"] = Jellyfin::Support::toJsonValue(m_video3DFormat); + + if (!(m_mediaStreams.size() == 0)) { + result["MediaStreams"] = Jellyfin::Support::toJsonValue>(m_mediaStreams); + } + + + if (!(m_mediaAttachments.size() == 0)) { + result["MediaAttachments"] = Jellyfin::Support::toJsonValue>(m_mediaAttachments); + } + + + if (!(m_formats.size() == 0)) { + result["Formats"] = Jellyfin::Support::toJsonValue(m_formats); + } + + + if (!(!m_bitrate.has_value())) { + result["Bitrate"] = Jellyfin::Support::toJsonValue>(m_bitrate); + } + + result["Timestamp"] = Jellyfin::Support::toJsonValue(m_timestamp); + + if (!(m_requiredHttpHeaders.isEmpty())) { + result["RequiredHttpHeaders"] = Jellyfin::Support::toJsonValue(m_requiredHttpHeaders); + } + + + if (!(m_transcodingUrl.isNull())) { + result["TranscodingUrl"] = Jellyfin::Support::toJsonValue(m_transcodingUrl); + } + + + if (!(m_transcodingSubProtocol.isNull())) { + result["TranscodingSubProtocol"] = Jellyfin::Support::toJsonValue(m_transcodingSubProtocol); + } + + + if (!(m_transcodingContainer.isNull())) { + result["TranscodingContainer"] = Jellyfin::Support::toJsonValue(m_transcodingContainer); + } + + + if (!(!m_analyzeDurationMs.has_value())) { + result["AnalyzeDurationMs"] = Jellyfin::Support::toJsonValue>(m_analyzeDurationMs); + } + + + if (!(!m_defaultAudioStreamIndex.has_value())) { + result["DefaultAudioStreamIndex"] = Jellyfin::Support::toJsonValue>(m_defaultAudioStreamIndex); + } + + + if (!(!m_defaultSubtitleStreamIndex.has_value())) { + result["DefaultSubtitleStreamIndex"] = Jellyfin::Support::toJsonValue>(m_defaultSubtitleStreamIndex); + } + return result; } diff --git a/core/src/dto/mediastream.cpp b/core/src/dto/mediastream.cpp index b4839c9..73907f4 100644 --- a/core/src/dto/mediastream.cpp +++ b/core/src/dto/mediastream.cpp @@ -195,54 +195,206 @@ void MediaStream::setFromJson(QJsonObject source) { QJsonObject MediaStream::toJson() const { QJsonObject result; - result["Codec"] = Jellyfin::Support::toJsonValue(m_codec); - result["CodecTag"] = Jellyfin::Support::toJsonValue(m_codecTag); - result["Language"] = Jellyfin::Support::toJsonValue(m_language); - result["ColorRange"] = Jellyfin::Support::toJsonValue(m_colorRange); - result["ColorSpace"] = Jellyfin::Support::toJsonValue(m_colorSpace); - result["ColorTransfer"] = Jellyfin::Support::toJsonValue(m_colorTransfer); - result["ColorPrimaries"] = Jellyfin::Support::toJsonValue(m_colorPrimaries); - result["Comment"] = Jellyfin::Support::toJsonValue(m_comment); - result["TimeBase"] = Jellyfin::Support::toJsonValue(m_timeBase); - result["CodecTimeBase"] = Jellyfin::Support::toJsonValue(m_codecTimeBase); - result["Title"] = Jellyfin::Support::toJsonValue(m_title); - result["VideoRange"] = Jellyfin::Support::toJsonValue(m_videoRange); - result["localizedUndefined"] = Jellyfin::Support::toJsonValue(m_localizedUndefined); - result["localizedDefault"] = Jellyfin::Support::toJsonValue(m_localizedDefault); - result["localizedForced"] = Jellyfin::Support::toJsonValue(m_localizedForced); - result["DisplayTitle"] = Jellyfin::Support::toJsonValue(m_displayTitle); - result["NalLengthSize"] = Jellyfin::Support::toJsonValue(m_nalLengthSize); - result["IsInterlaced"] = Jellyfin::Support::toJsonValue(m_isInterlaced); - result["IsAVC"] = Jellyfin::Support::toJsonValue>(m_isAVC); - result["ChannelLayout"] = Jellyfin::Support::toJsonValue(m_channelLayout); - result["BitRate"] = Jellyfin::Support::toJsonValue>(m_bitRate); - result["BitDepth"] = Jellyfin::Support::toJsonValue>(m_bitDepth); - result["RefFrames"] = Jellyfin::Support::toJsonValue>(m_refFrames); - result["PacketLength"] = Jellyfin::Support::toJsonValue>(m_packetLength); - result["Channels"] = Jellyfin::Support::toJsonValue>(m_channels); - result["SampleRate"] = Jellyfin::Support::toJsonValue>(m_sampleRate); - result["IsDefault"] = Jellyfin::Support::toJsonValue(m_isDefault); - result["IsForced"] = Jellyfin::Support::toJsonValue(m_isForced); - result["Height"] = Jellyfin::Support::toJsonValue>(m_height); - result["Width"] = Jellyfin::Support::toJsonValue>(m_width); - result["AverageFrameRate"] = Jellyfin::Support::toJsonValue>(m_averageFrameRate); - result["RealFrameRate"] = Jellyfin::Support::toJsonValue>(m_realFrameRate); - result["Profile"] = Jellyfin::Support::toJsonValue(m_profile); - result["Type"] = Jellyfin::Support::toJsonValue(m_type); - result["AspectRatio"] = Jellyfin::Support::toJsonValue(m_aspectRatio); - result["Index"] = Jellyfin::Support::toJsonValue(m_index); - result["Score"] = Jellyfin::Support::toJsonValue>(m_score); - result["IsExternal"] = Jellyfin::Support::toJsonValue(m_isExternal); - result["DeliveryMethod"] = Jellyfin::Support::toJsonValue(m_deliveryMethod); - result["DeliveryUrl"] = Jellyfin::Support::toJsonValue(m_deliveryUrl); - result["IsExternalUrl"] = Jellyfin::Support::toJsonValue>(m_isExternalUrl); - result["IsTextSubtitleStream"] = Jellyfin::Support::toJsonValue(m_isTextSubtitleStream); - result["SupportsExternalStream"] = Jellyfin::Support::toJsonValue(m_supportsExternalStream); - result["Path"] = Jellyfin::Support::toJsonValue(m_path); - result["PixelFormat"] = Jellyfin::Support::toJsonValue(m_pixelFormat); - result["Level"] = Jellyfin::Support::toJsonValue>(m_level); - result["IsAnamorphic"] = Jellyfin::Support::toJsonValue>(m_isAnamorphic); - + + + if (!(m_codec.isNull())) { + result["Codec"] = Jellyfin::Support::toJsonValue(m_codec); + } + + + if (!(m_codecTag.isNull())) { + result["CodecTag"] = Jellyfin::Support::toJsonValue(m_codecTag); + } + + + if (!(m_language.isNull())) { + result["Language"] = Jellyfin::Support::toJsonValue(m_language); + } + + + if (!(m_colorRange.isNull())) { + result["ColorRange"] = Jellyfin::Support::toJsonValue(m_colorRange); + } + + + if (!(m_colorSpace.isNull())) { + result["ColorSpace"] = Jellyfin::Support::toJsonValue(m_colorSpace); + } + + + if (!(m_colorTransfer.isNull())) { + result["ColorTransfer"] = Jellyfin::Support::toJsonValue(m_colorTransfer); + } + + + if (!(m_colorPrimaries.isNull())) { + result["ColorPrimaries"] = Jellyfin::Support::toJsonValue(m_colorPrimaries); + } + + + if (!(m_comment.isNull())) { + result["Comment"] = Jellyfin::Support::toJsonValue(m_comment); + } + + + if (!(m_timeBase.isNull())) { + result["TimeBase"] = Jellyfin::Support::toJsonValue(m_timeBase); + } + + + if (!(m_codecTimeBase.isNull())) { + result["CodecTimeBase"] = Jellyfin::Support::toJsonValue(m_codecTimeBase); + } + + + if (!(m_title.isNull())) { + result["Title"] = Jellyfin::Support::toJsonValue(m_title); + } + + + if (!(m_videoRange.isNull())) { + result["VideoRange"] = Jellyfin::Support::toJsonValue(m_videoRange); + } + + + if (!(m_localizedUndefined.isNull())) { + result["localizedUndefined"] = Jellyfin::Support::toJsonValue(m_localizedUndefined); + } + + + if (!(m_localizedDefault.isNull())) { + result["localizedDefault"] = Jellyfin::Support::toJsonValue(m_localizedDefault); + } + + + if (!(m_localizedForced.isNull())) { + result["localizedForced"] = Jellyfin::Support::toJsonValue(m_localizedForced); + } + + + if (!(m_displayTitle.isNull())) { + result["DisplayTitle"] = Jellyfin::Support::toJsonValue(m_displayTitle); + } + + + if (!(m_nalLengthSize.isNull())) { + result["NalLengthSize"] = Jellyfin::Support::toJsonValue(m_nalLengthSize); + } + + result["IsInterlaced"] = Jellyfin::Support::toJsonValue(m_isInterlaced); + + if (!(!m_isAVC.has_value())) { + result["IsAVC"] = Jellyfin::Support::toJsonValue>(m_isAVC); + } + + + if (!(m_channelLayout.isNull())) { + result["ChannelLayout"] = Jellyfin::Support::toJsonValue(m_channelLayout); + } + + + if (!(!m_bitRate.has_value())) { + result["BitRate"] = Jellyfin::Support::toJsonValue>(m_bitRate); + } + + + if (!(!m_bitDepth.has_value())) { + result["BitDepth"] = Jellyfin::Support::toJsonValue>(m_bitDepth); + } + + + if (!(!m_refFrames.has_value())) { + result["RefFrames"] = Jellyfin::Support::toJsonValue>(m_refFrames); + } + + + if (!(!m_packetLength.has_value())) { + result["PacketLength"] = Jellyfin::Support::toJsonValue>(m_packetLength); + } + + + if (!(!m_channels.has_value())) { + result["Channels"] = Jellyfin::Support::toJsonValue>(m_channels); + } + + + if (!(!m_sampleRate.has_value())) { + result["SampleRate"] = Jellyfin::Support::toJsonValue>(m_sampleRate); + } + + result["IsDefault"] = Jellyfin::Support::toJsonValue(m_isDefault); + result["IsForced"] = Jellyfin::Support::toJsonValue(m_isForced); + + if (!(!m_height.has_value())) { + result["Height"] = Jellyfin::Support::toJsonValue>(m_height); + } + + + if (!(!m_width.has_value())) { + result["Width"] = Jellyfin::Support::toJsonValue>(m_width); + } + + + if (!(!m_averageFrameRate.has_value())) { + result["AverageFrameRate"] = Jellyfin::Support::toJsonValue>(m_averageFrameRate); + } + + + if (!(!m_realFrameRate.has_value())) { + result["RealFrameRate"] = Jellyfin::Support::toJsonValue>(m_realFrameRate); + } + + + if (!(m_profile.isNull())) { + result["Profile"] = Jellyfin::Support::toJsonValue(m_profile); + } + + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + + if (!(m_aspectRatio.isNull())) { + result["AspectRatio"] = Jellyfin::Support::toJsonValue(m_aspectRatio); + } + + result["Index"] = Jellyfin::Support::toJsonValue(m_index); + + if (!(!m_score.has_value())) { + result["Score"] = Jellyfin::Support::toJsonValue>(m_score); + } + + result["IsExternal"] = Jellyfin::Support::toJsonValue(m_isExternal); + result["DeliveryMethod"] = Jellyfin::Support::toJsonValue(m_deliveryMethod); + + if (!(m_deliveryUrl.isNull())) { + result["DeliveryUrl"] = Jellyfin::Support::toJsonValue(m_deliveryUrl); + } + + + if (!(!m_isExternalUrl.has_value())) { + result["IsExternalUrl"] = Jellyfin::Support::toJsonValue>(m_isExternalUrl); + } + + result["IsTextSubtitleStream"] = Jellyfin::Support::toJsonValue(m_isTextSubtitleStream); + result["SupportsExternalStream"] = Jellyfin::Support::toJsonValue(m_supportsExternalStream); + + if (!(m_path.isNull())) { + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + } + + + if (!(m_pixelFormat.isNull())) { + result["PixelFormat"] = Jellyfin::Support::toJsonValue(m_pixelFormat); + } + + + if (!(!m_level.has_value())) { + result["Level"] = Jellyfin::Support::toJsonValue>(m_level); + } + + + if (!(!m_isAnamorphic.has_value())) { + result["IsAnamorphic"] = Jellyfin::Support::toJsonValue>(m_isAnamorphic); + } + return result; } diff --git a/core/src/dto/mediaupdateinfodto.cpp b/core/src/dto/mediaupdateinfodto.cpp index 24ba17c..100f5c3 100644 --- a/core/src/dto/mediaupdateinfodto.cpp +++ b/core/src/dto/mediaupdateinfodto.cpp @@ -60,9 +60,17 @@ void MediaUpdateInfoDto::setFromJson(QJsonObject source) { QJsonObject MediaUpdateInfoDto::toJson() const { QJsonObject result; - result["Path"] = Jellyfin::Support::toJsonValue(m_path); - result["UpdateType"] = Jellyfin::Support::toJsonValue(m_updateType); - + + + if (!(m_path.isNull())) { + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + } + + + if (!(m_updateType.isNull())) { + result["UpdateType"] = Jellyfin::Support::toJsonValue(m_updateType); + } + return result; } diff --git a/core/src/dto/mediaurl.cpp b/core/src/dto/mediaurl.cpp index 6f8ed34..aca3d35 100644 --- a/core/src/dto/mediaurl.cpp +++ b/core/src/dto/mediaurl.cpp @@ -60,9 +60,17 @@ void MediaUrl::setFromJson(QJsonObject source) { QJsonObject MediaUrl::toJson() const { QJsonObject result; - result["Url"] = Jellyfin::Support::toJsonValue(m_url); - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - + + + if (!(m_url.isNull())) { + result["Url"] = Jellyfin::Support::toJsonValue(m_url); + } + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + return result; } diff --git a/core/src/dto/metadataeditorinfo.cpp b/core/src/dto/metadataeditorinfo.cpp index f63408d..9d975f9 100644 --- a/core/src/dto/metadataeditorinfo.cpp +++ b/core/src/dto/metadataeditorinfo.cpp @@ -72,13 +72,37 @@ void MetadataEditorInfo::setFromJson(QJsonObject source) { QJsonObject MetadataEditorInfo::toJson() const { QJsonObject result; - result["ParentalRatingOptions"] = Jellyfin::Support::toJsonValue>(m_parentalRatingOptions); - result["Countries"] = Jellyfin::Support::toJsonValue>(m_countries); - result["Cultures"] = Jellyfin::Support::toJsonValue>(m_cultures); - result["ExternalIdInfos"] = Jellyfin::Support::toJsonValue>(m_externalIdInfos); - result["ContentType"] = Jellyfin::Support::toJsonValue(m_contentType); - result["ContentTypeOptions"] = Jellyfin::Support::toJsonValue>(m_contentTypeOptions); - + + + if (!(m_parentalRatingOptions.size() == 0)) { + result["ParentalRatingOptions"] = Jellyfin::Support::toJsonValue>(m_parentalRatingOptions); + } + + + if (!(m_countries.size() == 0)) { + result["Countries"] = Jellyfin::Support::toJsonValue>(m_countries); + } + + + if (!(m_cultures.size() == 0)) { + result["Cultures"] = Jellyfin::Support::toJsonValue>(m_cultures); + } + + + if (!(m_externalIdInfos.size() == 0)) { + result["ExternalIdInfos"] = Jellyfin::Support::toJsonValue>(m_externalIdInfos); + } + + + if (!(m_contentType.isNull())) { + result["ContentType"] = Jellyfin::Support::toJsonValue(m_contentType); + } + + + if (!(m_contentTypeOptions.size() == 0)) { + result["ContentTypeOptions"] = Jellyfin::Support::toJsonValue>(m_contentTypeOptions); + } + return result; } diff --git a/core/src/dto/metadataoptions.cpp b/core/src/dto/metadataoptions.cpp index 05c3206..8f7cc44 100644 --- a/core/src/dto/metadataoptions.cpp +++ b/core/src/dto/metadataoptions.cpp @@ -75,14 +75,42 @@ void MetadataOptions::setFromJson(QJsonObject source) { QJsonObject MetadataOptions::toJson() const { QJsonObject result; - result["ItemType"] = Jellyfin::Support::toJsonValue(m_itemType); - result["DisabledMetadataSavers"] = Jellyfin::Support::toJsonValue(m_disabledMetadataSavers); - result["LocalMetadataReaderOrder"] = Jellyfin::Support::toJsonValue(m_localMetadataReaderOrder); - result["DisabledMetadataFetchers"] = Jellyfin::Support::toJsonValue(m_disabledMetadataFetchers); - result["MetadataFetcherOrder"] = Jellyfin::Support::toJsonValue(m_metadataFetcherOrder); - result["DisabledImageFetchers"] = Jellyfin::Support::toJsonValue(m_disabledImageFetchers); - result["ImageFetcherOrder"] = Jellyfin::Support::toJsonValue(m_imageFetcherOrder); - + + + if (!(m_itemType.isNull())) { + result["ItemType"] = Jellyfin::Support::toJsonValue(m_itemType); + } + + + if (!(m_disabledMetadataSavers.size() == 0)) { + result["DisabledMetadataSavers"] = Jellyfin::Support::toJsonValue(m_disabledMetadataSavers); + } + + + if (!(m_localMetadataReaderOrder.size() == 0)) { + result["LocalMetadataReaderOrder"] = Jellyfin::Support::toJsonValue(m_localMetadataReaderOrder); + } + + + if (!(m_disabledMetadataFetchers.size() == 0)) { + result["DisabledMetadataFetchers"] = Jellyfin::Support::toJsonValue(m_disabledMetadataFetchers); + } + + + if (!(m_metadataFetcherOrder.size() == 0)) { + result["MetadataFetcherOrder"] = Jellyfin::Support::toJsonValue(m_metadataFetcherOrder); + } + + + if (!(m_disabledImageFetchers.size() == 0)) { + result["DisabledImageFetchers"] = Jellyfin::Support::toJsonValue(m_disabledImageFetchers); + } + + + if (!(m_imageFetcherOrder.size() == 0)) { + result["ImageFetcherOrder"] = Jellyfin::Support::toJsonValue(m_imageFetcherOrder); + } + return result; } diff --git a/core/src/dto/moveplaylistitemrequestdto.cpp b/core/src/dto/moveplaylistitemrequestdto.cpp index 8c246ef..912c5a7 100644 --- a/core/src/dto/moveplaylistitemrequestdto.cpp +++ b/core/src/dto/moveplaylistitemrequestdto.cpp @@ -60,9 +60,9 @@ void MovePlaylistItemRequestDto::setFromJson(QJsonObject source) { QJsonObject MovePlaylistItemRequestDto::toJson() const { QJsonObject result; - result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); - result["NewIndex"] = Jellyfin::Support::toJsonValue(m_newIndex); - + + result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); + result["NewIndex"] = Jellyfin::Support::toJsonValue(m_newIndex); return result; } diff --git a/core/src/dto/movieinfo.cpp b/core/src/dto/movieinfo.cpp index 9237c36..d100d52 100644 --- a/core/src/dto/movieinfo.cpp +++ b/core/src/dto/movieinfo.cpp @@ -84,17 +84,53 @@ void MovieInfo::setFromJson(QJsonObject source) { QJsonObject MovieInfo::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Path"] = Jellyfin::Support::toJsonValue(m_path); - result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); - result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); - result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); - result["Year"] = Jellyfin::Support::toJsonValue>(m_year); - result["IndexNumber"] = Jellyfin::Support::toJsonValue>(m_indexNumber); - result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue>(m_parentIndexNumber); - result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); - result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_path.isNull())) { + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + } + + + if (!(m_metadataLanguage.isNull())) { + result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); + } + + + if (!(m_metadataCountryCode.isNull())) { + result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); + } + + + if (!(m_providerIds.isEmpty())) { + result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); + } + + + if (!(!m_year.has_value())) { + result["Year"] = Jellyfin::Support::toJsonValue>(m_year); + } + + + if (!(!m_indexNumber.has_value())) { + result["IndexNumber"] = Jellyfin::Support::toJsonValue>(m_indexNumber); + } + + + if (!(!m_parentIndexNumber.has_value())) { + result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue>(m_parentIndexNumber); + } + + + if (!(m_premiereDate.isNull())) { + result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); + } + + result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); return result; } diff --git a/core/src/dto/movieinforemotesearchquery.cpp b/core/src/dto/movieinforemotesearchquery.cpp index 21a3b2f..8a91039 100644 --- a/core/src/dto/movieinforemotesearchquery.cpp +++ b/core/src/dto/movieinforemotesearchquery.cpp @@ -66,11 +66,15 @@ void MovieInfoRemoteSearchQuery::setFromJson(QJsonObject source) { QJsonObject MovieInfoRemoteSearchQuery::toJson() const { QJsonObject result; - result["SearchInfo"] = Jellyfin::Support::toJsonValue>(m_searchInfo); - result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); - result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); - result["IncludeDisabledProviders"] = Jellyfin::Support::toJsonValue(m_includeDisabledProviders); - + + result["SearchInfo"] = Jellyfin::Support::toJsonValue>(m_searchInfo); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + + if (!(m_searchProviderName.isNull())) { + result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); + } + + result["IncludeDisabledProviders"] = Jellyfin::Support::toJsonValue(m_includeDisabledProviders); return result; } diff --git a/core/src/dto/musicvideoinfo.cpp b/core/src/dto/musicvideoinfo.cpp index 2848129..08b8cb0 100644 --- a/core/src/dto/musicvideoinfo.cpp +++ b/core/src/dto/musicvideoinfo.cpp @@ -87,18 +87,58 @@ void MusicVideoInfo::setFromJson(QJsonObject source) { QJsonObject MusicVideoInfo::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Path"] = Jellyfin::Support::toJsonValue(m_path); - result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); - result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); - result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); - result["Year"] = Jellyfin::Support::toJsonValue>(m_year); - result["IndexNumber"] = Jellyfin::Support::toJsonValue>(m_indexNumber); - result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue>(m_parentIndexNumber); - result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); - result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); - result["Artists"] = Jellyfin::Support::toJsonValue(m_artists); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_path.isNull())) { + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + } + + + if (!(m_metadataLanguage.isNull())) { + result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); + } + + + if (!(m_metadataCountryCode.isNull())) { + result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); + } + + + if (!(m_providerIds.isEmpty())) { + result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); + } + + + if (!(!m_year.has_value())) { + result["Year"] = Jellyfin::Support::toJsonValue>(m_year); + } + + + if (!(!m_indexNumber.has_value())) { + result["IndexNumber"] = Jellyfin::Support::toJsonValue>(m_indexNumber); + } + + + if (!(!m_parentIndexNumber.has_value())) { + result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue>(m_parentIndexNumber); + } + + + if (!(m_premiereDate.isNull())) { + result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); + } + + result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); + + if (!(m_artists.size() == 0)) { + result["Artists"] = Jellyfin::Support::toJsonValue(m_artists); + } + return result; } diff --git a/core/src/dto/musicvideoinforemotesearchquery.cpp b/core/src/dto/musicvideoinforemotesearchquery.cpp index 139cd90..91fd1d7 100644 --- a/core/src/dto/musicvideoinforemotesearchquery.cpp +++ b/core/src/dto/musicvideoinforemotesearchquery.cpp @@ -66,11 +66,15 @@ void MusicVideoInfoRemoteSearchQuery::setFromJson(QJsonObject source) { QJsonObject MusicVideoInfoRemoteSearchQuery::toJson() const { QJsonObject result; - result["SearchInfo"] = Jellyfin::Support::toJsonValue>(m_searchInfo); - result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); - result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); - result["IncludeDisabledProviders"] = Jellyfin::Support::toJsonValue(m_includeDisabledProviders); - + + result["SearchInfo"] = Jellyfin::Support::toJsonValue>(m_searchInfo); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + + if (!(m_searchProviderName.isNull())) { + result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); + } + + result["IncludeDisabledProviders"] = Jellyfin::Support::toJsonValue(m_includeDisabledProviders); return result; } diff --git a/core/src/dto/nameguidpair.cpp b/core/src/dto/nameguidpair.cpp index 4c8f05e..741e915 100644 --- a/core/src/dto/nameguidpair.cpp +++ b/core/src/dto/nameguidpair.cpp @@ -60,9 +60,13 @@ void NameGuidPair::setFromJson(QJsonObject source) { QJsonObject NameGuidPair::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); return result; } diff --git a/core/src/dto/nameidpair.cpp b/core/src/dto/nameidpair.cpp index 918cb77..3080edd 100644 --- a/core/src/dto/nameidpair.cpp +++ b/core/src/dto/nameidpair.cpp @@ -60,9 +60,17 @@ void NameIdPair::setFromJson(QJsonObject source) { QJsonObject NameIdPair::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_jellyfinId.isNull())) { + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + } + return result; } diff --git a/core/src/dto/namevaluepair.cpp b/core/src/dto/namevaluepair.cpp index 93d5eac..bee645d 100644 --- a/core/src/dto/namevaluepair.cpp +++ b/core/src/dto/namevaluepair.cpp @@ -60,9 +60,17 @@ void NameValuePair::setFromJson(QJsonObject source) { QJsonObject NameValuePair::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Value"] = Jellyfin::Support::toJsonValue(m_value); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_value.isNull())) { + result["Value"] = Jellyfin::Support::toJsonValue(m_value); + } + return result; } diff --git a/core/src/dto/newgrouprequestdto.cpp b/core/src/dto/newgrouprequestdto.cpp index 3c75c3e..dcf67ee 100644 --- a/core/src/dto/newgrouprequestdto.cpp +++ b/core/src/dto/newgrouprequestdto.cpp @@ -57,8 +57,12 @@ void NewGroupRequestDto::setFromJson(QJsonObject source) { QJsonObject NewGroupRequestDto::toJson() const { QJsonObject result; - result["GroupName"] = Jellyfin::Support::toJsonValue(m_groupName); - + + + if (!(m_groupName.isNull())) { + result["GroupName"] = Jellyfin::Support::toJsonValue(m_groupName); + } + return result; } diff --git a/core/src/dto/nextitemrequestdto.cpp b/core/src/dto/nextitemrequestdto.cpp index 0ac4662..800179e 100644 --- a/core/src/dto/nextitemrequestdto.cpp +++ b/core/src/dto/nextitemrequestdto.cpp @@ -57,8 +57,8 @@ void NextItemRequestDto::setFromJson(QJsonObject source) { QJsonObject NextItemRequestDto::toJson() const { QJsonObject result; - result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); - + + result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); return result; } diff --git a/core/src/dto/notificationdto.cpp b/core/src/dto/notificationdto.cpp index eddee22..b196798 100644 --- a/core/src/dto/notificationdto.cpp +++ b/core/src/dto/notificationdto.cpp @@ -78,15 +78,35 @@ void NotificationDto::setFromJson(QJsonObject source) { QJsonObject NotificationDto::toJson() const { QJsonObject result; - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); - result["Date"] = Jellyfin::Support::toJsonValue(m_date); - result["IsRead"] = Jellyfin::Support::toJsonValue(m_isRead); - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Description"] = Jellyfin::Support::toJsonValue(m_description); - result["Url"] = Jellyfin::Support::toJsonValue(m_url); - result["Level"] = Jellyfin::Support::toJsonValue(m_level); - + + + if (!(m_jellyfinId.isNull())) { + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + } + + + if (!(m_userId.isNull())) { + result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); + } + + result["Date"] = Jellyfin::Support::toJsonValue(m_date); + result["IsRead"] = Jellyfin::Support::toJsonValue(m_isRead); + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_description.isNull())) { + result["Description"] = Jellyfin::Support::toJsonValue(m_description); + } + + + if (!(m_url.isNull())) { + result["Url"] = Jellyfin::Support::toJsonValue(m_url); + } + + result["Level"] = Jellyfin::Support::toJsonValue(m_level); return result; } diff --git a/core/src/dto/notificationresultdto.cpp b/core/src/dto/notificationresultdto.cpp index 138f5c9..9e28633 100644 --- a/core/src/dto/notificationresultdto.cpp +++ b/core/src/dto/notificationresultdto.cpp @@ -60,9 +60,13 @@ void NotificationResultDto::setFromJson(QJsonObject source) { QJsonObject NotificationResultDto::toJson() const { QJsonObject result; - result["Notifications"] = Jellyfin::Support::toJsonValue>(m_notifications); - result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); - + + + if (!(m_notifications.size() == 0)) { + result["Notifications"] = Jellyfin::Support::toJsonValue>(m_notifications); + } + + result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); return result; } diff --git a/core/src/dto/notificationssummarydto.cpp b/core/src/dto/notificationssummarydto.cpp index 4ef4fde..bf45aa6 100644 --- a/core/src/dto/notificationssummarydto.cpp +++ b/core/src/dto/notificationssummarydto.cpp @@ -60,9 +60,9 @@ void NotificationsSummaryDto::setFromJson(QJsonObject source) { QJsonObject NotificationsSummaryDto::toJson() const { QJsonObject result; - result["UnreadCount"] = Jellyfin::Support::toJsonValue(m_unreadCount); - result["MaxUnreadNotificationLevel"] = Jellyfin::Support::toJsonValue(m_maxUnreadNotificationLevel); - + + result["UnreadCount"] = Jellyfin::Support::toJsonValue(m_unreadCount); + result["MaxUnreadNotificationLevel"] = Jellyfin::Support::toJsonValue(m_maxUnreadNotificationLevel); return result; } diff --git a/core/src/dto/notificationtypeinfo.cpp b/core/src/dto/notificationtypeinfo.cpp index 72cbce0..4bb6be6 100644 --- a/core/src/dto/notificationtypeinfo.cpp +++ b/core/src/dto/notificationtypeinfo.cpp @@ -69,12 +69,24 @@ void NotificationTypeInfo::setFromJson(QJsonObject source) { QJsonObject NotificationTypeInfo::toJson() const { QJsonObject result; - result["Type"] = Jellyfin::Support::toJsonValue(m_type); - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Enabled"] = Jellyfin::Support::toJsonValue(m_enabled); - result["Category"] = Jellyfin::Support::toJsonValue(m_category); - result["IsBasedOnUserEvent"] = Jellyfin::Support::toJsonValue(m_isBasedOnUserEvent); - + + + if (!(m_type.isNull())) { + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + } + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + result["Enabled"] = Jellyfin::Support::toJsonValue(m_enabled); + + if (!(m_category.isNull())) { + result["Category"] = Jellyfin::Support::toJsonValue(m_category); + } + + result["IsBasedOnUserEvent"] = Jellyfin::Support::toJsonValue(m_isBasedOnUserEvent); return result; } diff --git a/core/src/dto/objectgroupupdate.cpp b/core/src/dto/objectgroupupdate.cpp index bed40ba..95a06f9 100644 --- a/core/src/dto/objectgroupupdate.cpp +++ b/core/src/dto/objectgroupupdate.cpp @@ -63,10 +63,10 @@ void ObjectGroupUpdate::setFromJson(QJsonObject source) { QJsonObject ObjectGroupUpdate::toJson() const { QJsonObject result; - result["GroupId"] = Jellyfin::Support::toJsonValue(m_groupId); - result["Type"] = Jellyfin::Support::toJsonValue(m_type); - result["Data"] = Jellyfin::Support::toJsonValue(m_data); - + + result["GroupId"] = Jellyfin::Support::toJsonValue(m_groupId); + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + result["Data"] = Jellyfin::Support::toJsonValue(m_data); return result; } diff --git a/core/src/dto/openlivestreamdto.cpp b/core/src/dto/openlivestreamdto.cpp index 9ce6ded..d7739fa 100644 --- a/core/src/dto/openlivestreamdto.cpp +++ b/core/src/dto/openlivestreamdto.cpp @@ -93,20 +93,68 @@ void OpenLiveStreamDto::setFromJson(QJsonObject source) { QJsonObject OpenLiveStreamDto::toJson() const { QJsonObject result; - result["OpenToken"] = Jellyfin::Support::toJsonValue(m_openToken); - result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); - result["PlaySessionId"] = Jellyfin::Support::toJsonValue(m_playSessionId); - result["MaxStreamingBitrate"] = Jellyfin::Support::toJsonValue>(m_maxStreamingBitrate); - result["StartTimeTicks"] = Jellyfin::Support::toJsonValue>(m_startTimeTicks); - result["AudioStreamIndex"] = Jellyfin::Support::toJsonValue>(m_audioStreamIndex); - result["SubtitleStreamIndex"] = Jellyfin::Support::toJsonValue>(m_subtitleStreamIndex); - result["MaxAudioChannels"] = Jellyfin::Support::toJsonValue>(m_maxAudioChannels); - result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); - result["EnableDirectPlay"] = Jellyfin::Support::toJsonValue>(m_enableDirectPlay); - result["EnableDirectStream"] = Jellyfin::Support::toJsonValue>(m_enableDirectStream); - result["DeviceProfile"] = Jellyfin::Support::toJsonValue>(m_deviceProfile); - result["DirectPlayProtocols"] = Jellyfin::Support::toJsonValue>(m_directPlayProtocols); - + + + if (!(m_openToken.isNull())) { + result["OpenToken"] = Jellyfin::Support::toJsonValue(m_openToken); + } + + + if (!(m_userId.isNull())) { + result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); + } + + + if (!(m_playSessionId.isNull())) { + result["PlaySessionId"] = Jellyfin::Support::toJsonValue(m_playSessionId); + } + + + if (!(!m_maxStreamingBitrate.has_value())) { + result["MaxStreamingBitrate"] = Jellyfin::Support::toJsonValue>(m_maxStreamingBitrate); + } + + + if (!(!m_startTimeTicks.has_value())) { + result["StartTimeTicks"] = Jellyfin::Support::toJsonValue>(m_startTimeTicks); + } + + + if (!(!m_audioStreamIndex.has_value())) { + result["AudioStreamIndex"] = Jellyfin::Support::toJsonValue>(m_audioStreamIndex); + } + + + if (!(!m_subtitleStreamIndex.has_value())) { + result["SubtitleStreamIndex"] = Jellyfin::Support::toJsonValue>(m_subtitleStreamIndex); + } + + + if (!(!m_maxAudioChannels.has_value())) { + result["MaxAudioChannels"] = Jellyfin::Support::toJsonValue>(m_maxAudioChannels); + } + + + if (!(m_itemId.isNull())) { + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + } + + + if (!(!m_enableDirectPlay.has_value())) { + result["EnableDirectPlay"] = Jellyfin::Support::toJsonValue>(m_enableDirectPlay); + } + + + if (!(!m_enableDirectStream.has_value())) { + result["EnableDirectStream"] = Jellyfin::Support::toJsonValue>(m_enableDirectStream); + } + + result["DeviceProfile"] = Jellyfin::Support::toJsonValue>(m_deviceProfile); + + if (!(m_directPlayProtocols.size() == 0)) { + result["DirectPlayProtocols"] = Jellyfin::Support::toJsonValue>(m_directPlayProtocols); + } + return result; } diff --git a/core/src/dto/packageinfo.cpp b/core/src/dto/packageinfo.cpp index 1ce8d81..263c139 100644 --- a/core/src/dto/packageinfo.cpp +++ b/core/src/dto/packageinfo.cpp @@ -78,15 +78,47 @@ void PackageInfo::setFromJson(QJsonObject source) { QJsonObject PackageInfo::toJson() const { QJsonObject result; - result["name"] = Jellyfin::Support::toJsonValue(m_name); - result["description"] = Jellyfin::Support::toJsonValue(m_description); - result["overview"] = Jellyfin::Support::toJsonValue(m_overview); - result["owner"] = Jellyfin::Support::toJsonValue(m_owner); - result["category"] = Jellyfin::Support::toJsonValue(m_category); - result["guid"] = Jellyfin::Support::toJsonValue(m_guid); - result["versions"] = Jellyfin::Support::toJsonValue>(m_versions); - result["imageUrl"] = Jellyfin::Support::toJsonValue(m_imageUrl); - + + + if (!(m_name.isNull())) { + result["name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_description.isNull())) { + result["description"] = Jellyfin::Support::toJsonValue(m_description); + } + + + if (!(m_overview.isNull())) { + result["overview"] = Jellyfin::Support::toJsonValue(m_overview); + } + + + if (!(m_owner.isNull())) { + result["owner"] = Jellyfin::Support::toJsonValue(m_owner); + } + + + if (!(m_category.isNull())) { + result["category"] = Jellyfin::Support::toJsonValue(m_category); + } + + + if (!(m_guid.isNull())) { + result["guid"] = Jellyfin::Support::toJsonValue(m_guid); + } + + + if (!(m_versions.size() == 0)) { + result["versions"] = Jellyfin::Support::toJsonValue>(m_versions); + } + + + if (!(m_imageUrl.isNull())) { + result["imageUrl"] = Jellyfin::Support::toJsonValue(m_imageUrl); + } + return result; } diff --git a/core/src/dto/parentalrating.cpp b/core/src/dto/parentalrating.cpp index 5875ae5..ffb329e 100644 --- a/core/src/dto/parentalrating.cpp +++ b/core/src/dto/parentalrating.cpp @@ -60,9 +60,13 @@ void ParentalRating::setFromJson(QJsonObject source) { QJsonObject ParentalRating::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Value"] = Jellyfin::Support::toJsonValue(m_value); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + result["Value"] = Jellyfin::Support::toJsonValue(m_value); return result; } diff --git a/core/src/dto/pathsubstitution.cpp b/core/src/dto/pathsubstitution.cpp index 140a48e..a4c2caa 100644 --- a/core/src/dto/pathsubstitution.cpp +++ b/core/src/dto/pathsubstitution.cpp @@ -60,9 +60,17 @@ void PathSubstitution::setFromJson(QJsonObject source) { QJsonObject PathSubstitution::toJson() const { QJsonObject result; - result["From"] = Jellyfin::Support::toJsonValue(m_from); - result["To"] = Jellyfin::Support::toJsonValue(m_to); - + + + if (!(m_from.isNull())) { + result["From"] = Jellyfin::Support::toJsonValue(m_from); + } + + + if (!(m_to.isNull())) { + result["To"] = Jellyfin::Support::toJsonValue(m_to); + } + return result; } diff --git a/core/src/dto/personlookupinfo.cpp b/core/src/dto/personlookupinfo.cpp index b07e67d..2052b41 100644 --- a/core/src/dto/personlookupinfo.cpp +++ b/core/src/dto/personlookupinfo.cpp @@ -84,17 +84,53 @@ void PersonLookupInfo::setFromJson(QJsonObject source) { QJsonObject PersonLookupInfo::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Path"] = Jellyfin::Support::toJsonValue(m_path); - result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); - result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); - result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); - result["Year"] = Jellyfin::Support::toJsonValue>(m_year); - result["IndexNumber"] = Jellyfin::Support::toJsonValue>(m_indexNumber); - result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue>(m_parentIndexNumber); - result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); - result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_path.isNull())) { + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + } + + + if (!(m_metadataLanguage.isNull())) { + result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); + } + + + if (!(m_metadataCountryCode.isNull())) { + result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); + } + + + if (!(m_providerIds.isEmpty())) { + result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); + } + + + if (!(!m_year.has_value())) { + result["Year"] = Jellyfin::Support::toJsonValue>(m_year); + } + + + if (!(!m_indexNumber.has_value())) { + result["IndexNumber"] = Jellyfin::Support::toJsonValue>(m_indexNumber); + } + + + if (!(!m_parentIndexNumber.has_value())) { + result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue>(m_parentIndexNumber); + } + + + if (!(m_premiereDate.isNull())) { + result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); + } + + result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); return result; } diff --git a/core/src/dto/personlookupinforemotesearchquery.cpp b/core/src/dto/personlookupinforemotesearchquery.cpp index 3fbf2d7..5d570be 100644 --- a/core/src/dto/personlookupinforemotesearchquery.cpp +++ b/core/src/dto/personlookupinforemotesearchquery.cpp @@ -66,11 +66,15 @@ void PersonLookupInfoRemoteSearchQuery::setFromJson(QJsonObject source) { QJsonObject PersonLookupInfoRemoteSearchQuery::toJson() const { QJsonObject result; - result["SearchInfo"] = Jellyfin::Support::toJsonValue>(m_searchInfo); - result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); - result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); - result["IncludeDisabledProviders"] = Jellyfin::Support::toJsonValue(m_includeDisabledProviders); - + + result["SearchInfo"] = Jellyfin::Support::toJsonValue>(m_searchInfo); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + + if (!(m_searchProviderName.isNull())) { + result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); + } + + result["IncludeDisabledProviders"] = Jellyfin::Support::toJsonValue(m_includeDisabledProviders); return result; } diff --git a/core/src/dto/pingrequestdto.cpp b/core/src/dto/pingrequestdto.cpp index fd95280..8504d42 100644 --- a/core/src/dto/pingrequestdto.cpp +++ b/core/src/dto/pingrequestdto.cpp @@ -57,8 +57,8 @@ void PingRequestDto::setFromJson(QJsonObject source) { QJsonObject PingRequestDto::toJson() const { QJsonObject result; - result["Ping"] = Jellyfin::Support::toJsonValue(m_ping); - + + result["Ping"] = Jellyfin::Support::toJsonValue(m_ping); return result; } diff --git a/core/src/dto/pinredeemresult.cpp b/core/src/dto/pinredeemresult.cpp index dd2bbd2..5d8642e 100644 --- a/core/src/dto/pinredeemresult.cpp +++ b/core/src/dto/pinredeemresult.cpp @@ -60,9 +60,13 @@ void PinRedeemResult::setFromJson(QJsonObject source) { QJsonObject PinRedeemResult::toJson() const { QJsonObject result; - result["Success"] = Jellyfin::Support::toJsonValue(m_success); - result["UsersReset"] = Jellyfin::Support::toJsonValue(m_usersReset); - + + result["Success"] = Jellyfin::Support::toJsonValue(m_success); + + if (!(m_usersReset.size() == 0)) { + result["UsersReset"] = Jellyfin::Support::toJsonValue(m_usersReset); + } + return result; } diff --git a/core/src/dto/playbackinfodto.cpp b/core/src/dto/playbackinfodto.cpp index a7e27af..80d1524 100644 --- a/core/src/dto/playbackinfodto.cpp +++ b/core/src/dto/playbackinfodto.cpp @@ -99,22 +99,78 @@ void PlaybackInfoDto::setFromJson(QJsonObject source) { QJsonObject PlaybackInfoDto::toJson() const { QJsonObject result; - result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); - result["MaxStreamingBitrate"] = Jellyfin::Support::toJsonValue>(m_maxStreamingBitrate); - result["StartTimeTicks"] = Jellyfin::Support::toJsonValue>(m_startTimeTicks); - result["AudioStreamIndex"] = Jellyfin::Support::toJsonValue>(m_audioStreamIndex); - result["SubtitleStreamIndex"] = Jellyfin::Support::toJsonValue>(m_subtitleStreamIndex); - result["MaxAudioChannels"] = Jellyfin::Support::toJsonValue>(m_maxAudioChannels); - result["MediaSourceId"] = Jellyfin::Support::toJsonValue(m_mediaSourceId); - result["LiveStreamId"] = Jellyfin::Support::toJsonValue(m_liveStreamId); - result["DeviceProfile"] = Jellyfin::Support::toJsonValue>(m_deviceProfile); - result["EnableDirectPlay"] = Jellyfin::Support::toJsonValue>(m_enableDirectPlay); - result["EnableDirectStream"] = Jellyfin::Support::toJsonValue>(m_enableDirectStream); - result["EnableTranscoding"] = Jellyfin::Support::toJsonValue>(m_enableTranscoding); - result["AllowVideoStreamCopy"] = Jellyfin::Support::toJsonValue>(m_allowVideoStreamCopy); - result["AllowAudioStreamCopy"] = Jellyfin::Support::toJsonValue>(m_allowAudioStreamCopy); - result["AutoOpenLiveStream"] = Jellyfin::Support::toJsonValue>(m_autoOpenLiveStream); - + + + if (!(m_userId.isNull())) { + result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); + } + + + if (!(!m_maxStreamingBitrate.has_value())) { + result["MaxStreamingBitrate"] = Jellyfin::Support::toJsonValue>(m_maxStreamingBitrate); + } + + + if (!(!m_startTimeTicks.has_value())) { + result["StartTimeTicks"] = Jellyfin::Support::toJsonValue>(m_startTimeTicks); + } + + + if (!(!m_audioStreamIndex.has_value())) { + result["AudioStreamIndex"] = Jellyfin::Support::toJsonValue>(m_audioStreamIndex); + } + + + if (!(!m_subtitleStreamIndex.has_value())) { + result["SubtitleStreamIndex"] = Jellyfin::Support::toJsonValue>(m_subtitleStreamIndex); + } + + + if (!(!m_maxAudioChannels.has_value())) { + result["MaxAudioChannels"] = Jellyfin::Support::toJsonValue>(m_maxAudioChannels); + } + + + if (!(m_mediaSourceId.isNull())) { + result["MediaSourceId"] = Jellyfin::Support::toJsonValue(m_mediaSourceId); + } + + + if (!(m_liveStreamId.isNull())) { + result["LiveStreamId"] = Jellyfin::Support::toJsonValue(m_liveStreamId); + } + + result["DeviceProfile"] = Jellyfin::Support::toJsonValue>(m_deviceProfile); + + if (!(!m_enableDirectPlay.has_value())) { + result["EnableDirectPlay"] = Jellyfin::Support::toJsonValue>(m_enableDirectPlay); + } + + + if (!(!m_enableDirectStream.has_value())) { + result["EnableDirectStream"] = Jellyfin::Support::toJsonValue>(m_enableDirectStream); + } + + + if (!(!m_enableTranscoding.has_value())) { + result["EnableTranscoding"] = Jellyfin::Support::toJsonValue>(m_enableTranscoding); + } + + + if (!(!m_allowVideoStreamCopy.has_value())) { + result["AllowVideoStreamCopy"] = Jellyfin::Support::toJsonValue>(m_allowVideoStreamCopy); + } + + + if (!(!m_allowAudioStreamCopy.has_value())) { + result["AllowAudioStreamCopy"] = Jellyfin::Support::toJsonValue>(m_allowAudioStreamCopy); + } + + + if (!(!m_autoOpenLiveStream.has_value())) { + result["AutoOpenLiveStream"] = Jellyfin::Support::toJsonValue>(m_autoOpenLiveStream); + } + return result; } diff --git a/core/src/dto/playbackinforesponse.cpp b/core/src/dto/playbackinforesponse.cpp index adc1e62..69d1a24 100644 --- a/core/src/dto/playbackinforesponse.cpp +++ b/core/src/dto/playbackinforesponse.cpp @@ -63,10 +63,18 @@ void PlaybackInfoResponse::setFromJson(QJsonObject source) { QJsonObject PlaybackInfoResponse::toJson() const { QJsonObject result; - result["MediaSources"] = Jellyfin::Support::toJsonValue>(m_mediaSources); - result["PlaySessionId"] = Jellyfin::Support::toJsonValue(m_playSessionId); - result["ErrorCode"] = Jellyfin::Support::toJsonValue(m_errorCode); - + + + if (!(m_mediaSources.size() == 0)) { + result["MediaSources"] = Jellyfin::Support::toJsonValue>(m_mediaSources); + } + + + if (!(m_playSessionId.isNull())) { + result["PlaySessionId"] = Jellyfin::Support::toJsonValue(m_playSessionId); + } + + result["ErrorCode"] = Jellyfin::Support::toJsonValue(m_errorCode); return result; } diff --git a/core/src/dto/playbackprogressinfo.cpp b/core/src/dto/playbackprogressinfo.cpp index 48f36c6..985fc6b 100644 --- a/core/src/dto/playbackprogressinfo.cpp +++ b/core/src/dto/playbackprogressinfo.cpp @@ -114,27 +114,79 @@ void PlaybackProgressInfo::setFromJson(QJsonObject source) { QJsonObject PlaybackProgressInfo::toJson() const { QJsonObject result; - result["CanSeek"] = Jellyfin::Support::toJsonValue(m_canSeek); - result["Item"] = Jellyfin::Support::toJsonValue>(m_item); - result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); - result["SessionId"] = Jellyfin::Support::toJsonValue(m_sessionId); - result["MediaSourceId"] = Jellyfin::Support::toJsonValue(m_mediaSourceId); - result["AudioStreamIndex"] = Jellyfin::Support::toJsonValue>(m_audioStreamIndex); - result["SubtitleStreamIndex"] = Jellyfin::Support::toJsonValue>(m_subtitleStreamIndex); - result["IsPaused"] = Jellyfin::Support::toJsonValue(m_isPaused); - result["IsMuted"] = Jellyfin::Support::toJsonValue(m_isMuted); - result["PositionTicks"] = Jellyfin::Support::toJsonValue>(m_positionTicks); - result["PlaybackStartTimeTicks"] = Jellyfin::Support::toJsonValue>(m_playbackStartTimeTicks); - result["VolumeLevel"] = Jellyfin::Support::toJsonValue>(m_volumeLevel); - result["Brightness"] = Jellyfin::Support::toJsonValue>(m_brightness); - result["AspectRatio"] = Jellyfin::Support::toJsonValue(m_aspectRatio); - result["PlayMethod"] = Jellyfin::Support::toJsonValue(m_playMethod); - result["LiveStreamId"] = Jellyfin::Support::toJsonValue(m_liveStreamId); - result["PlaySessionId"] = Jellyfin::Support::toJsonValue(m_playSessionId); - result["RepeatMode"] = Jellyfin::Support::toJsonValue(m_repeatMode); - result["NowPlayingQueue"] = Jellyfin::Support::toJsonValue>(m_nowPlayingQueue); - result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); - + + result["CanSeek"] = Jellyfin::Support::toJsonValue(m_canSeek); + result["Item"] = Jellyfin::Support::toJsonValue>(m_item); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + + if (!(m_sessionId.isNull())) { + result["SessionId"] = Jellyfin::Support::toJsonValue(m_sessionId); + } + + + if (!(m_mediaSourceId.isNull())) { + result["MediaSourceId"] = Jellyfin::Support::toJsonValue(m_mediaSourceId); + } + + + if (!(!m_audioStreamIndex.has_value())) { + result["AudioStreamIndex"] = Jellyfin::Support::toJsonValue>(m_audioStreamIndex); + } + + + if (!(!m_subtitleStreamIndex.has_value())) { + result["SubtitleStreamIndex"] = Jellyfin::Support::toJsonValue>(m_subtitleStreamIndex); + } + + result["IsPaused"] = Jellyfin::Support::toJsonValue(m_isPaused); + result["IsMuted"] = Jellyfin::Support::toJsonValue(m_isMuted); + + if (!(!m_positionTicks.has_value())) { + result["PositionTicks"] = Jellyfin::Support::toJsonValue>(m_positionTicks); + } + + + if (!(!m_playbackStartTimeTicks.has_value())) { + result["PlaybackStartTimeTicks"] = Jellyfin::Support::toJsonValue>(m_playbackStartTimeTicks); + } + + + if (!(!m_volumeLevel.has_value())) { + result["VolumeLevel"] = Jellyfin::Support::toJsonValue>(m_volumeLevel); + } + + + if (!(!m_brightness.has_value())) { + result["Brightness"] = Jellyfin::Support::toJsonValue>(m_brightness); + } + + + if (!(m_aspectRatio.isNull())) { + result["AspectRatio"] = Jellyfin::Support::toJsonValue(m_aspectRatio); + } + + result["PlayMethod"] = Jellyfin::Support::toJsonValue(m_playMethod); + + if (!(m_liveStreamId.isNull())) { + result["LiveStreamId"] = Jellyfin::Support::toJsonValue(m_liveStreamId); + } + + + if (!(m_playSessionId.isNull())) { + result["PlaySessionId"] = Jellyfin::Support::toJsonValue(m_playSessionId); + } + + result["RepeatMode"] = Jellyfin::Support::toJsonValue(m_repeatMode); + + if (!(m_nowPlayingQueue.size() == 0)) { + result["NowPlayingQueue"] = Jellyfin::Support::toJsonValue>(m_nowPlayingQueue); + } + + + if (!(m_playlistItemId.isNull())) { + result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); + } + return result; } diff --git a/core/src/dto/playbackstartinfo.cpp b/core/src/dto/playbackstartinfo.cpp index 04abfb9..878052f 100644 --- a/core/src/dto/playbackstartinfo.cpp +++ b/core/src/dto/playbackstartinfo.cpp @@ -114,27 +114,79 @@ void PlaybackStartInfo::setFromJson(QJsonObject source) { QJsonObject PlaybackStartInfo::toJson() const { QJsonObject result; - result["CanSeek"] = Jellyfin::Support::toJsonValue(m_canSeek); - result["Item"] = Jellyfin::Support::toJsonValue>(m_item); - result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); - result["SessionId"] = Jellyfin::Support::toJsonValue(m_sessionId); - result["MediaSourceId"] = Jellyfin::Support::toJsonValue(m_mediaSourceId); - result["AudioStreamIndex"] = Jellyfin::Support::toJsonValue>(m_audioStreamIndex); - result["SubtitleStreamIndex"] = Jellyfin::Support::toJsonValue>(m_subtitleStreamIndex); - result["IsPaused"] = Jellyfin::Support::toJsonValue(m_isPaused); - result["IsMuted"] = Jellyfin::Support::toJsonValue(m_isMuted); - result["PositionTicks"] = Jellyfin::Support::toJsonValue>(m_positionTicks); - result["PlaybackStartTimeTicks"] = Jellyfin::Support::toJsonValue>(m_playbackStartTimeTicks); - result["VolumeLevel"] = Jellyfin::Support::toJsonValue>(m_volumeLevel); - result["Brightness"] = Jellyfin::Support::toJsonValue>(m_brightness); - result["AspectRatio"] = Jellyfin::Support::toJsonValue(m_aspectRatio); - result["PlayMethod"] = Jellyfin::Support::toJsonValue(m_playMethod); - result["LiveStreamId"] = Jellyfin::Support::toJsonValue(m_liveStreamId); - result["PlaySessionId"] = Jellyfin::Support::toJsonValue(m_playSessionId); - result["RepeatMode"] = Jellyfin::Support::toJsonValue(m_repeatMode); - result["NowPlayingQueue"] = Jellyfin::Support::toJsonValue>(m_nowPlayingQueue); - result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); - + + result["CanSeek"] = Jellyfin::Support::toJsonValue(m_canSeek); + result["Item"] = Jellyfin::Support::toJsonValue>(m_item); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + + if (!(m_sessionId.isNull())) { + result["SessionId"] = Jellyfin::Support::toJsonValue(m_sessionId); + } + + + if (!(m_mediaSourceId.isNull())) { + result["MediaSourceId"] = Jellyfin::Support::toJsonValue(m_mediaSourceId); + } + + + if (!(!m_audioStreamIndex.has_value())) { + result["AudioStreamIndex"] = Jellyfin::Support::toJsonValue>(m_audioStreamIndex); + } + + + if (!(!m_subtitleStreamIndex.has_value())) { + result["SubtitleStreamIndex"] = Jellyfin::Support::toJsonValue>(m_subtitleStreamIndex); + } + + result["IsPaused"] = Jellyfin::Support::toJsonValue(m_isPaused); + result["IsMuted"] = Jellyfin::Support::toJsonValue(m_isMuted); + + if (!(!m_positionTicks.has_value())) { + result["PositionTicks"] = Jellyfin::Support::toJsonValue>(m_positionTicks); + } + + + if (!(!m_playbackStartTimeTicks.has_value())) { + result["PlaybackStartTimeTicks"] = Jellyfin::Support::toJsonValue>(m_playbackStartTimeTicks); + } + + + if (!(!m_volumeLevel.has_value())) { + result["VolumeLevel"] = Jellyfin::Support::toJsonValue>(m_volumeLevel); + } + + + if (!(!m_brightness.has_value())) { + result["Brightness"] = Jellyfin::Support::toJsonValue>(m_brightness); + } + + + if (!(m_aspectRatio.isNull())) { + result["AspectRatio"] = Jellyfin::Support::toJsonValue(m_aspectRatio); + } + + result["PlayMethod"] = Jellyfin::Support::toJsonValue(m_playMethod); + + if (!(m_liveStreamId.isNull())) { + result["LiveStreamId"] = Jellyfin::Support::toJsonValue(m_liveStreamId); + } + + + if (!(m_playSessionId.isNull())) { + result["PlaySessionId"] = Jellyfin::Support::toJsonValue(m_playSessionId); + } + + result["RepeatMode"] = Jellyfin::Support::toJsonValue(m_repeatMode); + + if (!(m_nowPlayingQueue.size() == 0)) { + result["NowPlayingQueue"] = Jellyfin::Support::toJsonValue>(m_nowPlayingQueue); + } + + + if (!(m_playlistItemId.isNull())) { + result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); + } + return result; } diff --git a/core/src/dto/playbackstopinfo.cpp b/core/src/dto/playbackstopinfo.cpp index 1231bad..636c80b 100644 --- a/core/src/dto/playbackstopinfo.cpp +++ b/core/src/dto/playbackstopinfo.cpp @@ -87,18 +87,50 @@ void PlaybackStopInfo::setFromJson(QJsonObject source) { QJsonObject PlaybackStopInfo::toJson() const { QJsonObject result; - result["Item"] = Jellyfin::Support::toJsonValue>(m_item); - result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); - result["SessionId"] = Jellyfin::Support::toJsonValue(m_sessionId); - result["MediaSourceId"] = Jellyfin::Support::toJsonValue(m_mediaSourceId); - result["PositionTicks"] = Jellyfin::Support::toJsonValue>(m_positionTicks); - result["LiveStreamId"] = Jellyfin::Support::toJsonValue(m_liveStreamId); - result["PlaySessionId"] = Jellyfin::Support::toJsonValue(m_playSessionId); - result["Failed"] = Jellyfin::Support::toJsonValue(m_failed); - result["NextMediaType"] = Jellyfin::Support::toJsonValue(m_nextMediaType); - result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); - result["NowPlayingQueue"] = Jellyfin::Support::toJsonValue>(m_nowPlayingQueue); - + + result["Item"] = Jellyfin::Support::toJsonValue>(m_item); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + + if (!(m_sessionId.isNull())) { + result["SessionId"] = Jellyfin::Support::toJsonValue(m_sessionId); + } + + + if (!(m_mediaSourceId.isNull())) { + result["MediaSourceId"] = Jellyfin::Support::toJsonValue(m_mediaSourceId); + } + + + if (!(!m_positionTicks.has_value())) { + result["PositionTicks"] = Jellyfin::Support::toJsonValue>(m_positionTicks); + } + + + if (!(m_liveStreamId.isNull())) { + result["LiveStreamId"] = Jellyfin::Support::toJsonValue(m_liveStreamId); + } + + + if (!(m_playSessionId.isNull())) { + result["PlaySessionId"] = Jellyfin::Support::toJsonValue(m_playSessionId); + } + + result["Failed"] = Jellyfin::Support::toJsonValue(m_failed); + + if (!(m_nextMediaType.isNull())) { + result["NextMediaType"] = Jellyfin::Support::toJsonValue(m_nextMediaType); + } + + + if (!(m_playlistItemId.isNull())) { + result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); + } + + + if (!(m_nowPlayingQueue.size() == 0)) { + result["NowPlayingQueue"] = Jellyfin::Support::toJsonValue>(m_nowPlayingQueue); + } + return result; } diff --git a/core/src/dto/playerstateinfo.cpp b/core/src/dto/playerstateinfo.cpp index 2b89550..d5a3b09 100644 --- a/core/src/dto/playerstateinfo.cpp +++ b/core/src/dto/playerstateinfo.cpp @@ -84,17 +84,37 @@ void PlayerStateInfo::setFromJson(QJsonObject source) { QJsonObject PlayerStateInfo::toJson() const { QJsonObject result; - result["PositionTicks"] = Jellyfin::Support::toJsonValue>(m_positionTicks); - result["CanSeek"] = Jellyfin::Support::toJsonValue(m_canSeek); - result["IsPaused"] = Jellyfin::Support::toJsonValue(m_isPaused); - result["IsMuted"] = Jellyfin::Support::toJsonValue(m_isMuted); - result["VolumeLevel"] = Jellyfin::Support::toJsonValue>(m_volumeLevel); - result["AudioStreamIndex"] = Jellyfin::Support::toJsonValue>(m_audioStreamIndex); - result["SubtitleStreamIndex"] = Jellyfin::Support::toJsonValue>(m_subtitleStreamIndex); - result["MediaSourceId"] = Jellyfin::Support::toJsonValue(m_mediaSourceId); - result["PlayMethod"] = Jellyfin::Support::toJsonValue(m_playMethod); - result["RepeatMode"] = Jellyfin::Support::toJsonValue(m_repeatMode); - + + + if (!(!m_positionTicks.has_value())) { + result["PositionTicks"] = Jellyfin::Support::toJsonValue>(m_positionTicks); + } + + result["CanSeek"] = Jellyfin::Support::toJsonValue(m_canSeek); + result["IsPaused"] = Jellyfin::Support::toJsonValue(m_isPaused); + result["IsMuted"] = Jellyfin::Support::toJsonValue(m_isMuted); + + if (!(!m_volumeLevel.has_value())) { + result["VolumeLevel"] = Jellyfin::Support::toJsonValue>(m_volumeLevel); + } + + + if (!(!m_audioStreamIndex.has_value())) { + result["AudioStreamIndex"] = Jellyfin::Support::toJsonValue>(m_audioStreamIndex); + } + + + if (!(!m_subtitleStreamIndex.has_value())) { + result["SubtitleStreamIndex"] = Jellyfin::Support::toJsonValue>(m_subtitleStreamIndex); + } + + + if (!(m_mediaSourceId.isNull())) { + result["MediaSourceId"] = Jellyfin::Support::toJsonValue(m_mediaSourceId); + } + + result["PlayMethod"] = Jellyfin::Support::toJsonValue(m_playMethod); + result["RepeatMode"] = Jellyfin::Support::toJsonValue(m_repeatMode); return result; } diff --git a/core/src/dto/playlistcreationresult.cpp b/core/src/dto/playlistcreationresult.cpp index 1ae5cb9..bc7d1d8 100644 --- a/core/src/dto/playlistcreationresult.cpp +++ b/core/src/dto/playlistcreationresult.cpp @@ -57,8 +57,12 @@ void PlaylistCreationResult::setFromJson(QJsonObject source) { QJsonObject PlaylistCreationResult::toJson() const { QJsonObject result; - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - + + + if (!(m_jellyfinId.isNull())) { + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + } + return result; } diff --git a/core/src/dto/playrequest.cpp b/core/src/dto/playrequest.cpp index 7597f8c..834dc83 100644 --- a/core/src/dto/playrequest.cpp +++ b/core/src/dto/playrequest.cpp @@ -78,15 +78,39 @@ void PlayRequest::setFromJson(QJsonObject source) { QJsonObject PlayRequest::toJson() const { QJsonObject result; - result["ItemIds"] = Jellyfin::Support::toJsonValue(m_itemIds); - result["StartPositionTicks"] = Jellyfin::Support::toJsonValue>(m_startPositionTicks); - result["PlayCommand"] = Jellyfin::Support::toJsonValue(m_playCommand); - result["ControllingUserId"] = Jellyfin::Support::toJsonValue(m_controllingUserId); - result["SubtitleStreamIndex"] = Jellyfin::Support::toJsonValue>(m_subtitleStreamIndex); - result["AudioStreamIndex"] = Jellyfin::Support::toJsonValue>(m_audioStreamIndex); - result["MediaSourceId"] = Jellyfin::Support::toJsonValue(m_mediaSourceId); - result["StartIndex"] = Jellyfin::Support::toJsonValue>(m_startIndex); - + + + if (!(m_itemIds.size() == 0)) { + result["ItemIds"] = Jellyfin::Support::toJsonValue(m_itemIds); + } + + + if (!(!m_startPositionTicks.has_value())) { + result["StartPositionTicks"] = Jellyfin::Support::toJsonValue>(m_startPositionTicks); + } + + result["PlayCommand"] = Jellyfin::Support::toJsonValue(m_playCommand); + result["ControllingUserId"] = Jellyfin::Support::toJsonValue(m_controllingUserId); + + if (!(!m_subtitleStreamIndex.has_value())) { + result["SubtitleStreamIndex"] = Jellyfin::Support::toJsonValue>(m_subtitleStreamIndex); + } + + + if (!(!m_audioStreamIndex.has_value())) { + result["AudioStreamIndex"] = Jellyfin::Support::toJsonValue>(m_audioStreamIndex); + } + + + if (!(m_mediaSourceId.isNull())) { + result["MediaSourceId"] = Jellyfin::Support::toJsonValue(m_mediaSourceId); + } + + + if (!(!m_startIndex.has_value())) { + result["StartIndex"] = Jellyfin::Support::toJsonValue>(m_startIndex); + } + return result; } diff --git a/core/src/dto/playrequestdto.cpp b/core/src/dto/playrequestdto.cpp index a72020f..00b799a 100644 --- a/core/src/dto/playrequestdto.cpp +++ b/core/src/dto/playrequestdto.cpp @@ -63,10 +63,14 @@ void PlayRequestDto::setFromJson(QJsonObject source) { QJsonObject PlayRequestDto::toJson() const { QJsonObject result; - result["PlayingQueue"] = Jellyfin::Support::toJsonValue(m_playingQueue); - result["PlayingItemPosition"] = Jellyfin::Support::toJsonValue(m_playingItemPosition); - result["StartPositionTicks"] = Jellyfin::Support::toJsonValue(m_startPositionTicks); - + + + if (!(m_playingQueue.size() == 0)) { + result["PlayingQueue"] = Jellyfin::Support::toJsonValue(m_playingQueue); + } + + result["PlayingItemPosition"] = Jellyfin::Support::toJsonValue(m_playingItemPosition); + result["StartPositionTicks"] = Jellyfin::Support::toJsonValue(m_startPositionTicks); return result; } diff --git a/core/src/dto/playstaterequest.cpp b/core/src/dto/playstaterequest.cpp index 30c2e0b..da71fa8 100644 --- a/core/src/dto/playstaterequest.cpp +++ b/core/src/dto/playstaterequest.cpp @@ -63,10 +63,18 @@ void PlaystateRequest::setFromJson(QJsonObject source) { QJsonObject PlaystateRequest::toJson() const { QJsonObject result; - result["Command"] = Jellyfin::Support::toJsonValue(m_command); - result["SeekPositionTicks"] = Jellyfin::Support::toJsonValue>(m_seekPositionTicks); - result["ControllingUserId"] = Jellyfin::Support::toJsonValue(m_controllingUserId); - + + result["Command"] = Jellyfin::Support::toJsonValue(m_command); + + if (!(!m_seekPositionTicks.has_value())) { + result["SeekPositionTicks"] = Jellyfin::Support::toJsonValue>(m_seekPositionTicks); + } + + + if (!(m_controllingUserId.isNull())) { + result["ControllingUserId"] = Jellyfin::Support::toJsonValue(m_controllingUserId); + } + return result; } diff --git a/core/src/dto/plugininfo.cpp b/core/src/dto/plugininfo.cpp index 11290a5..05bbfc6 100644 --- a/core/src/dto/plugininfo.cpp +++ b/core/src/dto/plugininfo.cpp @@ -78,15 +78,27 @@ void PluginInfo::setFromJson(QJsonObject source) { QJsonObject PluginInfo::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Version"] = Jellyfin::Support::toJsonValue>(m_version); - result["ConfigurationFileName"] = Jellyfin::Support::toJsonValue(m_configurationFileName); - result["Description"] = Jellyfin::Support::toJsonValue(m_description); - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["CanUninstall"] = Jellyfin::Support::toJsonValue(m_canUninstall); - result["HasImage"] = Jellyfin::Support::toJsonValue(m_hasImage); - result["Status"] = Jellyfin::Support::toJsonValue(m_status); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + result["Version"] = Jellyfin::Support::toJsonValue>(m_version); + + if (!(m_configurationFileName.isNull())) { + result["ConfigurationFileName"] = Jellyfin::Support::toJsonValue(m_configurationFileName); + } + + + if (!(m_description.isNull())) { + result["Description"] = Jellyfin::Support::toJsonValue(m_description); + } + + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["CanUninstall"] = Jellyfin::Support::toJsonValue(m_canUninstall); + result["HasImage"] = Jellyfin::Support::toJsonValue(m_hasImage); + result["Status"] = Jellyfin::Support::toJsonValue(m_status); return result; } diff --git a/core/src/dto/pluginsecurityinfo.cpp b/core/src/dto/pluginsecurityinfo.cpp index 988ab1f..2b607d7 100644 --- a/core/src/dto/pluginsecurityinfo.cpp +++ b/core/src/dto/pluginsecurityinfo.cpp @@ -60,9 +60,13 @@ void PluginSecurityInfo::setFromJson(QJsonObject source) { QJsonObject PluginSecurityInfo::toJson() const { QJsonObject result; - result["SupporterKey"] = Jellyfin::Support::toJsonValue(m_supporterKey); - result["IsMbSupporter"] = Jellyfin::Support::toJsonValue(m_isMbSupporter); - + + + if (!(m_supporterKey.isNull())) { + result["SupporterKey"] = Jellyfin::Support::toJsonValue(m_supporterKey); + } + + result["IsMbSupporter"] = Jellyfin::Support::toJsonValue(m_isMbSupporter); return result; } diff --git a/core/src/dto/previousitemrequestdto.cpp b/core/src/dto/previousitemrequestdto.cpp index 52846c9..f26c77a 100644 --- a/core/src/dto/previousitemrequestdto.cpp +++ b/core/src/dto/previousitemrequestdto.cpp @@ -57,8 +57,8 @@ void PreviousItemRequestDto::setFromJson(QJsonObject source) { QJsonObject PreviousItemRequestDto::toJson() const { QJsonObject result; - result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); - + + result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); return result; } diff --git a/core/src/dto/problemdetails.cpp b/core/src/dto/problemdetails.cpp index 44f6130..6e1cd65 100644 --- a/core/src/dto/problemdetails.cpp +++ b/core/src/dto/problemdetails.cpp @@ -69,12 +69,32 @@ void ProblemDetails::setFromJson(QJsonObject source) { QJsonObject ProblemDetails::toJson() const { QJsonObject result; - result["type"] = Jellyfin::Support::toJsonValue(m_type); - result["title"] = Jellyfin::Support::toJsonValue(m_title); - result["status"] = Jellyfin::Support::toJsonValue>(m_status); - result["detail"] = Jellyfin::Support::toJsonValue(m_detail); - result["instance"] = Jellyfin::Support::toJsonValue(m_instance); - + + + if (!(m_type.isNull())) { + result["type"] = Jellyfin::Support::toJsonValue(m_type); + } + + + if (!(m_title.isNull())) { + result["title"] = Jellyfin::Support::toJsonValue(m_title); + } + + + if (!(!m_status.has_value())) { + result["status"] = Jellyfin::Support::toJsonValue>(m_status); + } + + + if (!(m_detail.isNull())) { + result["detail"] = Jellyfin::Support::toJsonValue(m_detail); + } + + + if (!(m_instance.isNull())) { + result["instance"] = Jellyfin::Support::toJsonValue(m_instance); + } + return result; } diff --git a/core/src/dto/profilecondition.cpp b/core/src/dto/profilecondition.cpp index fd223fb..39ba4b3 100644 --- a/core/src/dto/profilecondition.cpp +++ b/core/src/dto/profilecondition.cpp @@ -66,11 +66,15 @@ void ProfileCondition::setFromJson(QJsonObject source) { QJsonObject ProfileCondition::toJson() const { QJsonObject result; - result["Condition"] = Jellyfin::Support::toJsonValue(m_condition); - result["Property"] = Jellyfin::Support::toJsonValue(m_property); - result["Value"] = Jellyfin::Support::toJsonValue(m_value); - result["IsRequired"] = Jellyfin::Support::toJsonValue(m_isRequired); - + + result["Condition"] = Jellyfin::Support::toJsonValue(m_condition); + result["Property"] = Jellyfin::Support::toJsonValue(m_property); + + if (!(m_value.isNull())) { + result["Value"] = Jellyfin::Support::toJsonValue(m_value); + } + + result["IsRequired"] = Jellyfin::Support::toJsonValue(m_isRequired); return result; } diff --git a/core/src/dto/publicsysteminfo.cpp b/core/src/dto/publicsysteminfo.cpp index 45abf75..f029baa 100644 --- a/core/src/dto/publicsysteminfo.cpp +++ b/core/src/dto/publicsysteminfo.cpp @@ -75,14 +75,42 @@ void PublicSystemInfo::setFromJson(QJsonObject source) { QJsonObject PublicSystemInfo::toJson() const { QJsonObject result; - result["LocalAddress"] = Jellyfin::Support::toJsonValue(m_localAddress); - result["ServerName"] = Jellyfin::Support::toJsonValue(m_serverName); - result["Version"] = Jellyfin::Support::toJsonValue(m_version); - result["ProductName"] = Jellyfin::Support::toJsonValue(m_productName); - result["OperatingSystem"] = Jellyfin::Support::toJsonValue(m_operatingSystem); - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["StartupWizardCompleted"] = Jellyfin::Support::toJsonValue>(m_startupWizardCompleted); - + + + if (!(m_localAddress.isNull())) { + result["LocalAddress"] = Jellyfin::Support::toJsonValue(m_localAddress); + } + + + if (!(m_serverName.isNull())) { + result["ServerName"] = Jellyfin::Support::toJsonValue(m_serverName); + } + + + if (!(m_version.isNull())) { + result["Version"] = Jellyfin::Support::toJsonValue(m_version); + } + + + if (!(m_productName.isNull())) { + result["ProductName"] = Jellyfin::Support::toJsonValue(m_productName); + } + + + if (!(m_operatingSystem.isNull())) { + result["OperatingSystem"] = Jellyfin::Support::toJsonValue(m_operatingSystem); + } + + + if (!(m_jellyfinId.isNull())) { + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + } + + + if (!(!m_startupWizardCompleted.has_value())) { + result["StartupWizardCompleted"] = Jellyfin::Support::toJsonValue>(m_startupWizardCompleted); + } + return result; } diff --git a/core/src/dto/queryfilters.cpp b/core/src/dto/queryfilters.cpp index 3b6ef6e..5a4e9e0 100644 --- a/core/src/dto/queryfilters.cpp +++ b/core/src/dto/queryfilters.cpp @@ -60,9 +60,17 @@ void QueryFilters::setFromJson(QJsonObject source) { QJsonObject QueryFilters::toJson() const { QJsonObject result; - result["Genres"] = Jellyfin::Support::toJsonValue>(m_genres); - result["Tags"] = Jellyfin::Support::toJsonValue(m_tags); - + + + if (!(m_genres.size() == 0)) { + result["Genres"] = Jellyfin::Support::toJsonValue>(m_genres); + } + + + if (!(m_tags.size() == 0)) { + result["Tags"] = Jellyfin::Support::toJsonValue(m_tags); + } + return result; } diff --git a/core/src/dto/queryfilterslegacy.cpp b/core/src/dto/queryfilterslegacy.cpp index e94fe8a..8c256a6 100644 --- a/core/src/dto/queryfilterslegacy.cpp +++ b/core/src/dto/queryfilterslegacy.cpp @@ -66,11 +66,27 @@ void QueryFiltersLegacy::setFromJson(QJsonObject source) { QJsonObject QueryFiltersLegacy::toJson() const { QJsonObject result; - result["Genres"] = Jellyfin::Support::toJsonValue(m_genres); - result["Tags"] = Jellyfin::Support::toJsonValue(m_tags); - result["OfficialRatings"] = Jellyfin::Support::toJsonValue(m_officialRatings); - result["Years"] = Jellyfin::Support::toJsonValue>(m_years); - + + + if (!(m_genres.size() == 0)) { + result["Genres"] = Jellyfin::Support::toJsonValue(m_genres); + } + + + if (!(m_tags.size() == 0)) { + result["Tags"] = Jellyfin::Support::toJsonValue(m_tags); + } + + + if (!(m_officialRatings.size() == 0)) { + result["OfficialRatings"] = Jellyfin::Support::toJsonValue(m_officialRatings); + } + + + if (!(m_years.size() == 0)) { + result["Years"] = Jellyfin::Support::toJsonValue>(m_years); + } + return result; } diff --git a/core/src/dto/queueitem.cpp b/core/src/dto/queueitem.cpp index 6894d4f..0fab3b5 100644 --- a/core/src/dto/queueitem.cpp +++ b/core/src/dto/queueitem.cpp @@ -60,9 +60,13 @@ void QueueItem::setFromJson(QJsonObject source) { QJsonObject QueueItem::toJson() const { QJsonObject result; - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); - + + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + + if (!(m_playlistItemId.isNull())) { + result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); + } + return result; } diff --git a/core/src/dto/queuerequestdto.cpp b/core/src/dto/queuerequestdto.cpp index 33d25a2..276d02d 100644 --- a/core/src/dto/queuerequestdto.cpp +++ b/core/src/dto/queuerequestdto.cpp @@ -60,9 +60,13 @@ void QueueRequestDto::setFromJson(QJsonObject source) { QJsonObject QueueRequestDto::toJson() const { QJsonObject result; - result["ItemIds"] = Jellyfin::Support::toJsonValue(m_itemIds); - result["Mode"] = Jellyfin::Support::toJsonValue(m_mode); - + + + if (!(m_itemIds.size() == 0)) { + result["ItemIds"] = Jellyfin::Support::toJsonValue(m_itemIds); + } + + result["Mode"] = Jellyfin::Support::toJsonValue(m_mode); return result; } diff --git a/core/src/dto/quickconnectdto.cpp b/core/src/dto/quickconnectdto.cpp index f3736a1..ef0ee22 100644 --- a/core/src/dto/quickconnectdto.cpp +++ b/core/src/dto/quickconnectdto.cpp @@ -57,8 +57,8 @@ void QuickConnectDto::setFromJson(QJsonObject source) { QJsonObject QuickConnectDto::toJson() const { QJsonObject result; - result["Token"] = Jellyfin::Support::toJsonValue(m_token); - + + result["Token"] = Jellyfin::Support::toJsonValue(m_token); return result; } diff --git a/core/src/dto/quickconnectresult.cpp b/core/src/dto/quickconnectresult.cpp index 056ec1c..ab8eb23 100644 --- a/core/src/dto/quickconnectresult.cpp +++ b/core/src/dto/quickconnectresult.cpp @@ -72,13 +72,33 @@ void QuickConnectResult::setFromJson(QJsonObject source) { QJsonObject QuickConnectResult::toJson() const { QJsonObject result; - result["Authenticated"] = Jellyfin::Support::toJsonValue(m_authenticated); - result["Secret"] = Jellyfin::Support::toJsonValue(m_secret); - result["Code"] = Jellyfin::Support::toJsonValue(m_code); - result["Authentication"] = Jellyfin::Support::toJsonValue(m_authentication); - result["Error"] = Jellyfin::Support::toJsonValue(m_error); - result["DateAdded"] = Jellyfin::Support::toJsonValue(m_dateAdded); - + + result["Authenticated"] = Jellyfin::Support::toJsonValue(m_authenticated); + + if (!(m_secret.isNull())) { + result["Secret"] = Jellyfin::Support::toJsonValue(m_secret); + } + + + if (!(m_code.isNull())) { + result["Code"] = Jellyfin::Support::toJsonValue(m_code); + } + + + if (!(m_authentication.isNull())) { + result["Authentication"] = Jellyfin::Support::toJsonValue(m_authentication); + } + + + if (!(m_error.isNull())) { + result["Error"] = Jellyfin::Support::toJsonValue(m_error); + } + + + if (!(m_dateAdded.isNull())) { + result["DateAdded"] = Jellyfin::Support::toJsonValue(m_dateAdded); + } + return result; } diff --git a/core/src/dto/readyrequestdto.cpp b/core/src/dto/readyrequestdto.cpp index fc608eb..ce24904 100644 --- a/core/src/dto/readyrequestdto.cpp +++ b/core/src/dto/readyrequestdto.cpp @@ -66,11 +66,11 @@ void ReadyRequestDto::setFromJson(QJsonObject source) { QJsonObject ReadyRequestDto::toJson() const { QJsonObject result; - result["When"] = Jellyfin::Support::toJsonValue(m_when); - result["PositionTicks"] = Jellyfin::Support::toJsonValue(m_positionTicks); - result["IsPlaying"] = Jellyfin::Support::toJsonValue(m_isPlaying); - result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); - + + result["When"] = Jellyfin::Support::toJsonValue(m_when); + result["PositionTicks"] = Jellyfin::Support::toJsonValue(m_positionTicks); + result["IsPlaying"] = Jellyfin::Support::toJsonValue(m_isPlaying); + result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); return result; } diff --git a/core/src/dto/recommendationdto.cpp b/core/src/dto/recommendationdto.cpp index 5c2ef24..d0ff4db 100644 --- a/core/src/dto/recommendationdto.cpp +++ b/core/src/dto/recommendationdto.cpp @@ -66,11 +66,19 @@ void RecommendationDto::setFromJson(QJsonObject source) { QJsonObject RecommendationDto::toJson() const { QJsonObject result; - result["Items"] = Jellyfin::Support::toJsonValue>(m_items); - result["RecommendationType"] = Jellyfin::Support::toJsonValue(m_recommendationType); - result["BaselineItemName"] = Jellyfin::Support::toJsonValue(m_baselineItemName); - result["CategoryId"] = Jellyfin::Support::toJsonValue(m_categoryId); - + + + if (!(m_items.size() == 0)) { + result["Items"] = Jellyfin::Support::toJsonValue>(m_items); + } + + result["RecommendationType"] = Jellyfin::Support::toJsonValue(m_recommendationType); + + if (!(m_baselineItemName.isNull())) { + result["BaselineItemName"] = Jellyfin::Support::toJsonValue(m_baselineItemName); + } + + result["CategoryId"] = Jellyfin::Support::toJsonValue(m_categoryId); return result; } diff --git a/core/src/dto/remoteimageinfo.cpp b/core/src/dto/remoteimageinfo.cpp index 5393a4b..c5f6492 100644 --- a/core/src/dto/remoteimageinfo.cpp +++ b/core/src/dto/remoteimageinfo.cpp @@ -84,17 +84,49 @@ void RemoteImageInfo::setFromJson(QJsonObject source) { QJsonObject RemoteImageInfo::toJson() const { QJsonObject result; - result["ProviderName"] = Jellyfin::Support::toJsonValue(m_providerName); - result["Url"] = Jellyfin::Support::toJsonValue(m_url); - result["ThumbnailUrl"] = Jellyfin::Support::toJsonValue(m_thumbnailUrl); - result["Height"] = Jellyfin::Support::toJsonValue>(m_height); - result["Width"] = Jellyfin::Support::toJsonValue>(m_width); - result["CommunityRating"] = Jellyfin::Support::toJsonValue>(m_communityRating); - result["VoteCount"] = Jellyfin::Support::toJsonValue>(m_voteCount); - result["Language"] = Jellyfin::Support::toJsonValue(m_language); - result["Type"] = Jellyfin::Support::toJsonValue(m_type); - result["RatingType"] = Jellyfin::Support::toJsonValue(m_ratingType); - + + + if (!(m_providerName.isNull())) { + result["ProviderName"] = Jellyfin::Support::toJsonValue(m_providerName); + } + + + if (!(m_url.isNull())) { + result["Url"] = Jellyfin::Support::toJsonValue(m_url); + } + + + if (!(m_thumbnailUrl.isNull())) { + result["ThumbnailUrl"] = Jellyfin::Support::toJsonValue(m_thumbnailUrl); + } + + + if (!(!m_height.has_value())) { + result["Height"] = Jellyfin::Support::toJsonValue>(m_height); + } + + + if (!(!m_width.has_value())) { + result["Width"] = Jellyfin::Support::toJsonValue>(m_width); + } + + + if (!(!m_communityRating.has_value())) { + result["CommunityRating"] = Jellyfin::Support::toJsonValue>(m_communityRating); + } + + + if (!(!m_voteCount.has_value())) { + result["VoteCount"] = Jellyfin::Support::toJsonValue>(m_voteCount); + } + + + if (!(m_language.isNull())) { + result["Language"] = Jellyfin::Support::toJsonValue(m_language); + } + + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + result["RatingType"] = Jellyfin::Support::toJsonValue(m_ratingType); return result; } diff --git a/core/src/dto/remoteimageresult.cpp b/core/src/dto/remoteimageresult.cpp index 40fba2f..89a95d8 100644 --- a/core/src/dto/remoteimageresult.cpp +++ b/core/src/dto/remoteimageresult.cpp @@ -63,10 +63,18 @@ void RemoteImageResult::setFromJson(QJsonObject source) { QJsonObject RemoteImageResult::toJson() const { QJsonObject result; - result["Images"] = Jellyfin::Support::toJsonValue>(m_images); - result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); - result["Providers"] = Jellyfin::Support::toJsonValue(m_providers); - + + + if (!(m_images.size() == 0)) { + result["Images"] = Jellyfin::Support::toJsonValue>(m_images); + } + + result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); + + if (!(m_providers.size() == 0)) { + result["Providers"] = Jellyfin::Support::toJsonValue(m_providers); + } + return result; } diff --git a/core/src/dto/remotesearchresult.cpp b/core/src/dto/remotesearchresult.cpp index 76e1a48..a65e32d 100644 --- a/core/src/dto/remotesearchresult.cpp +++ b/core/src/dto/remotesearchresult.cpp @@ -90,19 +90,63 @@ void RemoteSearchResult::setFromJson(QJsonObject source) { QJsonObject RemoteSearchResult::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); - result["ProductionYear"] = Jellyfin::Support::toJsonValue>(m_productionYear); - result["IndexNumber"] = Jellyfin::Support::toJsonValue>(m_indexNumber); - result["IndexNumberEnd"] = Jellyfin::Support::toJsonValue>(m_indexNumberEnd); - result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue>(m_parentIndexNumber); - result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); - result["ImageUrl"] = Jellyfin::Support::toJsonValue(m_imageUrl); - result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); - result["Overview"] = Jellyfin::Support::toJsonValue(m_overview); - result["AlbumArtist"] = Jellyfin::Support::toJsonValue>(m_albumArtist); - result["Artists"] = Jellyfin::Support::toJsonValue>(m_artists); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_providerIds.isEmpty())) { + result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); + } + + + if (!(!m_productionYear.has_value())) { + result["ProductionYear"] = Jellyfin::Support::toJsonValue>(m_productionYear); + } + + + if (!(!m_indexNumber.has_value())) { + result["IndexNumber"] = Jellyfin::Support::toJsonValue>(m_indexNumber); + } + + + if (!(!m_indexNumberEnd.has_value())) { + result["IndexNumberEnd"] = Jellyfin::Support::toJsonValue>(m_indexNumberEnd); + } + + + if (!(!m_parentIndexNumber.has_value())) { + result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue>(m_parentIndexNumber); + } + + + if (!(m_premiereDate.isNull())) { + result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); + } + + + if (!(m_imageUrl.isNull())) { + result["ImageUrl"] = Jellyfin::Support::toJsonValue(m_imageUrl); + } + + + if (!(m_searchProviderName.isNull())) { + result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); + } + + + if (!(m_overview.isNull())) { + result["Overview"] = Jellyfin::Support::toJsonValue(m_overview); + } + + result["AlbumArtist"] = Jellyfin::Support::toJsonValue>(m_albumArtist); + + if (!(m_artists.size() == 0)) { + result["Artists"] = Jellyfin::Support::toJsonValue>(m_artists); + } + return result; } diff --git a/core/src/dto/remotesubtitleinfo.cpp b/core/src/dto/remotesubtitleinfo.cpp index 721a7ce..e9be16d 100644 --- a/core/src/dto/remotesubtitleinfo.cpp +++ b/core/src/dto/remotesubtitleinfo.cpp @@ -87,18 +87,62 @@ void RemoteSubtitleInfo::setFromJson(QJsonObject source) { QJsonObject RemoteSubtitleInfo::toJson() const { QJsonObject result; - result["ThreeLetterISOLanguageName"] = Jellyfin::Support::toJsonValue(m_threeLetterISOLanguageName); - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["ProviderName"] = Jellyfin::Support::toJsonValue(m_providerName); - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Format"] = Jellyfin::Support::toJsonValue(m_format); - result["Author"] = Jellyfin::Support::toJsonValue(m_author); - result["Comment"] = Jellyfin::Support::toJsonValue(m_comment); - result["DateCreated"] = Jellyfin::Support::toJsonValue(m_dateCreated); - result["CommunityRating"] = Jellyfin::Support::toJsonValue>(m_communityRating); - result["DownloadCount"] = Jellyfin::Support::toJsonValue>(m_downloadCount); - result["IsHashMatch"] = Jellyfin::Support::toJsonValue>(m_isHashMatch); - + + + if (!(m_threeLetterISOLanguageName.isNull())) { + result["ThreeLetterISOLanguageName"] = Jellyfin::Support::toJsonValue(m_threeLetterISOLanguageName); + } + + + if (!(m_jellyfinId.isNull())) { + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + } + + + if (!(m_providerName.isNull())) { + result["ProviderName"] = Jellyfin::Support::toJsonValue(m_providerName); + } + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_format.isNull())) { + result["Format"] = Jellyfin::Support::toJsonValue(m_format); + } + + + if (!(m_author.isNull())) { + result["Author"] = Jellyfin::Support::toJsonValue(m_author); + } + + + if (!(m_comment.isNull())) { + result["Comment"] = Jellyfin::Support::toJsonValue(m_comment); + } + + + if (!(m_dateCreated.isNull())) { + result["DateCreated"] = Jellyfin::Support::toJsonValue(m_dateCreated); + } + + + if (!(!m_communityRating.has_value())) { + result["CommunityRating"] = Jellyfin::Support::toJsonValue>(m_communityRating); + } + + + if (!(!m_downloadCount.has_value())) { + result["DownloadCount"] = Jellyfin::Support::toJsonValue>(m_downloadCount); + } + + + if (!(!m_isHashMatch.has_value())) { + result["IsHashMatch"] = Jellyfin::Support::toJsonValue>(m_isHashMatch); + } + return result; } diff --git a/core/src/dto/removefromplaylistrequestdto.cpp b/core/src/dto/removefromplaylistrequestdto.cpp index 20219b2..a4108bd 100644 --- a/core/src/dto/removefromplaylistrequestdto.cpp +++ b/core/src/dto/removefromplaylistrequestdto.cpp @@ -57,8 +57,12 @@ void RemoveFromPlaylistRequestDto::setFromJson(QJsonObject source) { QJsonObject RemoveFromPlaylistRequestDto::toJson() const { QJsonObject result; - result["PlaylistItemIds"] = Jellyfin::Support::toJsonValue(m_playlistItemIds); - + + + if (!(m_playlistItemIds.size() == 0)) { + result["PlaylistItemIds"] = Jellyfin::Support::toJsonValue(m_playlistItemIds); + } + return result; } diff --git a/core/src/dto/repositoryinfo.cpp b/core/src/dto/repositoryinfo.cpp index 3fd54b8..c57f976 100644 --- a/core/src/dto/repositoryinfo.cpp +++ b/core/src/dto/repositoryinfo.cpp @@ -63,10 +63,18 @@ void RepositoryInfo::setFromJson(QJsonObject source) { QJsonObject RepositoryInfo::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Url"] = Jellyfin::Support::toJsonValue(m_url); - result["Enabled"] = Jellyfin::Support::toJsonValue(m_enabled); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_url.isNull())) { + result["Url"] = Jellyfin::Support::toJsonValue(m_url); + } + + result["Enabled"] = Jellyfin::Support::toJsonValue(m_enabled); return result; } diff --git a/core/src/dto/responseprofile.cpp b/core/src/dto/responseprofile.cpp index 9327d0e..6f6f93c 100644 --- a/core/src/dto/responseprofile.cpp +++ b/core/src/dto/responseprofile.cpp @@ -75,14 +75,38 @@ void ResponseProfile::setFromJson(QJsonObject source) { QJsonObject ResponseProfile::toJson() const { QJsonObject result; - result["Container"] = Jellyfin::Support::toJsonValue(m_container); - result["AudioCodec"] = Jellyfin::Support::toJsonValue(m_audioCodec); - result["VideoCodec"] = Jellyfin::Support::toJsonValue(m_videoCodec); - result["Type"] = Jellyfin::Support::toJsonValue(m_type); - result["OrgPn"] = Jellyfin::Support::toJsonValue(m_orgPn); - result["MimeType"] = Jellyfin::Support::toJsonValue(m_mimeType); - result["Conditions"] = Jellyfin::Support::toJsonValue>(m_conditions); - + + + if (!(m_container.isNull())) { + result["Container"] = Jellyfin::Support::toJsonValue(m_container); + } + + + if (!(m_audioCodec.isNull())) { + result["AudioCodec"] = Jellyfin::Support::toJsonValue(m_audioCodec); + } + + + if (!(m_videoCodec.isNull())) { + result["VideoCodec"] = Jellyfin::Support::toJsonValue(m_videoCodec); + } + + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + + if (!(m_orgPn.isNull())) { + result["OrgPn"] = Jellyfin::Support::toJsonValue(m_orgPn); + } + + + if (!(m_mimeType.isNull())) { + result["MimeType"] = Jellyfin::Support::toJsonValue(m_mimeType); + } + + + if (!(m_conditions.size() == 0)) { + result["Conditions"] = Jellyfin::Support::toJsonValue>(m_conditions); + } + return result; } diff --git a/core/src/dto/searchhint.cpp b/core/src/dto/searchhint.cpp index 1dfc088..c7c04d5 100644 --- a/core/src/dto/searchhint.cpp +++ b/core/src/dto/searchhint.cpp @@ -141,36 +141,136 @@ void SearchHint::setFromJson(QJsonObject source) { QJsonObject SearchHint::toJson() const { QJsonObject result; - result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["MatchedTerm"] = Jellyfin::Support::toJsonValue(m_matchedTerm); - result["IndexNumber"] = Jellyfin::Support::toJsonValue>(m_indexNumber); - result["ProductionYear"] = Jellyfin::Support::toJsonValue>(m_productionYear); - result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue>(m_parentIndexNumber); - result["PrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_primaryImageTag); - result["ThumbImageTag"] = Jellyfin::Support::toJsonValue(m_thumbImageTag); - result["ThumbImageItemId"] = Jellyfin::Support::toJsonValue(m_thumbImageItemId); - result["BackdropImageTag"] = Jellyfin::Support::toJsonValue(m_backdropImageTag); - result["BackdropImageItemId"] = Jellyfin::Support::toJsonValue(m_backdropImageItemId); - result["Type"] = Jellyfin::Support::toJsonValue(m_type); - result["IsFolder"] = Jellyfin::Support::toJsonValue>(m_isFolder); - result["RunTimeTicks"] = Jellyfin::Support::toJsonValue>(m_runTimeTicks); - result["MediaType"] = Jellyfin::Support::toJsonValue(m_mediaType); - result["StartDate"] = Jellyfin::Support::toJsonValue(m_startDate); - result["EndDate"] = Jellyfin::Support::toJsonValue(m_endDate); - result["Series"] = Jellyfin::Support::toJsonValue(m_series); - result["Status"] = Jellyfin::Support::toJsonValue(m_status); - result["Album"] = Jellyfin::Support::toJsonValue(m_album); - result["AlbumId"] = Jellyfin::Support::toJsonValue(m_albumId); - result["AlbumArtist"] = Jellyfin::Support::toJsonValue(m_albumArtist); - result["Artists"] = Jellyfin::Support::toJsonValue(m_artists); - result["SongCount"] = Jellyfin::Support::toJsonValue>(m_songCount); - result["EpisodeCount"] = Jellyfin::Support::toJsonValue>(m_episodeCount); - result["ChannelId"] = Jellyfin::Support::toJsonValue(m_channelId); - result["ChannelName"] = Jellyfin::Support::toJsonValue(m_channelName); - result["PrimaryImageAspectRatio"] = Jellyfin::Support::toJsonValue>(m_primaryImageAspectRatio); - + + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_matchedTerm.isNull())) { + result["MatchedTerm"] = Jellyfin::Support::toJsonValue(m_matchedTerm); + } + + + if (!(!m_indexNumber.has_value())) { + result["IndexNumber"] = Jellyfin::Support::toJsonValue>(m_indexNumber); + } + + + if (!(!m_productionYear.has_value())) { + result["ProductionYear"] = Jellyfin::Support::toJsonValue>(m_productionYear); + } + + + if (!(!m_parentIndexNumber.has_value())) { + result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue>(m_parentIndexNumber); + } + + + if (!(m_primaryImageTag.isNull())) { + result["PrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_primaryImageTag); + } + + + if (!(m_thumbImageTag.isNull())) { + result["ThumbImageTag"] = Jellyfin::Support::toJsonValue(m_thumbImageTag); + } + + + if (!(m_thumbImageItemId.isNull())) { + result["ThumbImageItemId"] = Jellyfin::Support::toJsonValue(m_thumbImageItemId); + } + + + if (!(m_backdropImageTag.isNull())) { + result["BackdropImageTag"] = Jellyfin::Support::toJsonValue(m_backdropImageTag); + } + + + if (!(m_backdropImageItemId.isNull())) { + result["BackdropImageItemId"] = Jellyfin::Support::toJsonValue(m_backdropImageItemId); + } + + + if (!(m_type.isNull())) { + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + } + + + if (!(!m_isFolder.has_value())) { + result["IsFolder"] = Jellyfin::Support::toJsonValue>(m_isFolder); + } + + + if (!(!m_runTimeTicks.has_value())) { + result["RunTimeTicks"] = Jellyfin::Support::toJsonValue>(m_runTimeTicks); + } + + + if (!(m_mediaType.isNull())) { + result["MediaType"] = Jellyfin::Support::toJsonValue(m_mediaType); + } + + + if (!(m_startDate.isNull())) { + result["StartDate"] = Jellyfin::Support::toJsonValue(m_startDate); + } + + + if (!(m_endDate.isNull())) { + result["EndDate"] = Jellyfin::Support::toJsonValue(m_endDate); + } + + + if (!(m_series.isNull())) { + result["Series"] = Jellyfin::Support::toJsonValue(m_series); + } + + + if (!(m_status.isNull())) { + result["Status"] = Jellyfin::Support::toJsonValue(m_status); + } + + + if (!(m_album.isNull())) { + result["Album"] = Jellyfin::Support::toJsonValue(m_album); + } + + result["AlbumId"] = Jellyfin::Support::toJsonValue(m_albumId); + + if (!(m_albumArtist.isNull())) { + result["AlbumArtist"] = Jellyfin::Support::toJsonValue(m_albumArtist); + } + + + if (!(m_artists.size() == 0)) { + result["Artists"] = Jellyfin::Support::toJsonValue(m_artists); + } + + + if (!(!m_songCount.has_value())) { + result["SongCount"] = Jellyfin::Support::toJsonValue>(m_songCount); + } + + + if (!(!m_episodeCount.has_value())) { + result["EpisodeCount"] = Jellyfin::Support::toJsonValue>(m_episodeCount); + } + + result["ChannelId"] = Jellyfin::Support::toJsonValue(m_channelId); + + if (!(m_channelName.isNull())) { + result["ChannelName"] = Jellyfin::Support::toJsonValue(m_channelName); + } + + + if (!(!m_primaryImageAspectRatio.has_value())) { + result["PrimaryImageAspectRatio"] = Jellyfin::Support::toJsonValue>(m_primaryImageAspectRatio); + } + return result; } diff --git a/core/src/dto/searchhintresult.cpp b/core/src/dto/searchhintresult.cpp index 9e00a46..1ed89ed 100644 --- a/core/src/dto/searchhintresult.cpp +++ b/core/src/dto/searchhintresult.cpp @@ -60,9 +60,13 @@ void SearchHintResult::setFromJson(QJsonObject source) { QJsonObject SearchHintResult::toJson() const { QJsonObject result; - result["SearchHints"] = Jellyfin::Support::toJsonValue>(m_searchHints); - result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); - + + + if (!(m_searchHints.size() == 0)) { + result["SearchHints"] = Jellyfin::Support::toJsonValue>(m_searchHints); + } + + result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); return result; } diff --git a/core/src/dto/seekrequestdto.cpp b/core/src/dto/seekrequestdto.cpp index 57edc8a..a616bc1 100644 --- a/core/src/dto/seekrequestdto.cpp +++ b/core/src/dto/seekrequestdto.cpp @@ -57,8 +57,8 @@ void SeekRequestDto::setFromJson(QJsonObject source) { QJsonObject SeekRequestDto::toJson() const { QJsonObject result; - result["PositionTicks"] = Jellyfin::Support::toJsonValue(m_positionTicks); - + + result["PositionTicks"] = Jellyfin::Support::toJsonValue(m_positionTicks); return result; } diff --git a/core/src/dto/sendcommand.cpp b/core/src/dto/sendcommand.cpp index 230e82e..6d32adb 100644 --- a/core/src/dto/sendcommand.cpp +++ b/core/src/dto/sendcommand.cpp @@ -72,13 +72,17 @@ void SendCommand::setFromJson(QJsonObject source) { QJsonObject SendCommand::toJson() const { QJsonObject result; - result["GroupId"] = Jellyfin::Support::toJsonValue(m_groupId); - result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); - result["When"] = Jellyfin::Support::toJsonValue(m_when); - result["PositionTicks"] = Jellyfin::Support::toJsonValue>(m_positionTicks); - result["Command"] = Jellyfin::Support::toJsonValue(m_command); - result["EmittedAt"] = Jellyfin::Support::toJsonValue(m_emittedAt); - + + result["GroupId"] = Jellyfin::Support::toJsonValue(m_groupId); + result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); + result["When"] = Jellyfin::Support::toJsonValue(m_when); + + if (!(!m_positionTicks.has_value())) { + result["PositionTicks"] = Jellyfin::Support::toJsonValue>(m_positionTicks); + } + + result["Command"] = Jellyfin::Support::toJsonValue(m_command); + result["EmittedAt"] = Jellyfin::Support::toJsonValue(m_emittedAt); return result; } diff --git a/core/src/dto/seriesinfo.cpp b/core/src/dto/seriesinfo.cpp index fff0594..69f0a8b 100644 --- a/core/src/dto/seriesinfo.cpp +++ b/core/src/dto/seriesinfo.cpp @@ -84,17 +84,53 @@ void SeriesInfo::setFromJson(QJsonObject source) { QJsonObject SeriesInfo::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Path"] = Jellyfin::Support::toJsonValue(m_path); - result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); - result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); - result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); - result["Year"] = Jellyfin::Support::toJsonValue>(m_year); - result["IndexNumber"] = Jellyfin::Support::toJsonValue>(m_indexNumber); - result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue>(m_parentIndexNumber); - result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); - result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_path.isNull())) { + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + } + + + if (!(m_metadataLanguage.isNull())) { + result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); + } + + + if (!(m_metadataCountryCode.isNull())) { + result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); + } + + + if (!(m_providerIds.isEmpty())) { + result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); + } + + + if (!(!m_year.has_value())) { + result["Year"] = Jellyfin::Support::toJsonValue>(m_year); + } + + + if (!(!m_indexNumber.has_value())) { + result["IndexNumber"] = Jellyfin::Support::toJsonValue>(m_indexNumber); + } + + + if (!(!m_parentIndexNumber.has_value())) { + result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue>(m_parentIndexNumber); + } + + + if (!(m_premiereDate.isNull())) { + result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); + } + + result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); return result; } diff --git a/core/src/dto/seriesinforemotesearchquery.cpp b/core/src/dto/seriesinforemotesearchquery.cpp index b05c66e..e68cb7e 100644 --- a/core/src/dto/seriesinforemotesearchquery.cpp +++ b/core/src/dto/seriesinforemotesearchquery.cpp @@ -66,11 +66,15 @@ void SeriesInfoRemoteSearchQuery::setFromJson(QJsonObject source) { QJsonObject SeriesInfoRemoteSearchQuery::toJson() const { QJsonObject result; - result["SearchInfo"] = Jellyfin::Support::toJsonValue>(m_searchInfo); - result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); - result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); - result["IncludeDisabledProviders"] = Jellyfin::Support::toJsonValue(m_includeDisabledProviders); - + + result["SearchInfo"] = Jellyfin::Support::toJsonValue>(m_searchInfo); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + + if (!(m_searchProviderName.isNull())) { + result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); + } + + result["IncludeDisabledProviders"] = Jellyfin::Support::toJsonValue(m_includeDisabledProviders); return result; } diff --git a/core/src/dto/seriestimerinfodto.cpp b/core/src/dto/seriestimerinfodto.cpp index 04da1d7..248f00a 100644 --- a/core/src/dto/seriestimerinfodto.cpp +++ b/core/src/dto/seriestimerinfodto.cpp @@ -159,42 +159,122 @@ void SeriesTimerInfoDto::setFromJson(QJsonObject source) { QJsonObject SeriesTimerInfoDto::toJson() const { QJsonObject result; - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["Type"] = Jellyfin::Support::toJsonValue(m_type); - result["ServerId"] = Jellyfin::Support::toJsonValue(m_serverId); - result["ExternalId"] = Jellyfin::Support::toJsonValue(m_externalId); - result["ChannelId"] = Jellyfin::Support::toJsonValue(m_channelId); - result["ExternalChannelId"] = Jellyfin::Support::toJsonValue(m_externalChannelId); - result["ChannelName"] = Jellyfin::Support::toJsonValue(m_channelName); - result["ChannelPrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_channelPrimaryImageTag); - result["ProgramId"] = Jellyfin::Support::toJsonValue(m_programId); - result["ExternalProgramId"] = Jellyfin::Support::toJsonValue(m_externalProgramId); - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Overview"] = Jellyfin::Support::toJsonValue(m_overview); - result["StartDate"] = Jellyfin::Support::toJsonValue(m_startDate); - result["EndDate"] = Jellyfin::Support::toJsonValue(m_endDate); - result["ServiceName"] = Jellyfin::Support::toJsonValue(m_serviceName); - result["Priority"] = Jellyfin::Support::toJsonValue(m_priority); - result["PrePaddingSeconds"] = Jellyfin::Support::toJsonValue(m_prePaddingSeconds); - result["PostPaddingSeconds"] = Jellyfin::Support::toJsonValue(m_postPaddingSeconds); - result["IsPrePaddingRequired"] = Jellyfin::Support::toJsonValue(m_isPrePaddingRequired); - result["ParentBackdropItemId"] = Jellyfin::Support::toJsonValue(m_parentBackdropItemId); - result["ParentBackdropImageTags"] = Jellyfin::Support::toJsonValue(m_parentBackdropImageTags); - result["IsPostPaddingRequired"] = Jellyfin::Support::toJsonValue(m_isPostPaddingRequired); - result["KeepUntil"] = Jellyfin::Support::toJsonValue(m_keepUntil); - result["RecordAnyTime"] = Jellyfin::Support::toJsonValue(m_recordAnyTime); - result["SkipEpisodesInLibrary"] = Jellyfin::Support::toJsonValue(m_skipEpisodesInLibrary); - result["RecordAnyChannel"] = Jellyfin::Support::toJsonValue(m_recordAnyChannel); - result["KeepUpTo"] = Jellyfin::Support::toJsonValue(m_keepUpTo); - result["RecordNewOnly"] = Jellyfin::Support::toJsonValue(m_recordNewOnly); - result["Days"] = Jellyfin::Support::toJsonValue>(m_days); - result["DayPattern"] = Jellyfin::Support::toJsonValue(m_dayPattern); - result["ImageTags"] = Jellyfin::Support::toJsonValue(m_imageTags); - result["ParentThumbItemId"] = Jellyfin::Support::toJsonValue(m_parentThumbItemId); - result["ParentThumbImageTag"] = Jellyfin::Support::toJsonValue(m_parentThumbImageTag); - result["ParentPrimaryImageItemId"] = Jellyfin::Support::toJsonValue(m_parentPrimaryImageItemId); - result["ParentPrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_parentPrimaryImageTag); - + + + if (!(m_jellyfinId.isNull())) { + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + } + + + if (!(m_type.isNull())) { + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + } + + + if (!(m_serverId.isNull())) { + result["ServerId"] = Jellyfin::Support::toJsonValue(m_serverId); + } + + + if (!(m_externalId.isNull())) { + result["ExternalId"] = Jellyfin::Support::toJsonValue(m_externalId); + } + + result["ChannelId"] = Jellyfin::Support::toJsonValue(m_channelId); + + if (!(m_externalChannelId.isNull())) { + result["ExternalChannelId"] = Jellyfin::Support::toJsonValue(m_externalChannelId); + } + + + if (!(m_channelName.isNull())) { + result["ChannelName"] = Jellyfin::Support::toJsonValue(m_channelName); + } + + + if (!(m_channelPrimaryImageTag.isNull())) { + result["ChannelPrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_channelPrimaryImageTag); + } + + + if (!(m_programId.isNull())) { + result["ProgramId"] = Jellyfin::Support::toJsonValue(m_programId); + } + + + if (!(m_externalProgramId.isNull())) { + result["ExternalProgramId"] = Jellyfin::Support::toJsonValue(m_externalProgramId); + } + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_overview.isNull())) { + result["Overview"] = Jellyfin::Support::toJsonValue(m_overview); + } + + result["StartDate"] = Jellyfin::Support::toJsonValue(m_startDate); + result["EndDate"] = Jellyfin::Support::toJsonValue(m_endDate); + + if (!(m_serviceName.isNull())) { + result["ServiceName"] = Jellyfin::Support::toJsonValue(m_serviceName); + } + + result["Priority"] = Jellyfin::Support::toJsonValue(m_priority); + result["PrePaddingSeconds"] = Jellyfin::Support::toJsonValue(m_prePaddingSeconds); + result["PostPaddingSeconds"] = Jellyfin::Support::toJsonValue(m_postPaddingSeconds); + result["IsPrePaddingRequired"] = Jellyfin::Support::toJsonValue(m_isPrePaddingRequired); + + if (!(m_parentBackdropItemId.isNull())) { + result["ParentBackdropItemId"] = Jellyfin::Support::toJsonValue(m_parentBackdropItemId); + } + + + if (!(m_parentBackdropImageTags.size() == 0)) { + result["ParentBackdropImageTags"] = Jellyfin::Support::toJsonValue(m_parentBackdropImageTags); + } + + result["IsPostPaddingRequired"] = Jellyfin::Support::toJsonValue(m_isPostPaddingRequired); + result["KeepUntil"] = Jellyfin::Support::toJsonValue(m_keepUntil); + result["RecordAnyTime"] = Jellyfin::Support::toJsonValue(m_recordAnyTime); + result["SkipEpisodesInLibrary"] = Jellyfin::Support::toJsonValue(m_skipEpisodesInLibrary); + result["RecordAnyChannel"] = Jellyfin::Support::toJsonValue(m_recordAnyChannel); + result["KeepUpTo"] = Jellyfin::Support::toJsonValue(m_keepUpTo); + result["RecordNewOnly"] = Jellyfin::Support::toJsonValue(m_recordNewOnly); + + if (!(m_days.size() == 0)) { + result["Days"] = Jellyfin::Support::toJsonValue>(m_days); + } + + result["DayPattern"] = Jellyfin::Support::toJsonValue(m_dayPattern); + + if (!(m_imageTags.isEmpty())) { + result["ImageTags"] = Jellyfin::Support::toJsonValue(m_imageTags); + } + + + if (!(m_parentThumbItemId.isNull())) { + result["ParentThumbItemId"] = Jellyfin::Support::toJsonValue(m_parentThumbItemId); + } + + + if (!(m_parentThumbImageTag.isNull())) { + result["ParentThumbImageTag"] = Jellyfin::Support::toJsonValue(m_parentThumbImageTag); + } + + + if (!(m_parentPrimaryImageItemId.isNull())) { + result["ParentPrimaryImageItemId"] = Jellyfin::Support::toJsonValue(m_parentPrimaryImageItemId); + } + + + if (!(m_parentPrimaryImageTag.isNull())) { + result["ParentPrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_parentPrimaryImageTag); + } + return result; } diff --git a/core/src/dto/seriestimerinfodtoqueryresult.cpp b/core/src/dto/seriestimerinfodtoqueryresult.cpp index 8ed7193..7d6b144 100644 --- a/core/src/dto/seriestimerinfodtoqueryresult.cpp +++ b/core/src/dto/seriestimerinfodtoqueryresult.cpp @@ -63,10 +63,14 @@ void SeriesTimerInfoDtoQueryResult::setFromJson(QJsonObject source) { QJsonObject SeriesTimerInfoDtoQueryResult::toJson() const { QJsonObject result; - result["Items"] = Jellyfin::Support::toJsonValue>(m_items); - result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); - result["StartIndex"] = Jellyfin::Support::toJsonValue(m_startIndex); - + + + if (!(m_items.size() == 0)) { + result["Items"] = Jellyfin::Support::toJsonValue>(m_items); + } + + result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); + result["StartIndex"] = Jellyfin::Support::toJsonValue(m_startIndex); return result; } diff --git a/core/src/dto/serverconfiguration.cpp b/core/src/dto/serverconfiguration.cpp index 4a6b5bc..4abeb19 100644 --- a/core/src/dto/serverconfiguration.cpp +++ b/core/src/dto/serverconfiguration.cpp @@ -309,92 +309,216 @@ void ServerConfiguration::setFromJson(QJsonObject source) { QJsonObject ServerConfiguration::toJson() const { QJsonObject result; - result["LogFileRetentionDays"] = Jellyfin::Support::toJsonValue(m_logFileRetentionDays); - result["IsStartupWizardCompleted"] = Jellyfin::Support::toJsonValue(m_isStartupWizardCompleted); - result["CachePath"] = Jellyfin::Support::toJsonValue(m_cachePath); - result["PreviousVersion"] = Jellyfin::Support::toJsonValue>(m_previousVersion); - result["PreviousVersionStr"] = Jellyfin::Support::toJsonValue(m_previousVersionStr); - result["EnableUPnP"] = Jellyfin::Support::toJsonValue(m_enableUPnP); - result["EnableMetrics"] = Jellyfin::Support::toJsonValue(m_enableMetrics); - result["PublicPort"] = Jellyfin::Support::toJsonValue(m_publicPort); - result["UPnPCreateHttpPortMap"] = Jellyfin::Support::toJsonValue(m_uPnPCreateHttpPortMap); - result["UDPPortRange"] = Jellyfin::Support::toJsonValue(m_uDPPortRange); - result["EnableIPV6"] = Jellyfin::Support::toJsonValue(m_enableIPV6); - result["EnableIPV4"] = Jellyfin::Support::toJsonValue(m_enableIPV4); - result["EnableSSDPTracing"] = Jellyfin::Support::toJsonValue(m_enableSSDPTracing); - result["SSDPTracingFilter"] = Jellyfin::Support::toJsonValue(m_sSDPTracingFilter); - result["UDPSendCount"] = Jellyfin::Support::toJsonValue(m_uDPSendCount); - result["UDPSendDelay"] = Jellyfin::Support::toJsonValue(m_uDPSendDelay); - result["IgnoreVirtualInterfaces"] = Jellyfin::Support::toJsonValue(m_ignoreVirtualInterfaces); - result["VirtualInterfaceNames"] = Jellyfin::Support::toJsonValue(m_virtualInterfaceNames); - result["GatewayMonitorPeriod"] = Jellyfin::Support::toJsonValue(m_gatewayMonitorPeriod); - result["EnableMultiSocketBinding"] = Jellyfin::Support::toJsonValue(m_enableMultiSocketBinding); - result["TrustAllIP6Interfaces"] = Jellyfin::Support::toJsonValue(m_trustAllIP6Interfaces); - result["HDHomerunPortRange"] = Jellyfin::Support::toJsonValue(m_hDHomerunPortRange); - result["PublishedServerUriBySubnet"] = Jellyfin::Support::toJsonValue(m_publishedServerUriBySubnet); - result["AutoDiscoveryTracing"] = Jellyfin::Support::toJsonValue(m_autoDiscoveryTracing); - result["AutoDiscovery"] = Jellyfin::Support::toJsonValue(m_autoDiscovery); - result["PublicHttpsPort"] = Jellyfin::Support::toJsonValue(m_publicHttpsPort); - result["HttpServerPortNumber"] = Jellyfin::Support::toJsonValue(m_httpServerPortNumber); - result["HttpsPortNumber"] = Jellyfin::Support::toJsonValue(m_httpsPortNumber); - result["EnableHttps"] = Jellyfin::Support::toJsonValue(m_enableHttps); - result["EnableNormalizedItemByNameIds"] = Jellyfin::Support::toJsonValue(m_enableNormalizedItemByNameIds); - result["CertificatePath"] = Jellyfin::Support::toJsonValue(m_certificatePath); - result["CertificatePassword"] = Jellyfin::Support::toJsonValue(m_certificatePassword); - result["IsPortAuthorized"] = Jellyfin::Support::toJsonValue(m_isPortAuthorized); - result["QuickConnectAvailable"] = Jellyfin::Support::toJsonValue(m_quickConnectAvailable); - result["EnableRemoteAccess"] = Jellyfin::Support::toJsonValue(m_enableRemoteAccess); - result["EnableCaseSensitiveItemIds"] = Jellyfin::Support::toJsonValue(m_enableCaseSensitiveItemIds); - result["DisableLiveTvChannelUserDataName"] = Jellyfin::Support::toJsonValue(m_disableLiveTvChannelUserDataName); - result["MetadataPath"] = Jellyfin::Support::toJsonValue(m_metadataPath); - result["MetadataNetworkPath"] = Jellyfin::Support::toJsonValue(m_metadataNetworkPath); - result["PreferredMetadataLanguage"] = Jellyfin::Support::toJsonValue(m_preferredMetadataLanguage); - result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); - result["SortReplaceCharacters"] = Jellyfin::Support::toJsonValue(m_sortReplaceCharacters); - result["SortRemoveCharacters"] = Jellyfin::Support::toJsonValue(m_sortRemoveCharacters); - result["SortRemoveWords"] = Jellyfin::Support::toJsonValue(m_sortRemoveWords); - result["MinResumePct"] = Jellyfin::Support::toJsonValue(m_minResumePct); - result["MaxResumePct"] = Jellyfin::Support::toJsonValue(m_maxResumePct); - result["MinResumeDurationSeconds"] = Jellyfin::Support::toJsonValue(m_minResumeDurationSeconds); - result["MinAudiobookResume"] = Jellyfin::Support::toJsonValue(m_minAudiobookResume); - result["MaxAudiobookResume"] = Jellyfin::Support::toJsonValue(m_maxAudiobookResume); - result["LibraryMonitorDelay"] = Jellyfin::Support::toJsonValue(m_libraryMonitorDelay); - result["EnableDashboardResponseCaching"] = Jellyfin::Support::toJsonValue(m_enableDashboardResponseCaching); - result["ImageSavingConvention"] = Jellyfin::Support::toJsonValue(m_imageSavingConvention); - result["MetadataOptions"] = Jellyfin::Support::toJsonValue>(m_metadataOptions); - result["SkipDeserializationForBasicTypes"] = Jellyfin::Support::toJsonValue(m_skipDeserializationForBasicTypes); - result["ServerName"] = Jellyfin::Support::toJsonValue(m_serverName); - result["BaseUrl"] = Jellyfin::Support::toJsonValue(m_baseUrl); - result["UICulture"] = Jellyfin::Support::toJsonValue(m_uICulture); - result["SaveMetadataHidden"] = Jellyfin::Support::toJsonValue(m_saveMetadataHidden); - result["ContentTypes"] = Jellyfin::Support::toJsonValue>(m_contentTypes); - result["RemoteClientBitrateLimit"] = Jellyfin::Support::toJsonValue(m_remoteClientBitrateLimit); - result["EnableFolderView"] = Jellyfin::Support::toJsonValue(m_enableFolderView); - result["EnableGroupingIntoCollections"] = Jellyfin::Support::toJsonValue(m_enableGroupingIntoCollections); - result["DisplaySpecialsWithinSeasons"] = Jellyfin::Support::toJsonValue(m_displaySpecialsWithinSeasons); - result["LocalNetworkSubnets"] = Jellyfin::Support::toJsonValue(m_localNetworkSubnets); - result["LocalNetworkAddresses"] = Jellyfin::Support::toJsonValue(m_localNetworkAddresses); - result["CodecsUsed"] = Jellyfin::Support::toJsonValue(m_codecsUsed); - result["PluginRepositories"] = Jellyfin::Support::toJsonValue>(m_pluginRepositories); - result["EnableExternalContentInSuggestions"] = Jellyfin::Support::toJsonValue(m_enableExternalContentInSuggestions); - result["RequireHttps"] = Jellyfin::Support::toJsonValue(m_requireHttps); - result["EnableNewOmdbSupport"] = Jellyfin::Support::toJsonValue(m_enableNewOmdbSupport); - result["RemoteIPFilter"] = Jellyfin::Support::toJsonValue(m_remoteIPFilter); - result["IsRemoteIPFilterBlacklist"] = Jellyfin::Support::toJsonValue(m_isRemoteIPFilterBlacklist); - result["ImageExtractionTimeoutMs"] = Jellyfin::Support::toJsonValue(m_imageExtractionTimeoutMs); - result["PathSubstitutions"] = Jellyfin::Support::toJsonValue>(m_pathSubstitutions); - result["EnableSimpleArtistDetection"] = Jellyfin::Support::toJsonValue(m_enableSimpleArtistDetection); - result["UninstalledPlugins"] = Jellyfin::Support::toJsonValue(m_uninstalledPlugins); - result["EnableSlowResponseWarning"] = Jellyfin::Support::toJsonValue(m_enableSlowResponseWarning); - result["SlowResponseThresholdMs"] = Jellyfin::Support::toJsonValue(m_slowResponseThresholdMs); - result["CorsHosts"] = Jellyfin::Support::toJsonValue(m_corsHosts); - result["KnownProxies"] = Jellyfin::Support::toJsonValue(m_knownProxies); - result["ActivityLogRetentionDays"] = Jellyfin::Support::toJsonValue>(m_activityLogRetentionDays); - result["LibraryScanFanoutConcurrency"] = Jellyfin::Support::toJsonValue(m_libraryScanFanoutConcurrency); - result["LibraryMetadataRefreshConcurrency"] = Jellyfin::Support::toJsonValue(m_libraryMetadataRefreshConcurrency); - result["RemoveOldPlugins"] = Jellyfin::Support::toJsonValue(m_removeOldPlugins); - result["DisablePluginImages"] = Jellyfin::Support::toJsonValue(m_disablePluginImages); - + + result["LogFileRetentionDays"] = Jellyfin::Support::toJsonValue(m_logFileRetentionDays); + result["IsStartupWizardCompleted"] = Jellyfin::Support::toJsonValue(m_isStartupWizardCompleted); + + if (!(m_cachePath.isNull())) { + result["CachePath"] = Jellyfin::Support::toJsonValue(m_cachePath); + } + + result["PreviousVersion"] = Jellyfin::Support::toJsonValue>(m_previousVersion); + + if (!(m_previousVersionStr.isNull())) { + result["PreviousVersionStr"] = Jellyfin::Support::toJsonValue(m_previousVersionStr); + } + + result["EnableUPnP"] = Jellyfin::Support::toJsonValue(m_enableUPnP); + result["EnableMetrics"] = Jellyfin::Support::toJsonValue(m_enableMetrics); + result["PublicPort"] = Jellyfin::Support::toJsonValue(m_publicPort); + result["UPnPCreateHttpPortMap"] = Jellyfin::Support::toJsonValue(m_uPnPCreateHttpPortMap); + + if (!(m_uDPPortRange.isNull())) { + result["UDPPortRange"] = Jellyfin::Support::toJsonValue(m_uDPPortRange); + } + + result["EnableIPV6"] = Jellyfin::Support::toJsonValue(m_enableIPV6); + result["EnableIPV4"] = Jellyfin::Support::toJsonValue(m_enableIPV4); + result["EnableSSDPTracing"] = Jellyfin::Support::toJsonValue(m_enableSSDPTracing); + + if (!(m_sSDPTracingFilter.isNull())) { + result["SSDPTracingFilter"] = Jellyfin::Support::toJsonValue(m_sSDPTracingFilter); + } + + result["UDPSendCount"] = Jellyfin::Support::toJsonValue(m_uDPSendCount); + result["UDPSendDelay"] = Jellyfin::Support::toJsonValue(m_uDPSendDelay); + result["IgnoreVirtualInterfaces"] = Jellyfin::Support::toJsonValue(m_ignoreVirtualInterfaces); + + if (!(m_virtualInterfaceNames.isNull())) { + result["VirtualInterfaceNames"] = Jellyfin::Support::toJsonValue(m_virtualInterfaceNames); + } + + result["GatewayMonitorPeriod"] = Jellyfin::Support::toJsonValue(m_gatewayMonitorPeriod); + result["EnableMultiSocketBinding"] = Jellyfin::Support::toJsonValue(m_enableMultiSocketBinding); + result["TrustAllIP6Interfaces"] = Jellyfin::Support::toJsonValue(m_trustAllIP6Interfaces); + + if (!(m_hDHomerunPortRange.isNull())) { + result["HDHomerunPortRange"] = Jellyfin::Support::toJsonValue(m_hDHomerunPortRange); + } + + + if (!(m_publishedServerUriBySubnet.size() == 0)) { + result["PublishedServerUriBySubnet"] = Jellyfin::Support::toJsonValue(m_publishedServerUriBySubnet); + } + + result["AutoDiscoveryTracing"] = Jellyfin::Support::toJsonValue(m_autoDiscoveryTracing); + result["AutoDiscovery"] = Jellyfin::Support::toJsonValue(m_autoDiscovery); + result["PublicHttpsPort"] = Jellyfin::Support::toJsonValue(m_publicHttpsPort); + result["HttpServerPortNumber"] = Jellyfin::Support::toJsonValue(m_httpServerPortNumber); + result["HttpsPortNumber"] = Jellyfin::Support::toJsonValue(m_httpsPortNumber); + result["EnableHttps"] = Jellyfin::Support::toJsonValue(m_enableHttps); + result["EnableNormalizedItemByNameIds"] = Jellyfin::Support::toJsonValue(m_enableNormalizedItemByNameIds); + + if (!(m_certificatePath.isNull())) { + result["CertificatePath"] = Jellyfin::Support::toJsonValue(m_certificatePath); + } + + + if (!(m_certificatePassword.isNull())) { + result["CertificatePassword"] = Jellyfin::Support::toJsonValue(m_certificatePassword); + } + + result["IsPortAuthorized"] = Jellyfin::Support::toJsonValue(m_isPortAuthorized); + result["QuickConnectAvailable"] = Jellyfin::Support::toJsonValue(m_quickConnectAvailable); + result["EnableRemoteAccess"] = Jellyfin::Support::toJsonValue(m_enableRemoteAccess); + result["EnableCaseSensitiveItemIds"] = Jellyfin::Support::toJsonValue(m_enableCaseSensitiveItemIds); + result["DisableLiveTvChannelUserDataName"] = Jellyfin::Support::toJsonValue(m_disableLiveTvChannelUserDataName); + + if (!(m_metadataPath.isNull())) { + result["MetadataPath"] = Jellyfin::Support::toJsonValue(m_metadataPath); + } + + + if (!(m_metadataNetworkPath.isNull())) { + result["MetadataNetworkPath"] = Jellyfin::Support::toJsonValue(m_metadataNetworkPath); + } + + + if (!(m_preferredMetadataLanguage.isNull())) { + result["PreferredMetadataLanguage"] = Jellyfin::Support::toJsonValue(m_preferredMetadataLanguage); + } + + + if (!(m_metadataCountryCode.isNull())) { + result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); + } + + + if (!(m_sortReplaceCharacters.size() == 0)) { + result["SortReplaceCharacters"] = Jellyfin::Support::toJsonValue(m_sortReplaceCharacters); + } + + + if (!(m_sortRemoveCharacters.size() == 0)) { + result["SortRemoveCharacters"] = Jellyfin::Support::toJsonValue(m_sortRemoveCharacters); + } + + + if (!(m_sortRemoveWords.size() == 0)) { + result["SortRemoveWords"] = Jellyfin::Support::toJsonValue(m_sortRemoveWords); + } + + result["MinResumePct"] = Jellyfin::Support::toJsonValue(m_minResumePct); + result["MaxResumePct"] = Jellyfin::Support::toJsonValue(m_maxResumePct); + result["MinResumeDurationSeconds"] = Jellyfin::Support::toJsonValue(m_minResumeDurationSeconds); + result["MinAudiobookResume"] = Jellyfin::Support::toJsonValue(m_minAudiobookResume); + result["MaxAudiobookResume"] = Jellyfin::Support::toJsonValue(m_maxAudiobookResume); + result["LibraryMonitorDelay"] = Jellyfin::Support::toJsonValue(m_libraryMonitorDelay); + result["EnableDashboardResponseCaching"] = Jellyfin::Support::toJsonValue(m_enableDashboardResponseCaching); + result["ImageSavingConvention"] = Jellyfin::Support::toJsonValue(m_imageSavingConvention); + + if (!(m_metadataOptions.size() == 0)) { + result["MetadataOptions"] = Jellyfin::Support::toJsonValue>(m_metadataOptions); + } + + result["SkipDeserializationForBasicTypes"] = Jellyfin::Support::toJsonValue(m_skipDeserializationForBasicTypes); + + if (!(m_serverName.isNull())) { + result["ServerName"] = Jellyfin::Support::toJsonValue(m_serverName); + } + + + if (!(m_baseUrl.isNull())) { + result["BaseUrl"] = Jellyfin::Support::toJsonValue(m_baseUrl); + } + + + if (!(m_uICulture.isNull())) { + result["UICulture"] = Jellyfin::Support::toJsonValue(m_uICulture); + } + + result["SaveMetadataHidden"] = Jellyfin::Support::toJsonValue(m_saveMetadataHidden); + + if (!(m_contentTypes.size() == 0)) { + result["ContentTypes"] = Jellyfin::Support::toJsonValue>(m_contentTypes); + } + + result["RemoteClientBitrateLimit"] = Jellyfin::Support::toJsonValue(m_remoteClientBitrateLimit); + result["EnableFolderView"] = Jellyfin::Support::toJsonValue(m_enableFolderView); + result["EnableGroupingIntoCollections"] = Jellyfin::Support::toJsonValue(m_enableGroupingIntoCollections); + result["DisplaySpecialsWithinSeasons"] = Jellyfin::Support::toJsonValue(m_displaySpecialsWithinSeasons); + + if (!(m_localNetworkSubnets.size() == 0)) { + result["LocalNetworkSubnets"] = Jellyfin::Support::toJsonValue(m_localNetworkSubnets); + } + + + if (!(m_localNetworkAddresses.size() == 0)) { + result["LocalNetworkAddresses"] = Jellyfin::Support::toJsonValue(m_localNetworkAddresses); + } + + + if (!(m_codecsUsed.size() == 0)) { + result["CodecsUsed"] = Jellyfin::Support::toJsonValue(m_codecsUsed); + } + + + if (!(m_pluginRepositories.size() == 0)) { + result["PluginRepositories"] = Jellyfin::Support::toJsonValue>(m_pluginRepositories); + } + + result["EnableExternalContentInSuggestions"] = Jellyfin::Support::toJsonValue(m_enableExternalContentInSuggestions); + result["RequireHttps"] = Jellyfin::Support::toJsonValue(m_requireHttps); + result["EnableNewOmdbSupport"] = Jellyfin::Support::toJsonValue(m_enableNewOmdbSupport); + + if (!(m_remoteIPFilter.size() == 0)) { + result["RemoteIPFilter"] = Jellyfin::Support::toJsonValue(m_remoteIPFilter); + } + + result["IsRemoteIPFilterBlacklist"] = Jellyfin::Support::toJsonValue(m_isRemoteIPFilterBlacklist); + result["ImageExtractionTimeoutMs"] = Jellyfin::Support::toJsonValue(m_imageExtractionTimeoutMs); + + if (!(m_pathSubstitutions.size() == 0)) { + result["PathSubstitutions"] = Jellyfin::Support::toJsonValue>(m_pathSubstitutions); + } + + result["EnableSimpleArtistDetection"] = Jellyfin::Support::toJsonValue(m_enableSimpleArtistDetection); + + if (!(m_uninstalledPlugins.size() == 0)) { + result["UninstalledPlugins"] = Jellyfin::Support::toJsonValue(m_uninstalledPlugins); + } + + result["EnableSlowResponseWarning"] = Jellyfin::Support::toJsonValue(m_enableSlowResponseWarning); + result["SlowResponseThresholdMs"] = Jellyfin::Support::toJsonValue(m_slowResponseThresholdMs); + + if (!(m_corsHosts.size() == 0)) { + result["CorsHosts"] = Jellyfin::Support::toJsonValue(m_corsHosts); + } + + + if (!(m_knownProxies.size() == 0)) { + result["KnownProxies"] = Jellyfin::Support::toJsonValue(m_knownProxies); + } + + + if (!(!m_activityLogRetentionDays.has_value())) { + result["ActivityLogRetentionDays"] = Jellyfin::Support::toJsonValue>(m_activityLogRetentionDays); + } + + result["LibraryScanFanoutConcurrency"] = Jellyfin::Support::toJsonValue(m_libraryScanFanoutConcurrency); + result["LibraryMetadataRefreshConcurrency"] = Jellyfin::Support::toJsonValue(m_libraryMetadataRefreshConcurrency); + result["RemoveOldPlugins"] = Jellyfin::Support::toJsonValue(m_removeOldPlugins); + result["DisablePluginImages"] = Jellyfin::Support::toJsonValue(m_disablePluginImages); return result; } diff --git a/core/src/dto/sessioninfo.cpp b/core/src/dto/sessioninfo.cpp index c3d2bf9..139350e 100644 --- a/core/src/dto/sessioninfo.cpp +++ b/core/src/dto/sessioninfo.cpp @@ -138,35 +138,95 @@ void SessionInfo::setFromJson(QJsonObject source) { QJsonObject SessionInfo::toJson() const { QJsonObject result; - result["PlayState"] = Jellyfin::Support::toJsonValue>(m_playState); - result["AdditionalUsers"] = Jellyfin::Support::toJsonValue>(m_additionalUsers); - result["Capabilities"] = Jellyfin::Support::toJsonValue>(m_capabilities); - result["RemoteEndPoint"] = Jellyfin::Support::toJsonValue(m_remoteEndPoint); - result["PlayableMediaTypes"] = Jellyfin::Support::toJsonValue(m_playableMediaTypes); - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); - result["UserName"] = Jellyfin::Support::toJsonValue(m_userName); - result["Client"] = Jellyfin::Support::toJsonValue(m_client); - result["LastActivityDate"] = Jellyfin::Support::toJsonValue(m_lastActivityDate); - result["LastPlaybackCheckIn"] = Jellyfin::Support::toJsonValue(m_lastPlaybackCheckIn); - result["DeviceName"] = Jellyfin::Support::toJsonValue(m_deviceName); - result["DeviceType"] = Jellyfin::Support::toJsonValue(m_deviceType); - result["NowPlayingItem"] = Jellyfin::Support::toJsonValue>(m_nowPlayingItem); - result["FullNowPlayingItem"] = Jellyfin::Support::toJsonValue>(m_fullNowPlayingItem); - result["NowViewingItem"] = Jellyfin::Support::toJsonValue>(m_nowViewingItem); - result["DeviceId"] = Jellyfin::Support::toJsonValue(m_deviceId); - result["ApplicationVersion"] = Jellyfin::Support::toJsonValue(m_applicationVersion); - result["TranscodingInfo"] = Jellyfin::Support::toJsonValue>(m_transcodingInfo); - result["IsActive"] = Jellyfin::Support::toJsonValue(m_isActive); - result["SupportsMediaControl"] = Jellyfin::Support::toJsonValue(m_supportsMediaControl); - result["SupportsRemoteControl"] = Jellyfin::Support::toJsonValue(m_supportsRemoteControl); - result["NowPlayingQueue"] = Jellyfin::Support::toJsonValue>(m_nowPlayingQueue); - result["HasCustomDeviceName"] = Jellyfin::Support::toJsonValue(m_hasCustomDeviceName); - result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); - result["ServerId"] = Jellyfin::Support::toJsonValue(m_serverId); - result["UserPrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_userPrimaryImageTag); - result["SupportedCommands"] = Jellyfin::Support::toJsonValue>(m_supportedCommands); - + + result["PlayState"] = Jellyfin::Support::toJsonValue>(m_playState); + + if (!(m_additionalUsers.size() == 0)) { + result["AdditionalUsers"] = Jellyfin::Support::toJsonValue>(m_additionalUsers); + } + + result["Capabilities"] = Jellyfin::Support::toJsonValue>(m_capabilities); + + if (!(m_remoteEndPoint.isNull())) { + result["RemoteEndPoint"] = Jellyfin::Support::toJsonValue(m_remoteEndPoint); + } + + + if (!(m_playableMediaTypes.size() == 0)) { + result["PlayableMediaTypes"] = Jellyfin::Support::toJsonValue(m_playableMediaTypes); + } + + + if (!(m_jellyfinId.isNull())) { + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + } + + result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); + + if (!(m_userName.isNull())) { + result["UserName"] = Jellyfin::Support::toJsonValue(m_userName); + } + + + if (!(m_client.isNull())) { + result["Client"] = Jellyfin::Support::toJsonValue(m_client); + } + + result["LastActivityDate"] = Jellyfin::Support::toJsonValue(m_lastActivityDate); + result["LastPlaybackCheckIn"] = Jellyfin::Support::toJsonValue(m_lastPlaybackCheckIn); + + if (!(m_deviceName.isNull())) { + result["DeviceName"] = Jellyfin::Support::toJsonValue(m_deviceName); + } + + + if (!(m_deviceType.isNull())) { + result["DeviceType"] = Jellyfin::Support::toJsonValue(m_deviceType); + } + + result["NowPlayingItem"] = Jellyfin::Support::toJsonValue>(m_nowPlayingItem); + result["FullNowPlayingItem"] = Jellyfin::Support::toJsonValue>(m_fullNowPlayingItem); + result["NowViewingItem"] = Jellyfin::Support::toJsonValue>(m_nowViewingItem); + + if (!(m_deviceId.isNull())) { + result["DeviceId"] = Jellyfin::Support::toJsonValue(m_deviceId); + } + + + if (!(m_applicationVersion.isNull())) { + result["ApplicationVersion"] = Jellyfin::Support::toJsonValue(m_applicationVersion); + } + + result["TranscodingInfo"] = Jellyfin::Support::toJsonValue>(m_transcodingInfo); + result["IsActive"] = Jellyfin::Support::toJsonValue(m_isActive); + result["SupportsMediaControl"] = Jellyfin::Support::toJsonValue(m_supportsMediaControl); + result["SupportsRemoteControl"] = Jellyfin::Support::toJsonValue(m_supportsRemoteControl); + + if (!(m_nowPlayingQueue.size() == 0)) { + result["NowPlayingQueue"] = Jellyfin::Support::toJsonValue>(m_nowPlayingQueue); + } + + result["HasCustomDeviceName"] = Jellyfin::Support::toJsonValue(m_hasCustomDeviceName); + + if (!(m_playlistItemId.isNull())) { + result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); + } + + + if (!(m_serverId.isNull())) { + result["ServerId"] = Jellyfin::Support::toJsonValue(m_serverId); + } + + + if (!(m_userPrimaryImageTag.isNull())) { + result["UserPrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_userPrimaryImageTag); + } + + + if (!(m_supportedCommands.size() == 0)) { + result["SupportedCommands"] = Jellyfin::Support::toJsonValue>(m_supportedCommands); + } + return result; } diff --git a/core/src/dto/sessionuserinfo.cpp b/core/src/dto/sessionuserinfo.cpp index 12c98c5..6662a00 100644 --- a/core/src/dto/sessionuserinfo.cpp +++ b/core/src/dto/sessionuserinfo.cpp @@ -60,9 +60,13 @@ void SessionUserInfo::setFromJson(QJsonObject source) { QJsonObject SessionUserInfo::toJson() const { QJsonObject result; - result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); - result["UserName"] = Jellyfin::Support::toJsonValue(m_userName); - + + result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); + + if (!(m_userName.isNull())) { + result["UserName"] = Jellyfin::Support::toJsonValue(m_userName); + } + return result; } diff --git a/core/src/dto/setchannelmappingdto.cpp b/core/src/dto/setchannelmappingdto.cpp index 5ca369c..bbde21a 100644 --- a/core/src/dto/setchannelmappingdto.cpp +++ b/core/src/dto/setchannelmappingdto.cpp @@ -63,10 +63,10 @@ void SetChannelMappingDto::setFromJson(QJsonObject source) { QJsonObject SetChannelMappingDto::toJson() const { QJsonObject result; - result["ProviderId"] = Jellyfin::Support::toJsonValue(m_providerId); - result["TunerChannelId"] = Jellyfin::Support::toJsonValue(m_tunerChannelId); - result["ProviderChannelId"] = Jellyfin::Support::toJsonValue(m_providerChannelId); - + + result["ProviderId"] = Jellyfin::Support::toJsonValue(m_providerId); + result["TunerChannelId"] = Jellyfin::Support::toJsonValue(m_tunerChannelId); + result["ProviderChannelId"] = Jellyfin::Support::toJsonValue(m_providerChannelId); return result; } diff --git a/core/src/dto/setplaylistitemrequestdto.cpp b/core/src/dto/setplaylistitemrequestdto.cpp index 485860c..0ea9382 100644 --- a/core/src/dto/setplaylistitemrequestdto.cpp +++ b/core/src/dto/setplaylistitemrequestdto.cpp @@ -57,8 +57,8 @@ void SetPlaylistItemRequestDto::setFromJson(QJsonObject source) { QJsonObject SetPlaylistItemRequestDto::toJson() const { QJsonObject result; - result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); - + + result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); return result; } diff --git a/core/src/dto/setrepeatmoderequestdto.cpp b/core/src/dto/setrepeatmoderequestdto.cpp index 4a948b2..2151f92 100644 --- a/core/src/dto/setrepeatmoderequestdto.cpp +++ b/core/src/dto/setrepeatmoderequestdto.cpp @@ -57,8 +57,8 @@ void SetRepeatModeRequestDto::setFromJson(QJsonObject source) { QJsonObject SetRepeatModeRequestDto::toJson() const { QJsonObject result; - result["Mode"] = Jellyfin::Support::toJsonValue(m_mode); - + + result["Mode"] = Jellyfin::Support::toJsonValue(m_mode); return result; } diff --git a/core/src/dto/setshufflemoderequestdto.cpp b/core/src/dto/setshufflemoderequestdto.cpp index 735c6ae..494cfdb 100644 --- a/core/src/dto/setshufflemoderequestdto.cpp +++ b/core/src/dto/setshufflemoderequestdto.cpp @@ -57,8 +57,8 @@ void SetShuffleModeRequestDto::setFromJson(QJsonObject source) { QJsonObject SetShuffleModeRequestDto::toJson() const { QJsonObject result; - result["Mode"] = Jellyfin::Support::toJsonValue(m_mode); - + + result["Mode"] = Jellyfin::Support::toJsonValue(m_mode); return result; } diff --git a/core/src/dto/songinfo.cpp b/core/src/dto/songinfo.cpp index 05658b8..008ef39 100644 --- a/core/src/dto/songinfo.cpp +++ b/core/src/dto/songinfo.cpp @@ -93,20 +93,68 @@ void SongInfo::setFromJson(QJsonObject source) { QJsonObject SongInfo::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Path"] = Jellyfin::Support::toJsonValue(m_path); - result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); - result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); - result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); - result["Year"] = Jellyfin::Support::toJsonValue>(m_year); - result["IndexNumber"] = Jellyfin::Support::toJsonValue>(m_indexNumber); - result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue>(m_parentIndexNumber); - result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); - result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); - result["AlbumArtists"] = Jellyfin::Support::toJsonValue(m_albumArtists); - result["Album"] = Jellyfin::Support::toJsonValue(m_album); - result["Artists"] = Jellyfin::Support::toJsonValue(m_artists); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_path.isNull())) { + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + } + + + if (!(m_metadataLanguage.isNull())) { + result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); + } + + + if (!(m_metadataCountryCode.isNull())) { + result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); + } + + + if (!(m_providerIds.isEmpty())) { + result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); + } + + + if (!(!m_year.has_value())) { + result["Year"] = Jellyfin::Support::toJsonValue>(m_year); + } + + + if (!(!m_indexNumber.has_value())) { + result["IndexNumber"] = Jellyfin::Support::toJsonValue>(m_indexNumber); + } + + + if (!(!m_parentIndexNumber.has_value())) { + result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue>(m_parentIndexNumber); + } + + + if (!(m_premiereDate.isNull())) { + result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); + } + + result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); + + if (!(m_albumArtists.size() == 0)) { + result["AlbumArtists"] = Jellyfin::Support::toJsonValue(m_albumArtists); + } + + + if (!(m_album.isNull())) { + result["Album"] = Jellyfin::Support::toJsonValue(m_album); + } + + + if (!(m_artists.size() == 0)) { + result["Artists"] = Jellyfin::Support::toJsonValue(m_artists); + } + return result; } diff --git a/core/src/dto/specialviewoptiondto.cpp b/core/src/dto/specialviewoptiondto.cpp index d3d61b6..2aa250c 100644 --- a/core/src/dto/specialviewoptiondto.cpp +++ b/core/src/dto/specialviewoptiondto.cpp @@ -60,9 +60,17 @@ void SpecialViewOptionDto::setFromJson(QJsonObject source) { QJsonObject SpecialViewOptionDto::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_jellyfinId.isNull())) { + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + } + return result; } diff --git a/core/src/dto/startupconfigurationdto.cpp b/core/src/dto/startupconfigurationdto.cpp index 806d88e..1508460 100644 --- a/core/src/dto/startupconfigurationdto.cpp +++ b/core/src/dto/startupconfigurationdto.cpp @@ -63,10 +63,22 @@ void StartupConfigurationDto::setFromJson(QJsonObject source) { QJsonObject StartupConfigurationDto::toJson() const { QJsonObject result; - result["UICulture"] = Jellyfin::Support::toJsonValue(m_uICulture); - result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); - result["PreferredMetadataLanguage"] = Jellyfin::Support::toJsonValue(m_preferredMetadataLanguage); - + + + if (!(m_uICulture.isNull())) { + result["UICulture"] = Jellyfin::Support::toJsonValue(m_uICulture); + } + + + if (!(m_metadataCountryCode.isNull())) { + result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); + } + + + if (!(m_preferredMetadataLanguage.isNull())) { + result["PreferredMetadataLanguage"] = Jellyfin::Support::toJsonValue(m_preferredMetadataLanguage); + } + return result; } diff --git a/core/src/dto/startupremoteaccessdto.cpp b/core/src/dto/startupremoteaccessdto.cpp index 1da3bd9..4c95a5b 100644 --- a/core/src/dto/startupremoteaccessdto.cpp +++ b/core/src/dto/startupremoteaccessdto.cpp @@ -60,9 +60,9 @@ void StartupRemoteAccessDto::setFromJson(QJsonObject source) { QJsonObject StartupRemoteAccessDto::toJson() const { QJsonObject result; - result["EnableRemoteAccess"] = Jellyfin::Support::toJsonValue(m_enableRemoteAccess); - result["EnableAutomaticPortMapping"] = Jellyfin::Support::toJsonValue(m_enableAutomaticPortMapping); - + + result["EnableRemoteAccess"] = Jellyfin::Support::toJsonValue(m_enableRemoteAccess); + result["EnableAutomaticPortMapping"] = Jellyfin::Support::toJsonValue(m_enableAutomaticPortMapping); return result; } diff --git a/core/src/dto/startupuserdto.cpp b/core/src/dto/startupuserdto.cpp index 5ca8b29..9beb4bc 100644 --- a/core/src/dto/startupuserdto.cpp +++ b/core/src/dto/startupuserdto.cpp @@ -60,9 +60,17 @@ void StartupUserDto::setFromJson(QJsonObject source) { QJsonObject StartupUserDto::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Password"] = Jellyfin::Support::toJsonValue(m_password); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_password.isNull())) { + result["Password"] = Jellyfin::Support::toJsonValue(m_password); + } + return result; } diff --git a/core/src/dto/subtitleprofile.cpp b/core/src/dto/subtitleprofile.cpp index 40b5de5..f28085d 100644 --- a/core/src/dto/subtitleprofile.cpp +++ b/core/src/dto/subtitleprofile.cpp @@ -69,12 +69,28 @@ void SubtitleProfile::setFromJson(QJsonObject source) { QJsonObject SubtitleProfile::toJson() const { QJsonObject result; - result["Format"] = Jellyfin::Support::toJsonValue(m_format); - result["Method"] = Jellyfin::Support::toJsonValue(m_method); - result["DidlMode"] = Jellyfin::Support::toJsonValue(m_didlMode); - result["Language"] = Jellyfin::Support::toJsonValue(m_language); - result["Container"] = Jellyfin::Support::toJsonValue(m_container); - + + + if (!(m_format.isNull())) { + result["Format"] = Jellyfin::Support::toJsonValue(m_format); + } + + result["Method"] = Jellyfin::Support::toJsonValue(m_method); + + if (!(m_didlMode.isNull())) { + result["DidlMode"] = Jellyfin::Support::toJsonValue(m_didlMode); + } + + + if (!(m_language.isNull())) { + result["Language"] = Jellyfin::Support::toJsonValue(m_language); + } + + + if (!(m_container.isNull())) { + result["Container"] = Jellyfin::Support::toJsonValue(m_container); + } + return result; } diff --git a/core/src/dto/systeminfo.cpp b/core/src/dto/systeminfo.cpp index da2bbff..b3d1b9b 100644 --- a/core/src/dto/systeminfo.cpp +++ b/core/src/dto/systeminfo.cpp @@ -132,33 +132,101 @@ void SystemInfo::setFromJson(QJsonObject source) { QJsonObject SystemInfo::toJson() const { QJsonObject result; - result["LocalAddress"] = Jellyfin::Support::toJsonValue(m_localAddress); - result["ServerName"] = Jellyfin::Support::toJsonValue(m_serverName); - result["Version"] = Jellyfin::Support::toJsonValue(m_version); - result["ProductName"] = Jellyfin::Support::toJsonValue(m_productName); - result["OperatingSystem"] = Jellyfin::Support::toJsonValue(m_operatingSystem); - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["StartupWizardCompleted"] = Jellyfin::Support::toJsonValue>(m_startupWizardCompleted); - result["OperatingSystemDisplayName"] = Jellyfin::Support::toJsonValue(m_operatingSystemDisplayName); - result["PackageName"] = Jellyfin::Support::toJsonValue(m_packageName); - result["HasPendingRestart"] = Jellyfin::Support::toJsonValue(m_hasPendingRestart); - result["IsShuttingDown"] = Jellyfin::Support::toJsonValue(m_isShuttingDown); - result["SupportsLibraryMonitor"] = Jellyfin::Support::toJsonValue(m_supportsLibraryMonitor); - result["WebSocketPortNumber"] = Jellyfin::Support::toJsonValue(m_webSocketPortNumber); - result["CompletedInstallations"] = Jellyfin::Support::toJsonValue>(m_completedInstallations); - result["CanSelfRestart"] = Jellyfin::Support::toJsonValue(m_canSelfRestart); - result["CanLaunchWebBrowser"] = Jellyfin::Support::toJsonValue(m_canLaunchWebBrowser); - result["ProgramDataPath"] = Jellyfin::Support::toJsonValue(m_programDataPath); - result["WebPath"] = Jellyfin::Support::toJsonValue(m_webPath); - result["ItemsByNamePath"] = Jellyfin::Support::toJsonValue(m_itemsByNamePath); - result["CachePath"] = Jellyfin::Support::toJsonValue(m_cachePath); - result["LogPath"] = Jellyfin::Support::toJsonValue(m_logPath); - result["InternalMetadataPath"] = Jellyfin::Support::toJsonValue(m_internalMetadataPath); - result["TranscodingTempPath"] = Jellyfin::Support::toJsonValue(m_transcodingTempPath); - result["HasUpdateAvailable"] = Jellyfin::Support::toJsonValue(m_hasUpdateAvailable); - result["EncoderLocation"] = Jellyfin::Support::toJsonValue(m_encoderLocation); - result["SystemArchitecture"] = Jellyfin::Support::toJsonValue(m_systemArchitecture); - + + + if (!(m_localAddress.isNull())) { + result["LocalAddress"] = Jellyfin::Support::toJsonValue(m_localAddress); + } + + + if (!(m_serverName.isNull())) { + result["ServerName"] = Jellyfin::Support::toJsonValue(m_serverName); + } + + + if (!(m_version.isNull())) { + result["Version"] = Jellyfin::Support::toJsonValue(m_version); + } + + + if (!(m_productName.isNull())) { + result["ProductName"] = Jellyfin::Support::toJsonValue(m_productName); + } + + + if (!(m_operatingSystem.isNull())) { + result["OperatingSystem"] = Jellyfin::Support::toJsonValue(m_operatingSystem); + } + + + if (!(m_jellyfinId.isNull())) { + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + } + + + if (!(!m_startupWizardCompleted.has_value())) { + result["StartupWizardCompleted"] = Jellyfin::Support::toJsonValue>(m_startupWizardCompleted); + } + + + if (!(m_operatingSystemDisplayName.isNull())) { + result["OperatingSystemDisplayName"] = Jellyfin::Support::toJsonValue(m_operatingSystemDisplayName); + } + + + if (!(m_packageName.isNull())) { + result["PackageName"] = Jellyfin::Support::toJsonValue(m_packageName); + } + + result["HasPendingRestart"] = Jellyfin::Support::toJsonValue(m_hasPendingRestart); + result["IsShuttingDown"] = Jellyfin::Support::toJsonValue(m_isShuttingDown); + result["SupportsLibraryMonitor"] = Jellyfin::Support::toJsonValue(m_supportsLibraryMonitor); + result["WebSocketPortNumber"] = Jellyfin::Support::toJsonValue(m_webSocketPortNumber); + + if (!(m_completedInstallations.size() == 0)) { + result["CompletedInstallations"] = Jellyfin::Support::toJsonValue>(m_completedInstallations); + } + + result["CanSelfRestart"] = Jellyfin::Support::toJsonValue(m_canSelfRestart); + result["CanLaunchWebBrowser"] = Jellyfin::Support::toJsonValue(m_canLaunchWebBrowser); + + if (!(m_programDataPath.isNull())) { + result["ProgramDataPath"] = Jellyfin::Support::toJsonValue(m_programDataPath); + } + + + if (!(m_webPath.isNull())) { + result["WebPath"] = Jellyfin::Support::toJsonValue(m_webPath); + } + + + if (!(m_itemsByNamePath.isNull())) { + result["ItemsByNamePath"] = Jellyfin::Support::toJsonValue(m_itemsByNamePath); + } + + + if (!(m_cachePath.isNull())) { + result["CachePath"] = Jellyfin::Support::toJsonValue(m_cachePath); + } + + + if (!(m_logPath.isNull())) { + result["LogPath"] = Jellyfin::Support::toJsonValue(m_logPath); + } + + + if (!(m_internalMetadataPath.isNull())) { + result["InternalMetadataPath"] = Jellyfin::Support::toJsonValue(m_internalMetadataPath); + } + + + if (!(m_transcodingTempPath.isNull())) { + result["TranscodingTempPath"] = Jellyfin::Support::toJsonValue(m_transcodingTempPath); + } + + result["HasUpdateAvailable"] = Jellyfin::Support::toJsonValue(m_hasUpdateAvailable); + result["EncoderLocation"] = Jellyfin::Support::toJsonValue(m_encoderLocation); + result["SystemArchitecture"] = Jellyfin::Support::toJsonValue(m_systemArchitecture); return result; } diff --git a/core/src/dto/taskinfo.cpp b/core/src/dto/taskinfo.cpp index 0cc41ed..1126d60 100644 --- a/core/src/dto/taskinfo.cpp +++ b/core/src/dto/taskinfo.cpp @@ -84,17 +84,45 @@ void TaskInfo::setFromJson(QJsonObject source) { QJsonObject TaskInfo::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["State"] = Jellyfin::Support::toJsonValue(m_state); - result["CurrentProgressPercentage"] = Jellyfin::Support::toJsonValue>(m_currentProgressPercentage); - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["LastExecutionResult"] = Jellyfin::Support::toJsonValue>(m_lastExecutionResult); - result["Triggers"] = Jellyfin::Support::toJsonValue>(m_triggers); - result["Description"] = Jellyfin::Support::toJsonValue(m_description); - result["Category"] = Jellyfin::Support::toJsonValue(m_category); - result["IsHidden"] = Jellyfin::Support::toJsonValue(m_isHidden); - result["Key"] = Jellyfin::Support::toJsonValue(m_key); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + result["State"] = Jellyfin::Support::toJsonValue(m_state); + + if (!(!m_currentProgressPercentage.has_value())) { + result["CurrentProgressPercentage"] = Jellyfin::Support::toJsonValue>(m_currentProgressPercentage); + } + + + if (!(m_jellyfinId.isNull())) { + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + } + + result["LastExecutionResult"] = Jellyfin::Support::toJsonValue>(m_lastExecutionResult); + + if (!(m_triggers.size() == 0)) { + result["Triggers"] = Jellyfin::Support::toJsonValue>(m_triggers); + } + + + if (!(m_description.isNull())) { + result["Description"] = Jellyfin::Support::toJsonValue(m_description); + } + + + if (!(m_category.isNull())) { + result["Category"] = Jellyfin::Support::toJsonValue(m_category); + } + + result["IsHidden"] = Jellyfin::Support::toJsonValue(m_isHidden); + + if (!(m_key.isNull())) { + result["Key"] = Jellyfin::Support::toJsonValue(m_key); + } + return result; } diff --git a/core/src/dto/taskresult.cpp b/core/src/dto/taskresult.cpp index a8aef7a..613564b 100644 --- a/core/src/dto/taskresult.cpp +++ b/core/src/dto/taskresult.cpp @@ -78,15 +78,35 @@ void TaskResult::setFromJson(QJsonObject source) { QJsonObject TaskResult::toJson() const { QJsonObject result; - result["StartTimeUtc"] = Jellyfin::Support::toJsonValue(m_startTimeUtc); - result["EndTimeUtc"] = Jellyfin::Support::toJsonValue(m_endTimeUtc); - result["Status"] = Jellyfin::Support::toJsonValue(m_status); - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Key"] = Jellyfin::Support::toJsonValue(m_key); - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["ErrorMessage"] = Jellyfin::Support::toJsonValue(m_errorMessage); - result["LongErrorMessage"] = Jellyfin::Support::toJsonValue(m_longErrorMessage); - + + result["StartTimeUtc"] = Jellyfin::Support::toJsonValue(m_startTimeUtc); + result["EndTimeUtc"] = Jellyfin::Support::toJsonValue(m_endTimeUtc); + result["Status"] = Jellyfin::Support::toJsonValue(m_status); + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_key.isNull())) { + result["Key"] = Jellyfin::Support::toJsonValue(m_key); + } + + + if (!(m_jellyfinId.isNull())) { + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + } + + + if (!(m_errorMessage.isNull())) { + result["ErrorMessage"] = Jellyfin::Support::toJsonValue(m_errorMessage); + } + + + if (!(m_longErrorMessage.isNull())) { + result["LongErrorMessage"] = Jellyfin::Support::toJsonValue(m_longErrorMessage); + } + return result; } diff --git a/core/src/dto/tasktriggerinfo.cpp b/core/src/dto/tasktriggerinfo.cpp index bbdac76..17c9da5 100644 --- a/core/src/dto/tasktriggerinfo.cpp +++ b/core/src/dto/tasktriggerinfo.cpp @@ -69,12 +69,28 @@ void TaskTriggerInfo::setFromJson(QJsonObject source) { QJsonObject TaskTriggerInfo::toJson() const { QJsonObject result; - result["Type"] = Jellyfin::Support::toJsonValue(m_type); - result["TimeOfDayTicks"] = Jellyfin::Support::toJsonValue>(m_timeOfDayTicks); - result["IntervalTicks"] = Jellyfin::Support::toJsonValue>(m_intervalTicks); - result["DayOfWeek"] = Jellyfin::Support::toJsonValue(m_dayOfWeek); - result["MaxRuntimeTicks"] = Jellyfin::Support::toJsonValue>(m_maxRuntimeTicks); - + + + if (!(m_type.isNull())) { + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + } + + + if (!(!m_timeOfDayTicks.has_value())) { + result["TimeOfDayTicks"] = Jellyfin::Support::toJsonValue>(m_timeOfDayTicks); + } + + + if (!(!m_intervalTicks.has_value())) { + result["IntervalTicks"] = Jellyfin::Support::toJsonValue>(m_intervalTicks); + } + + result["DayOfWeek"] = Jellyfin::Support::toJsonValue(m_dayOfWeek); + + if (!(!m_maxRuntimeTicks.has_value())) { + result["MaxRuntimeTicks"] = Jellyfin::Support::toJsonValue>(m_maxRuntimeTicks); + } + return result; } diff --git a/core/src/dto/thememediaresult.cpp b/core/src/dto/thememediaresult.cpp index 274fc0a..65fb016 100644 --- a/core/src/dto/thememediaresult.cpp +++ b/core/src/dto/thememediaresult.cpp @@ -66,11 +66,15 @@ void ThemeMediaResult::setFromJson(QJsonObject source) { QJsonObject ThemeMediaResult::toJson() const { QJsonObject result; - result["Items"] = Jellyfin::Support::toJsonValue>(m_items); - result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); - result["StartIndex"] = Jellyfin::Support::toJsonValue(m_startIndex); - result["OwnerId"] = Jellyfin::Support::toJsonValue(m_ownerId); - + + + if (!(m_items.size() == 0)) { + result["Items"] = Jellyfin::Support::toJsonValue>(m_items); + } + + result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); + result["StartIndex"] = Jellyfin::Support::toJsonValue(m_startIndex); + result["OwnerId"] = Jellyfin::Support::toJsonValue(m_ownerId); return result; } diff --git a/core/src/dto/timereventinfo.cpp b/core/src/dto/timereventinfo.cpp index b5ea60f..64bb1e1 100644 --- a/core/src/dto/timereventinfo.cpp +++ b/core/src/dto/timereventinfo.cpp @@ -60,9 +60,17 @@ void TimerEventInfo::setFromJson(QJsonObject source) { QJsonObject TimerEventInfo::toJson() const { QJsonObject result; - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["ProgramId"] = Jellyfin::Support::toJsonValue(m_programId); - + + + if (!(m_jellyfinId.isNull())) { + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + } + + + if (!(m_programId.isNull())) { + result["ProgramId"] = Jellyfin::Support::toJsonValue(m_programId); + } + return result; } diff --git a/core/src/dto/timerinfodto.cpp b/core/src/dto/timerinfodto.cpp index 796dce8..a78a04a 100644 --- a/core/src/dto/timerinfodto.cpp +++ b/core/src/dto/timerinfodto.cpp @@ -138,35 +138,103 @@ void TimerInfoDto::setFromJson(QJsonObject source) { QJsonObject TimerInfoDto::toJson() const { QJsonObject result; - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["Type"] = Jellyfin::Support::toJsonValue(m_type); - result["ServerId"] = Jellyfin::Support::toJsonValue(m_serverId); - result["ExternalId"] = Jellyfin::Support::toJsonValue(m_externalId); - result["ChannelId"] = Jellyfin::Support::toJsonValue(m_channelId); - result["ExternalChannelId"] = Jellyfin::Support::toJsonValue(m_externalChannelId); - result["ChannelName"] = Jellyfin::Support::toJsonValue(m_channelName); - result["ChannelPrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_channelPrimaryImageTag); - result["ProgramId"] = Jellyfin::Support::toJsonValue(m_programId); - result["ExternalProgramId"] = Jellyfin::Support::toJsonValue(m_externalProgramId); - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Overview"] = Jellyfin::Support::toJsonValue(m_overview); - result["StartDate"] = Jellyfin::Support::toJsonValue(m_startDate); - result["EndDate"] = Jellyfin::Support::toJsonValue(m_endDate); - result["ServiceName"] = Jellyfin::Support::toJsonValue(m_serviceName); - result["Priority"] = Jellyfin::Support::toJsonValue(m_priority); - result["PrePaddingSeconds"] = Jellyfin::Support::toJsonValue(m_prePaddingSeconds); - result["PostPaddingSeconds"] = Jellyfin::Support::toJsonValue(m_postPaddingSeconds); - result["IsPrePaddingRequired"] = Jellyfin::Support::toJsonValue(m_isPrePaddingRequired); - result["ParentBackdropItemId"] = Jellyfin::Support::toJsonValue(m_parentBackdropItemId); - result["ParentBackdropImageTags"] = Jellyfin::Support::toJsonValue(m_parentBackdropImageTags); - result["IsPostPaddingRequired"] = Jellyfin::Support::toJsonValue(m_isPostPaddingRequired); - result["KeepUntil"] = Jellyfin::Support::toJsonValue(m_keepUntil); - result["Status"] = Jellyfin::Support::toJsonValue(m_status); - result["SeriesTimerId"] = Jellyfin::Support::toJsonValue(m_seriesTimerId); - result["ExternalSeriesTimerId"] = Jellyfin::Support::toJsonValue(m_externalSeriesTimerId); - result["RunTimeTicks"] = Jellyfin::Support::toJsonValue>(m_runTimeTicks); - result["ProgramInfo"] = Jellyfin::Support::toJsonValue>(m_programInfo); - + + + if (!(m_jellyfinId.isNull())) { + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + } + + + if (!(m_type.isNull())) { + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + } + + + if (!(m_serverId.isNull())) { + result["ServerId"] = Jellyfin::Support::toJsonValue(m_serverId); + } + + + if (!(m_externalId.isNull())) { + result["ExternalId"] = Jellyfin::Support::toJsonValue(m_externalId); + } + + result["ChannelId"] = Jellyfin::Support::toJsonValue(m_channelId); + + if (!(m_externalChannelId.isNull())) { + result["ExternalChannelId"] = Jellyfin::Support::toJsonValue(m_externalChannelId); + } + + + if (!(m_channelName.isNull())) { + result["ChannelName"] = Jellyfin::Support::toJsonValue(m_channelName); + } + + + if (!(m_channelPrimaryImageTag.isNull())) { + result["ChannelPrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_channelPrimaryImageTag); + } + + + if (!(m_programId.isNull())) { + result["ProgramId"] = Jellyfin::Support::toJsonValue(m_programId); + } + + + if (!(m_externalProgramId.isNull())) { + result["ExternalProgramId"] = Jellyfin::Support::toJsonValue(m_externalProgramId); + } + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_overview.isNull())) { + result["Overview"] = Jellyfin::Support::toJsonValue(m_overview); + } + + result["StartDate"] = Jellyfin::Support::toJsonValue(m_startDate); + result["EndDate"] = Jellyfin::Support::toJsonValue(m_endDate); + + if (!(m_serviceName.isNull())) { + result["ServiceName"] = Jellyfin::Support::toJsonValue(m_serviceName); + } + + result["Priority"] = Jellyfin::Support::toJsonValue(m_priority); + result["PrePaddingSeconds"] = Jellyfin::Support::toJsonValue(m_prePaddingSeconds); + result["PostPaddingSeconds"] = Jellyfin::Support::toJsonValue(m_postPaddingSeconds); + result["IsPrePaddingRequired"] = Jellyfin::Support::toJsonValue(m_isPrePaddingRequired); + + if (!(m_parentBackdropItemId.isNull())) { + result["ParentBackdropItemId"] = Jellyfin::Support::toJsonValue(m_parentBackdropItemId); + } + + + if (!(m_parentBackdropImageTags.size() == 0)) { + result["ParentBackdropImageTags"] = Jellyfin::Support::toJsonValue(m_parentBackdropImageTags); + } + + result["IsPostPaddingRequired"] = Jellyfin::Support::toJsonValue(m_isPostPaddingRequired); + result["KeepUntil"] = Jellyfin::Support::toJsonValue(m_keepUntil); + result["Status"] = Jellyfin::Support::toJsonValue(m_status); + + if (!(m_seriesTimerId.isNull())) { + result["SeriesTimerId"] = Jellyfin::Support::toJsonValue(m_seriesTimerId); + } + + + if (!(m_externalSeriesTimerId.isNull())) { + result["ExternalSeriesTimerId"] = Jellyfin::Support::toJsonValue(m_externalSeriesTimerId); + } + + + if (!(!m_runTimeTicks.has_value())) { + result["RunTimeTicks"] = Jellyfin::Support::toJsonValue>(m_runTimeTicks); + } + + result["ProgramInfo"] = Jellyfin::Support::toJsonValue>(m_programInfo); return result; } diff --git a/core/src/dto/timerinfodtoqueryresult.cpp b/core/src/dto/timerinfodtoqueryresult.cpp index 374ffeb..e034e0b 100644 --- a/core/src/dto/timerinfodtoqueryresult.cpp +++ b/core/src/dto/timerinfodtoqueryresult.cpp @@ -63,10 +63,14 @@ void TimerInfoDtoQueryResult::setFromJson(QJsonObject source) { QJsonObject TimerInfoDtoQueryResult::toJson() const { QJsonObject result; - result["Items"] = Jellyfin::Support::toJsonValue>(m_items); - result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); - result["StartIndex"] = Jellyfin::Support::toJsonValue(m_startIndex); - + + + if (!(m_items.size() == 0)) { + result["Items"] = Jellyfin::Support::toJsonValue>(m_items); + } + + result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); + result["StartIndex"] = Jellyfin::Support::toJsonValue(m_startIndex); return result; } diff --git a/core/src/dto/trailerinfo.cpp b/core/src/dto/trailerinfo.cpp index 5dc7b34..ce1b412 100644 --- a/core/src/dto/trailerinfo.cpp +++ b/core/src/dto/trailerinfo.cpp @@ -84,17 +84,53 @@ void TrailerInfo::setFromJson(QJsonObject source) { QJsonObject TrailerInfo::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Path"] = Jellyfin::Support::toJsonValue(m_path); - result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); - result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); - result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); - result["Year"] = Jellyfin::Support::toJsonValue>(m_year); - result["IndexNumber"] = Jellyfin::Support::toJsonValue>(m_indexNumber); - result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue>(m_parentIndexNumber); - result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); - result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_path.isNull())) { + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + } + + + if (!(m_metadataLanguage.isNull())) { + result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); + } + + + if (!(m_metadataCountryCode.isNull())) { + result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); + } + + + if (!(m_providerIds.isEmpty())) { + result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); + } + + + if (!(!m_year.has_value())) { + result["Year"] = Jellyfin::Support::toJsonValue>(m_year); + } + + + if (!(!m_indexNumber.has_value())) { + result["IndexNumber"] = Jellyfin::Support::toJsonValue>(m_indexNumber); + } + + + if (!(!m_parentIndexNumber.has_value())) { + result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue>(m_parentIndexNumber); + } + + + if (!(m_premiereDate.isNull())) { + result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); + } + + result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); return result; } diff --git a/core/src/dto/trailerinforemotesearchquery.cpp b/core/src/dto/trailerinforemotesearchquery.cpp index aabbaa8..92a19de 100644 --- a/core/src/dto/trailerinforemotesearchquery.cpp +++ b/core/src/dto/trailerinforemotesearchquery.cpp @@ -66,11 +66,15 @@ void TrailerInfoRemoteSearchQuery::setFromJson(QJsonObject source) { QJsonObject TrailerInfoRemoteSearchQuery::toJson() const { QJsonObject result; - result["SearchInfo"] = Jellyfin::Support::toJsonValue>(m_searchInfo); - result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); - result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); - result["IncludeDisabledProviders"] = Jellyfin::Support::toJsonValue(m_includeDisabledProviders); - + + result["SearchInfo"] = Jellyfin::Support::toJsonValue>(m_searchInfo); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + + if (!(m_searchProviderName.isNull())) { + result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); + } + + result["IncludeDisabledProviders"] = Jellyfin::Support::toJsonValue(m_includeDisabledProviders); return result; } diff --git a/core/src/dto/transcodinginfo.cpp b/core/src/dto/transcodinginfo.cpp index 016b8c7..d64ec4f 100644 --- a/core/src/dto/transcodinginfo.cpp +++ b/core/src/dto/transcodinginfo.cpp @@ -90,19 +90,59 @@ void TranscodingInfo::setFromJson(QJsonObject source) { QJsonObject TranscodingInfo::toJson() const { QJsonObject result; - result["AudioCodec"] = Jellyfin::Support::toJsonValue(m_audioCodec); - result["VideoCodec"] = Jellyfin::Support::toJsonValue(m_videoCodec); - result["Container"] = Jellyfin::Support::toJsonValue(m_container); - result["IsVideoDirect"] = Jellyfin::Support::toJsonValue(m_isVideoDirect); - result["IsAudioDirect"] = Jellyfin::Support::toJsonValue(m_isAudioDirect); - result["Bitrate"] = Jellyfin::Support::toJsonValue>(m_bitrate); - result["Framerate"] = Jellyfin::Support::toJsonValue>(m_framerate); - result["CompletionPercentage"] = Jellyfin::Support::toJsonValue>(m_completionPercentage); - result["Width"] = Jellyfin::Support::toJsonValue>(m_width); - result["Height"] = Jellyfin::Support::toJsonValue>(m_height); - result["AudioChannels"] = Jellyfin::Support::toJsonValue>(m_audioChannels); - result["TranscodeReasons"] = Jellyfin::Support::toJsonValue>(m_transcodeReasons); - + + + if (!(m_audioCodec.isNull())) { + result["AudioCodec"] = Jellyfin::Support::toJsonValue(m_audioCodec); + } + + + if (!(m_videoCodec.isNull())) { + result["VideoCodec"] = Jellyfin::Support::toJsonValue(m_videoCodec); + } + + + if (!(m_container.isNull())) { + result["Container"] = Jellyfin::Support::toJsonValue(m_container); + } + + result["IsVideoDirect"] = Jellyfin::Support::toJsonValue(m_isVideoDirect); + result["IsAudioDirect"] = Jellyfin::Support::toJsonValue(m_isAudioDirect); + + if (!(!m_bitrate.has_value())) { + result["Bitrate"] = Jellyfin::Support::toJsonValue>(m_bitrate); + } + + + if (!(!m_framerate.has_value())) { + result["Framerate"] = Jellyfin::Support::toJsonValue>(m_framerate); + } + + + if (!(!m_completionPercentage.has_value())) { + result["CompletionPercentage"] = Jellyfin::Support::toJsonValue>(m_completionPercentage); + } + + + if (!(!m_width.has_value())) { + result["Width"] = Jellyfin::Support::toJsonValue>(m_width); + } + + + if (!(!m_height.has_value())) { + result["Height"] = Jellyfin::Support::toJsonValue>(m_height); + } + + + if (!(!m_audioChannels.has_value())) { + result["AudioChannels"] = Jellyfin::Support::toJsonValue>(m_audioChannels); + } + + + if (!(m_transcodeReasons.size() == 0)) { + result["TranscodeReasons"] = Jellyfin::Support::toJsonValue>(m_transcodeReasons); + } + return result; } diff --git a/core/src/dto/transcodingprofile.cpp b/core/src/dto/transcodingprofile.cpp index 747503e..6780825 100644 --- a/core/src/dto/transcodingprofile.cpp +++ b/core/src/dto/transcodingprofile.cpp @@ -99,22 +99,42 @@ void TranscodingProfile::setFromJson(QJsonObject source) { QJsonObject TranscodingProfile::toJson() const { QJsonObject result; - result["Container"] = Jellyfin::Support::toJsonValue(m_container); - result["Type"] = Jellyfin::Support::toJsonValue(m_type); - result["VideoCodec"] = Jellyfin::Support::toJsonValue(m_videoCodec); - result["AudioCodec"] = Jellyfin::Support::toJsonValue(m_audioCodec); - result["Protocol"] = Jellyfin::Support::toJsonValue(m_protocol); - result["EstimateContentLength"] = Jellyfin::Support::toJsonValue(m_estimateContentLength); - result["EnableMpegtsM2TsMode"] = Jellyfin::Support::toJsonValue(m_enableMpegtsM2TsMode); - result["TranscodeSeekInfo"] = Jellyfin::Support::toJsonValue(m_transcodeSeekInfo); - result["CopyTimestamps"] = Jellyfin::Support::toJsonValue(m_copyTimestamps); - result["Context"] = Jellyfin::Support::toJsonValue(m_context); - result["EnableSubtitlesInManifest"] = Jellyfin::Support::toJsonValue(m_enableSubtitlesInManifest); - result["MaxAudioChannels"] = Jellyfin::Support::toJsonValue(m_maxAudioChannels); - result["MinSegments"] = Jellyfin::Support::toJsonValue(m_minSegments); - result["SegmentLength"] = Jellyfin::Support::toJsonValue(m_segmentLength); - result["BreakOnNonKeyFrames"] = Jellyfin::Support::toJsonValue(m_breakOnNonKeyFrames); - + + + if (!(m_container.isNull())) { + result["Container"] = Jellyfin::Support::toJsonValue(m_container); + } + + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + + if (!(m_videoCodec.isNull())) { + result["VideoCodec"] = Jellyfin::Support::toJsonValue(m_videoCodec); + } + + + if (!(m_audioCodec.isNull())) { + result["AudioCodec"] = Jellyfin::Support::toJsonValue(m_audioCodec); + } + + + if (!(m_protocol.isNull())) { + result["Protocol"] = Jellyfin::Support::toJsonValue(m_protocol); + } + + result["EstimateContentLength"] = Jellyfin::Support::toJsonValue(m_estimateContentLength); + result["EnableMpegtsM2TsMode"] = Jellyfin::Support::toJsonValue(m_enableMpegtsM2TsMode); + result["TranscodeSeekInfo"] = Jellyfin::Support::toJsonValue(m_transcodeSeekInfo); + result["CopyTimestamps"] = Jellyfin::Support::toJsonValue(m_copyTimestamps); + result["Context"] = Jellyfin::Support::toJsonValue(m_context); + result["EnableSubtitlesInManifest"] = Jellyfin::Support::toJsonValue(m_enableSubtitlesInManifest); + + if (!(m_maxAudioChannels.isNull())) { + result["MaxAudioChannels"] = Jellyfin::Support::toJsonValue(m_maxAudioChannels); + } + + result["MinSegments"] = Jellyfin::Support::toJsonValue(m_minSegments); + result["SegmentLength"] = Jellyfin::Support::toJsonValue(m_segmentLength); + result["BreakOnNonKeyFrames"] = Jellyfin::Support::toJsonValue(m_breakOnNonKeyFrames); return result; } diff --git a/core/src/dto/tunerchannelmapping.cpp b/core/src/dto/tunerchannelmapping.cpp index 47687fa..20d700d 100644 --- a/core/src/dto/tunerchannelmapping.cpp +++ b/core/src/dto/tunerchannelmapping.cpp @@ -66,11 +66,27 @@ void TunerChannelMapping::setFromJson(QJsonObject source) { QJsonObject TunerChannelMapping::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["ProviderChannelName"] = Jellyfin::Support::toJsonValue(m_providerChannelName); - result["ProviderChannelId"] = Jellyfin::Support::toJsonValue(m_providerChannelId); - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_providerChannelName.isNull())) { + result["ProviderChannelName"] = Jellyfin::Support::toJsonValue(m_providerChannelName); + } + + + if (!(m_providerChannelId.isNull())) { + result["ProviderChannelId"] = Jellyfin::Support::toJsonValue(m_providerChannelId); + } + + + if (!(m_jellyfinId.isNull())) { + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + } + return result; } diff --git a/core/src/dto/tunerhostinfo.cpp b/core/src/dto/tunerhostinfo.cpp index cc7706d..1dd037c 100644 --- a/core/src/dto/tunerhostinfo.cpp +++ b/core/src/dto/tunerhostinfo.cpp @@ -87,18 +87,46 @@ void TunerHostInfo::setFromJson(QJsonObject source) { QJsonObject TunerHostInfo::toJson() const { QJsonObject result; - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["Url"] = Jellyfin::Support::toJsonValue(m_url); - result["Type"] = Jellyfin::Support::toJsonValue(m_type); - result["DeviceId"] = Jellyfin::Support::toJsonValue(m_deviceId); - result["FriendlyName"] = Jellyfin::Support::toJsonValue(m_friendlyName); - result["ImportFavoritesOnly"] = Jellyfin::Support::toJsonValue(m_importFavoritesOnly); - result["AllowHWTranscoding"] = Jellyfin::Support::toJsonValue(m_allowHWTranscoding); - result["EnableStreamLooping"] = Jellyfin::Support::toJsonValue(m_enableStreamLooping); - result["Source"] = Jellyfin::Support::toJsonValue(m_source); - result["TunerCount"] = Jellyfin::Support::toJsonValue(m_tunerCount); - result["UserAgent"] = Jellyfin::Support::toJsonValue(m_userAgent); - + + + if (!(m_jellyfinId.isNull())) { + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + } + + + if (!(m_url.isNull())) { + result["Url"] = Jellyfin::Support::toJsonValue(m_url); + } + + + if (!(m_type.isNull())) { + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + } + + + if (!(m_deviceId.isNull())) { + result["DeviceId"] = Jellyfin::Support::toJsonValue(m_deviceId); + } + + + if (!(m_friendlyName.isNull())) { + result["FriendlyName"] = Jellyfin::Support::toJsonValue(m_friendlyName); + } + + result["ImportFavoritesOnly"] = Jellyfin::Support::toJsonValue(m_importFavoritesOnly); + result["AllowHWTranscoding"] = Jellyfin::Support::toJsonValue(m_allowHWTranscoding); + result["EnableStreamLooping"] = Jellyfin::Support::toJsonValue(m_enableStreamLooping); + + if (!(m_source.isNull())) { + result["Source"] = Jellyfin::Support::toJsonValue(m_source); + } + + result["TunerCount"] = Jellyfin::Support::toJsonValue(m_tunerCount); + + if (!(m_userAgent.isNull())) { + result["UserAgent"] = Jellyfin::Support::toJsonValue(m_userAgent); + } + return result; } diff --git a/core/src/dto/typeoptions.cpp b/core/src/dto/typeoptions.cpp index d29e37d..e041cb3 100644 --- a/core/src/dto/typeoptions.cpp +++ b/core/src/dto/typeoptions.cpp @@ -72,13 +72,37 @@ void TypeOptions::setFromJson(QJsonObject source) { QJsonObject TypeOptions::toJson() const { QJsonObject result; - result["Type"] = Jellyfin::Support::toJsonValue(m_type); - result["MetadataFetchers"] = Jellyfin::Support::toJsonValue(m_metadataFetchers); - result["MetadataFetcherOrder"] = Jellyfin::Support::toJsonValue(m_metadataFetcherOrder); - result["ImageFetchers"] = Jellyfin::Support::toJsonValue(m_imageFetchers); - result["ImageFetcherOrder"] = Jellyfin::Support::toJsonValue(m_imageFetcherOrder); - result["ImageOptions"] = Jellyfin::Support::toJsonValue>(m_imageOptions); - + + + if (!(m_type.isNull())) { + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + } + + + if (!(m_metadataFetchers.size() == 0)) { + result["MetadataFetchers"] = Jellyfin::Support::toJsonValue(m_metadataFetchers); + } + + + if (!(m_metadataFetcherOrder.size() == 0)) { + result["MetadataFetcherOrder"] = Jellyfin::Support::toJsonValue(m_metadataFetcherOrder); + } + + + if (!(m_imageFetchers.size() == 0)) { + result["ImageFetchers"] = Jellyfin::Support::toJsonValue(m_imageFetchers); + } + + + if (!(m_imageFetcherOrder.size() == 0)) { + result["ImageFetcherOrder"] = Jellyfin::Support::toJsonValue(m_imageFetcherOrder); + } + + + if (!(m_imageOptions.size() == 0)) { + result["ImageOptions"] = Jellyfin::Support::toJsonValue>(m_imageOptions); + } + return result; } diff --git a/core/src/dto/updatelibraryoptionsdto.cpp b/core/src/dto/updatelibraryoptionsdto.cpp index ed1d049..02a0ea7 100644 --- a/core/src/dto/updatelibraryoptionsdto.cpp +++ b/core/src/dto/updatelibraryoptionsdto.cpp @@ -60,9 +60,9 @@ void UpdateLibraryOptionsDto::setFromJson(QJsonObject source) { QJsonObject UpdateLibraryOptionsDto::toJson() const { QJsonObject result; - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["LibraryOptions"] = Jellyfin::Support::toJsonValue>(m_libraryOptions); - + + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["LibraryOptions"] = Jellyfin::Support::toJsonValue>(m_libraryOptions); return result; } diff --git a/core/src/dto/updateusereasypassword.cpp b/core/src/dto/updateusereasypassword.cpp index 2a95cd9..d711429 100644 --- a/core/src/dto/updateusereasypassword.cpp +++ b/core/src/dto/updateusereasypassword.cpp @@ -63,10 +63,18 @@ void UpdateUserEasyPassword::setFromJson(QJsonObject source) { QJsonObject UpdateUserEasyPassword::toJson() const { QJsonObject result; - result["NewPassword"] = Jellyfin::Support::toJsonValue(m_newPassword); - result["NewPw"] = Jellyfin::Support::toJsonValue(m_newPw); - result["ResetPassword"] = Jellyfin::Support::toJsonValue(m_resetPassword); - + + + if (!(m_newPassword.isNull())) { + result["NewPassword"] = Jellyfin::Support::toJsonValue(m_newPassword); + } + + + if (!(m_newPw.isNull())) { + result["NewPw"] = Jellyfin::Support::toJsonValue(m_newPw); + } + + result["ResetPassword"] = Jellyfin::Support::toJsonValue(m_resetPassword); return result; } diff --git a/core/src/dto/updateuserpassword.cpp b/core/src/dto/updateuserpassword.cpp index 010c539..f7287ef 100644 --- a/core/src/dto/updateuserpassword.cpp +++ b/core/src/dto/updateuserpassword.cpp @@ -66,11 +66,23 @@ void UpdateUserPassword::setFromJson(QJsonObject source) { QJsonObject UpdateUserPassword::toJson() const { QJsonObject result; - result["CurrentPassword"] = Jellyfin::Support::toJsonValue(m_currentPassword); - result["CurrentPw"] = Jellyfin::Support::toJsonValue(m_currentPw); - result["NewPw"] = Jellyfin::Support::toJsonValue(m_newPw); - result["ResetPassword"] = Jellyfin::Support::toJsonValue(m_resetPassword); - + + + if (!(m_currentPassword.isNull())) { + result["CurrentPassword"] = Jellyfin::Support::toJsonValue(m_currentPassword); + } + + + if (!(m_currentPw.isNull())) { + result["CurrentPw"] = Jellyfin::Support::toJsonValue(m_currentPw); + } + + + if (!(m_newPw.isNull())) { + result["NewPw"] = Jellyfin::Support::toJsonValue(m_newPw); + } + + result["ResetPassword"] = Jellyfin::Support::toJsonValue(m_resetPassword); return result; } diff --git a/core/src/dto/uploadsubtitledto.cpp b/core/src/dto/uploadsubtitledto.cpp index 2a2e166..d1a722d 100644 --- a/core/src/dto/uploadsubtitledto.cpp +++ b/core/src/dto/uploadsubtitledto.cpp @@ -66,11 +66,11 @@ void UploadSubtitleDto::setFromJson(QJsonObject source) { QJsonObject UploadSubtitleDto::toJson() const { QJsonObject result; - result["Language"] = Jellyfin::Support::toJsonValue(m_language); - result["Format"] = Jellyfin::Support::toJsonValue(m_format); - result["IsForced"] = Jellyfin::Support::toJsonValue(m_isForced); - result["Data"] = Jellyfin::Support::toJsonValue(m_data); - + + result["Language"] = Jellyfin::Support::toJsonValue(m_language); + result["Format"] = Jellyfin::Support::toJsonValue(m_format); + result["IsForced"] = Jellyfin::Support::toJsonValue(m_isForced); + result["Data"] = Jellyfin::Support::toJsonValue(m_data); return result; } diff --git a/core/src/dto/userconfiguration.cpp b/core/src/dto/userconfiguration.cpp index ead32a4..3a51866 100644 --- a/core/src/dto/userconfiguration.cpp +++ b/core/src/dto/userconfiguration.cpp @@ -99,22 +99,46 @@ void UserConfiguration::setFromJson(QJsonObject source) { QJsonObject UserConfiguration::toJson() const { QJsonObject result; - result["AudioLanguagePreference"] = Jellyfin::Support::toJsonValue(m_audioLanguagePreference); - result["PlayDefaultAudioTrack"] = Jellyfin::Support::toJsonValue(m_playDefaultAudioTrack); - result["SubtitleLanguagePreference"] = Jellyfin::Support::toJsonValue(m_subtitleLanguagePreference); - result["DisplayMissingEpisodes"] = Jellyfin::Support::toJsonValue(m_displayMissingEpisodes); - result["GroupedFolders"] = Jellyfin::Support::toJsonValue(m_groupedFolders); - result["SubtitleMode"] = Jellyfin::Support::toJsonValue(m_subtitleMode); - result["DisplayCollectionsView"] = Jellyfin::Support::toJsonValue(m_displayCollectionsView); - result["EnableLocalPassword"] = Jellyfin::Support::toJsonValue(m_enableLocalPassword); - result["OrderedViews"] = Jellyfin::Support::toJsonValue(m_orderedViews); - result["LatestItemsExcludes"] = Jellyfin::Support::toJsonValue(m_latestItemsExcludes); - result["MyMediaExcludes"] = Jellyfin::Support::toJsonValue(m_myMediaExcludes); - result["HidePlayedInLatest"] = Jellyfin::Support::toJsonValue(m_hidePlayedInLatest); - result["RememberAudioSelections"] = Jellyfin::Support::toJsonValue(m_rememberAudioSelections); - result["RememberSubtitleSelections"] = Jellyfin::Support::toJsonValue(m_rememberSubtitleSelections); - result["EnableNextEpisodeAutoPlay"] = Jellyfin::Support::toJsonValue(m_enableNextEpisodeAutoPlay); - + + + if (!(m_audioLanguagePreference.isNull())) { + result["AudioLanguagePreference"] = Jellyfin::Support::toJsonValue(m_audioLanguagePreference); + } + + result["PlayDefaultAudioTrack"] = Jellyfin::Support::toJsonValue(m_playDefaultAudioTrack); + + if (!(m_subtitleLanguagePreference.isNull())) { + result["SubtitleLanguagePreference"] = Jellyfin::Support::toJsonValue(m_subtitleLanguagePreference); + } + + result["DisplayMissingEpisodes"] = Jellyfin::Support::toJsonValue(m_displayMissingEpisodes); + + if (!(m_groupedFolders.size() == 0)) { + result["GroupedFolders"] = Jellyfin::Support::toJsonValue(m_groupedFolders); + } + + result["SubtitleMode"] = Jellyfin::Support::toJsonValue(m_subtitleMode); + result["DisplayCollectionsView"] = Jellyfin::Support::toJsonValue(m_displayCollectionsView); + result["EnableLocalPassword"] = Jellyfin::Support::toJsonValue(m_enableLocalPassword); + + if (!(m_orderedViews.size() == 0)) { + result["OrderedViews"] = Jellyfin::Support::toJsonValue(m_orderedViews); + } + + + if (!(m_latestItemsExcludes.size() == 0)) { + result["LatestItemsExcludes"] = Jellyfin::Support::toJsonValue(m_latestItemsExcludes); + } + + + if (!(m_myMediaExcludes.size() == 0)) { + result["MyMediaExcludes"] = Jellyfin::Support::toJsonValue(m_myMediaExcludes); + } + + result["HidePlayedInLatest"] = Jellyfin::Support::toJsonValue(m_hidePlayedInLatest); + result["RememberAudioSelections"] = Jellyfin::Support::toJsonValue(m_rememberAudioSelections); + result["RememberSubtitleSelections"] = Jellyfin::Support::toJsonValue(m_rememberSubtitleSelections); + result["EnableNextEpisodeAutoPlay"] = Jellyfin::Support::toJsonValue(m_enableNextEpisodeAutoPlay); return result; } diff --git a/core/src/dto/userdto.cpp b/core/src/dto/userdto.cpp index 2edd4c1..c2ba44d 100644 --- a/core/src/dto/userdto.cpp +++ b/core/src/dto/userdto.cpp @@ -96,21 +96,53 @@ void UserDto::setFromJson(QJsonObject source) { QJsonObject UserDto::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["ServerId"] = Jellyfin::Support::toJsonValue(m_serverId); - result["ServerName"] = Jellyfin::Support::toJsonValue(m_serverName); - result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); - result["PrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_primaryImageTag); - result["HasPassword"] = Jellyfin::Support::toJsonValue(m_hasPassword); - result["HasConfiguredPassword"] = Jellyfin::Support::toJsonValue(m_hasConfiguredPassword); - result["HasConfiguredEasyPassword"] = Jellyfin::Support::toJsonValue(m_hasConfiguredEasyPassword); - result["EnableAutoLogin"] = Jellyfin::Support::toJsonValue>(m_enableAutoLogin); - result["LastLoginDate"] = Jellyfin::Support::toJsonValue(m_lastLoginDate); - result["LastActivityDate"] = Jellyfin::Support::toJsonValue(m_lastActivityDate); - result["Configuration"] = Jellyfin::Support::toJsonValue>(m_configuration); - result["Policy"] = Jellyfin::Support::toJsonValue>(m_policy); - result["PrimaryImageAspectRatio"] = Jellyfin::Support::toJsonValue>(m_primaryImageAspectRatio); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_serverId.isNull())) { + result["ServerId"] = Jellyfin::Support::toJsonValue(m_serverId); + } + + + if (!(m_serverName.isNull())) { + result["ServerName"] = Jellyfin::Support::toJsonValue(m_serverName); + } + + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + + if (!(m_primaryImageTag.isNull())) { + result["PrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_primaryImageTag); + } + + result["HasPassword"] = Jellyfin::Support::toJsonValue(m_hasPassword); + result["HasConfiguredPassword"] = Jellyfin::Support::toJsonValue(m_hasConfiguredPassword); + result["HasConfiguredEasyPassword"] = Jellyfin::Support::toJsonValue(m_hasConfiguredEasyPassword); + + if (!(!m_enableAutoLogin.has_value())) { + result["EnableAutoLogin"] = Jellyfin::Support::toJsonValue>(m_enableAutoLogin); + } + + + if (!(m_lastLoginDate.isNull())) { + result["LastLoginDate"] = Jellyfin::Support::toJsonValue(m_lastLoginDate); + } + + + if (!(m_lastActivityDate.isNull())) { + result["LastActivityDate"] = Jellyfin::Support::toJsonValue(m_lastActivityDate); + } + + result["Configuration"] = Jellyfin::Support::toJsonValue>(m_configuration); + result["Policy"] = Jellyfin::Support::toJsonValue>(m_policy); + + if (!(!m_primaryImageAspectRatio.has_value())) { + result["PrimaryImageAspectRatio"] = Jellyfin::Support::toJsonValue>(m_primaryImageAspectRatio); + } + return result; } diff --git a/core/src/dto/useritemdatadto.cpp b/core/src/dto/useritemdatadto.cpp index 3863abb..688ee3d 100644 --- a/core/src/dto/useritemdatadto.cpp +++ b/core/src/dto/useritemdatadto.cpp @@ -87,18 +87,46 @@ void UserItemDataDto::setFromJson(QJsonObject source) { QJsonObject UserItemDataDto::toJson() const { QJsonObject result; - result["Rating"] = Jellyfin::Support::toJsonValue>(m_rating); - result["PlayedPercentage"] = Jellyfin::Support::toJsonValue>(m_playedPercentage); - result["UnplayedItemCount"] = Jellyfin::Support::toJsonValue>(m_unplayedItemCount); - result["PlaybackPositionTicks"] = Jellyfin::Support::toJsonValue(m_playbackPositionTicks); - result["PlayCount"] = Jellyfin::Support::toJsonValue(m_playCount); - result["IsFavorite"] = Jellyfin::Support::toJsonValue(m_isFavorite); - result["Likes"] = Jellyfin::Support::toJsonValue>(m_likes); - result["LastPlayedDate"] = Jellyfin::Support::toJsonValue(m_lastPlayedDate); - result["Played"] = Jellyfin::Support::toJsonValue(m_played); - result["Key"] = Jellyfin::Support::toJsonValue(m_key); - result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); - + + + if (!(!m_rating.has_value())) { + result["Rating"] = Jellyfin::Support::toJsonValue>(m_rating); + } + + + if (!(!m_playedPercentage.has_value())) { + result["PlayedPercentage"] = Jellyfin::Support::toJsonValue>(m_playedPercentage); + } + + + if (!(!m_unplayedItemCount.has_value())) { + result["UnplayedItemCount"] = Jellyfin::Support::toJsonValue>(m_unplayedItemCount); + } + + result["PlaybackPositionTicks"] = Jellyfin::Support::toJsonValue(m_playbackPositionTicks); + result["PlayCount"] = Jellyfin::Support::toJsonValue(m_playCount); + result["IsFavorite"] = Jellyfin::Support::toJsonValue(m_isFavorite); + + if (!(!m_likes.has_value())) { + result["Likes"] = Jellyfin::Support::toJsonValue>(m_likes); + } + + + if (!(m_lastPlayedDate.isNull())) { + result["LastPlayedDate"] = Jellyfin::Support::toJsonValue(m_lastPlayedDate); + } + + result["Played"] = Jellyfin::Support::toJsonValue(m_played); + + if (!(m_key.isNull())) { + result["Key"] = Jellyfin::Support::toJsonValue(m_key); + } + + + if (!(m_itemId.isNull())) { + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + } + return result; } diff --git a/core/src/dto/userpolicy.cpp b/core/src/dto/userpolicy.cpp index c558b06..78c6a1d 100644 --- a/core/src/dto/userpolicy.cpp +++ b/core/src/dto/userpolicy.cpp @@ -171,46 +171,94 @@ void UserPolicy::setFromJson(QJsonObject source) { QJsonObject UserPolicy::toJson() const { QJsonObject result; - result["IsAdministrator"] = Jellyfin::Support::toJsonValue(m_isAdministrator); - result["IsHidden"] = Jellyfin::Support::toJsonValue(m_isHidden); - result["IsDisabled"] = Jellyfin::Support::toJsonValue(m_isDisabled); - result["MaxParentalRating"] = Jellyfin::Support::toJsonValue>(m_maxParentalRating); - result["BlockedTags"] = Jellyfin::Support::toJsonValue(m_blockedTags); - result["EnableUserPreferenceAccess"] = Jellyfin::Support::toJsonValue(m_enableUserPreferenceAccess); - result["AccessSchedules"] = Jellyfin::Support::toJsonValue>(m_accessSchedules); - result["BlockUnratedItems"] = Jellyfin::Support::toJsonValue>(m_blockUnratedItems); - result["EnableRemoteControlOfOtherUsers"] = Jellyfin::Support::toJsonValue(m_enableRemoteControlOfOtherUsers); - result["EnableSharedDeviceControl"] = Jellyfin::Support::toJsonValue(m_enableSharedDeviceControl); - result["EnableRemoteAccess"] = Jellyfin::Support::toJsonValue(m_enableRemoteAccess); - result["EnableLiveTvManagement"] = Jellyfin::Support::toJsonValue(m_enableLiveTvManagement); - result["EnableLiveTvAccess"] = Jellyfin::Support::toJsonValue(m_enableLiveTvAccess); - result["EnableMediaPlayback"] = Jellyfin::Support::toJsonValue(m_enableMediaPlayback); - result["EnableAudioPlaybackTranscoding"] = Jellyfin::Support::toJsonValue(m_enableAudioPlaybackTranscoding); - result["EnableVideoPlaybackTranscoding"] = Jellyfin::Support::toJsonValue(m_enableVideoPlaybackTranscoding); - result["EnablePlaybackRemuxing"] = Jellyfin::Support::toJsonValue(m_enablePlaybackRemuxing); - result["ForceRemoteSourceTranscoding"] = Jellyfin::Support::toJsonValue(m_forceRemoteSourceTranscoding); - result["EnableContentDeletion"] = Jellyfin::Support::toJsonValue(m_enableContentDeletion); - result["EnableContentDeletionFromFolders"] = Jellyfin::Support::toJsonValue(m_enableContentDeletionFromFolders); - result["EnableContentDownloading"] = Jellyfin::Support::toJsonValue(m_enableContentDownloading); - result["EnableSyncTranscoding"] = Jellyfin::Support::toJsonValue(m_enableSyncTranscoding); - result["EnableMediaConversion"] = Jellyfin::Support::toJsonValue(m_enableMediaConversion); - result["EnabledDevices"] = Jellyfin::Support::toJsonValue(m_enabledDevices); - result["EnableAllDevices"] = Jellyfin::Support::toJsonValue(m_enableAllDevices); - result["EnabledChannels"] = Jellyfin::Support::toJsonValue(m_enabledChannels); - result["EnableAllChannels"] = Jellyfin::Support::toJsonValue(m_enableAllChannels); - result["EnabledFolders"] = Jellyfin::Support::toJsonValue(m_enabledFolders); - result["EnableAllFolders"] = Jellyfin::Support::toJsonValue(m_enableAllFolders); - result["InvalidLoginAttemptCount"] = Jellyfin::Support::toJsonValue(m_invalidLoginAttemptCount); - result["LoginAttemptsBeforeLockout"] = Jellyfin::Support::toJsonValue(m_loginAttemptsBeforeLockout); - result["MaxActiveSessions"] = Jellyfin::Support::toJsonValue(m_maxActiveSessions); - result["EnablePublicSharing"] = Jellyfin::Support::toJsonValue(m_enablePublicSharing); - result["BlockedMediaFolders"] = Jellyfin::Support::toJsonValue(m_blockedMediaFolders); - result["BlockedChannels"] = Jellyfin::Support::toJsonValue(m_blockedChannels); - result["RemoteClientBitrateLimit"] = Jellyfin::Support::toJsonValue(m_remoteClientBitrateLimit); - result["AuthenticationProviderId"] = Jellyfin::Support::toJsonValue(m_authenticationProviderId); - result["PasswordResetProviderId"] = Jellyfin::Support::toJsonValue(m_passwordResetProviderId); - result["SyncPlayAccess"] = Jellyfin::Support::toJsonValue(m_syncPlayAccess); - + + result["IsAdministrator"] = Jellyfin::Support::toJsonValue(m_isAdministrator); + result["IsHidden"] = Jellyfin::Support::toJsonValue(m_isHidden); + result["IsDisabled"] = Jellyfin::Support::toJsonValue(m_isDisabled); + + if (!(!m_maxParentalRating.has_value())) { + result["MaxParentalRating"] = Jellyfin::Support::toJsonValue>(m_maxParentalRating); + } + + + if (!(m_blockedTags.size() == 0)) { + result["BlockedTags"] = Jellyfin::Support::toJsonValue(m_blockedTags); + } + + result["EnableUserPreferenceAccess"] = Jellyfin::Support::toJsonValue(m_enableUserPreferenceAccess); + + if (!(m_accessSchedules.size() == 0)) { + result["AccessSchedules"] = Jellyfin::Support::toJsonValue>(m_accessSchedules); + } + + + if (!(m_blockUnratedItems.size() == 0)) { + result["BlockUnratedItems"] = Jellyfin::Support::toJsonValue>(m_blockUnratedItems); + } + + result["EnableRemoteControlOfOtherUsers"] = Jellyfin::Support::toJsonValue(m_enableRemoteControlOfOtherUsers); + result["EnableSharedDeviceControl"] = Jellyfin::Support::toJsonValue(m_enableSharedDeviceControl); + result["EnableRemoteAccess"] = Jellyfin::Support::toJsonValue(m_enableRemoteAccess); + result["EnableLiveTvManagement"] = Jellyfin::Support::toJsonValue(m_enableLiveTvManagement); + result["EnableLiveTvAccess"] = Jellyfin::Support::toJsonValue(m_enableLiveTvAccess); + result["EnableMediaPlayback"] = Jellyfin::Support::toJsonValue(m_enableMediaPlayback); + result["EnableAudioPlaybackTranscoding"] = Jellyfin::Support::toJsonValue(m_enableAudioPlaybackTranscoding); + result["EnableVideoPlaybackTranscoding"] = Jellyfin::Support::toJsonValue(m_enableVideoPlaybackTranscoding); + result["EnablePlaybackRemuxing"] = Jellyfin::Support::toJsonValue(m_enablePlaybackRemuxing); + result["ForceRemoteSourceTranscoding"] = Jellyfin::Support::toJsonValue(m_forceRemoteSourceTranscoding); + result["EnableContentDeletion"] = Jellyfin::Support::toJsonValue(m_enableContentDeletion); + + if (!(m_enableContentDeletionFromFolders.size() == 0)) { + result["EnableContentDeletionFromFolders"] = Jellyfin::Support::toJsonValue(m_enableContentDeletionFromFolders); + } + + result["EnableContentDownloading"] = Jellyfin::Support::toJsonValue(m_enableContentDownloading); + result["EnableSyncTranscoding"] = Jellyfin::Support::toJsonValue(m_enableSyncTranscoding); + result["EnableMediaConversion"] = Jellyfin::Support::toJsonValue(m_enableMediaConversion); + + if (!(m_enabledDevices.size() == 0)) { + result["EnabledDevices"] = Jellyfin::Support::toJsonValue(m_enabledDevices); + } + + result["EnableAllDevices"] = Jellyfin::Support::toJsonValue(m_enableAllDevices); + + if (!(m_enabledChannels.size() == 0)) { + result["EnabledChannels"] = Jellyfin::Support::toJsonValue(m_enabledChannels); + } + + result["EnableAllChannels"] = Jellyfin::Support::toJsonValue(m_enableAllChannels); + + if (!(m_enabledFolders.size() == 0)) { + result["EnabledFolders"] = Jellyfin::Support::toJsonValue(m_enabledFolders); + } + + result["EnableAllFolders"] = Jellyfin::Support::toJsonValue(m_enableAllFolders); + result["InvalidLoginAttemptCount"] = Jellyfin::Support::toJsonValue(m_invalidLoginAttemptCount); + result["LoginAttemptsBeforeLockout"] = Jellyfin::Support::toJsonValue(m_loginAttemptsBeforeLockout); + result["MaxActiveSessions"] = Jellyfin::Support::toJsonValue(m_maxActiveSessions); + result["EnablePublicSharing"] = Jellyfin::Support::toJsonValue(m_enablePublicSharing); + + if (!(m_blockedMediaFolders.size() == 0)) { + result["BlockedMediaFolders"] = Jellyfin::Support::toJsonValue(m_blockedMediaFolders); + } + + + if (!(m_blockedChannels.size() == 0)) { + result["BlockedChannels"] = Jellyfin::Support::toJsonValue(m_blockedChannels); + } + + result["RemoteClientBitrateLimit"] = Jellyfin::Support::toJsonValue(m_remoteClientBitrateLimit); + + if (!(m_authenticationProviderId.isNull())) { + result["AuthenticationProviderId"] = Jellyfin::Support::toJsonValue(m_authenticationProviderId); + } + + + if (!(m_passwordResetProviderId.isNull())) { + result["PasswordResetProviderId"] = Jellyfin::Support::toJsonValue(m_passwordResetProviderId); + } + + result["SyncPlayAccess"] = Jellyfin::Support::toJsonValue(m_syncPlayAccess); return result; } diff --git a/core/src/dto/utctimeresponse.cpp b/core/src/dto/utctimeresponse.cpp index 309eb59..ef9110f 100644 --- a/core/src/dto/utctimeresponse.cpp +++ b/core/src/dto/utctimeresponse.cpp @@ -60,9 +60,9 @@ void UtcTimeResponse::setFromJson(QJsonObject source) { QJsonObject UtcTimeResponse::toJson() const { QJsonObject result; - result["RequestReceptionTime"] = Jellyfin::Support::toJsonValue(m_requestReceptionTime); - result["ResponseTransmissionTime"] = Jellyfin::Support::toJsonValue(m_responseTransmissionTime); - + + result["RequestReceptionTime"] = Jellyfin::Support::toJsonValue(m_requestReceptionTime); + result["ResponseTransmissionTime"] = Jellyfin::Support::toJsonValue(m_responseTransmissionTime); return result; } diff --git a/core/src/dto/validatepathdto.cpp b/core/src/dto/validatepathdto.cpp index 9f40d8a..d41fcf0 100644 --- a/core/src/dto/validatepathdto.cpp +++ b/core/src/dto/validatepathdto.cpp @@ -63,10 +63,18 @@ void ValidatePathDto::setFromJson(QJsonObject source) { QJsonObject ValidatePathDto::toJson() const { QJsonObject result; - result["ValidateWritable"] = Jellyfin::Support::toJsonValue(m_validateWritable); - result["Path"] = Jellyfin::Support::toJsonValue(m_path); - result["IsFile"] = Jellyfin::Support::toJsonValue>(m_isFile); - + + result["ValidateWritable"] = Jellyfin::Support::toJsonValue(m_validateWritable); + + if (!(m_path.isNull())) { + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + } + + + if (!(!m_isFile.has_value())) { + result["IsFile"] = Jellyfin::Support::toJsonValue>(m_isFile); + } + return result; } diff --git a/core/src/dto/version.cpp b/core/src/dto/version.cpp index cbe5449..e6febfb 100644 --- a/core/src/dto/version.cpp +++ b/core/src/dto/version.cpp @@ -72,13 +72,13 @@ void Version::setFromJson(QJsonObject source) { QJsonObject Version::toJson() const { QJsonObject result; - result["Major"] = Jellyfin::Support::toJsonValue(m_major); - result["Minor"] = Jellyfin::Support::toJsonValue(m_minor); - result["Build"] = Jellyfin::Support::toJsonValue(m_build); - result["Revision"] = Jellyfin::Support::toJsonValue(m_revision); - result["MajorRevision"] = Jellyfin::Support::toJsonValue(m_majorRevision); - result["MinorRevision"] = Jellyfin::Support::toJsonValue(m_minorRevision); - + + result["Major"] = Jellyfin::Support::toJsonValue(m_major); + result["Minor"] = Jellyfin::Support::toJsonValue(m_minor); + result["Build"] = Jellyfin::Support::toJsonValue(m_build); + result["Revision"] = Jellyfin::Support::toJsonValue(m_revision); + result["MajorRevision"] = Jellyfin::Support::toJsonValue(m_majorRevision); + result["MinorRevision"] = Jellyfin::Support::toJsonValue(m_minorRevision); return result; } diff --git a/core/src/dto/versioninfo.cpp b/core/src/dto/versioninfo.cpp index 53bbe76..be10817 100644 --- a/core/src/dto/versioninfo.cpp +++ b/core/src/dto/versioninfo.cpp @@ -81,16 +81,48 @@ void VersionInfo::setFromJson(QJsonObject source) { QJsonObject VersionInfo::toJson() const { QJsonObject result; - result["version"] = Jellyfin::Support::toJsonValue(m_version); - result["VersionNumber"] = Jellyfin::Support::toJsonValue>(m_versionNumber); - result["changelog"] = Jellyfin::Support::toJsonValue(m_changelog); - result["targetAbi"] = Jellyfin::Support::toJsonValue(m_targetAbi); - result["sourceUrl"] = Jellyfin::Support::toJsonValue(m_sourceUrl); - result["checksum"] = Jellyfin::Support::toJsonValue(m_checksum); - result["timestamp"] = Jellyfin::Support::toJsonValue(m_timestamp); - result["repositoryName"] = Jellyfin::Support::toJsonValue(m_repositoryName); - result["repositoryUrl"] = Jellyfin::Support::toJsonValue(m_repositoryUrl); - + + + if (!(m_version.isNull())) { + result["version"] = Jellyfin::Support::toJsonValue(m_version); + } + + result["VersionNumber"] = Jellyfin::Support::toJsonValue>(m_versionNumber); + + if (!(m_changelog.isNull())) { + result["changelog"] = Jellyfin::Support::toJsonValue(m_changelog); + } + + + if (!(m_targetAbi.isNull())) { + result["targetAbi"] = Jellyfin::Support::toJsonValue(m_targetAbi); + } + + + if (!(m_sourceUrl.isNull())) { + result["sourceUrl"] = Jellyfin::Support::toJsonValue(m_sourceUrl); + } + + + if (!(m_checksum.isNull())) { + result["checksum"] = Jellyfin::Support::toJsonValue(m_checksum); + } + + + if (!(m_timestamp.isNull())) { + result["timestamp"] = Jellyfin::Support::toJsonValue(m_timestamp); + } + + + if (!(m_repositoryName.isNull())) { + result["repositoryName"] = Jellyfin::Support::toJsonValue(m_repositoryName); + } + + + if (!(m_repositoryUrl.isNull())) { + result["repositoryUrl"] = Jellyfin::Support::toJsonValue(m_repositoryUrl); + } + return result; } diff --git a/core/src/dto/virtualfolderinfo.cpp b/core/src/dto/virtualfolderinfo.cpp index 2286b61..b3acbff 100644 --- a/core/src/dto/virtualfolderinfo.cpp +++ b/core/src/dto/virtualfolderinfo.cpp @@ -78,15 +78,43 @@ void VirtualFolderInfo::setFromJson(QJsonObject source) { QJsonObject VirtualFolderInfo::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Locations"] = Jellyfin::Support::toJsonValue(m_locations); - result["CollectionType"] = Jellyfin::Support::toJsonValue(m_collectionType); - result["LibraryOptions"] = Jellyfin::Support::toJsonValue>(m_libraryOptions); - result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); - result["PrimaryImageItemId"] = Jellyfin::Support::toJsonValue(m_primaryImageItemId); - result["RefreshProgress"] = Jellyfin::Support::toJsonValue>(m_refreshProgress); - result["RefreshStatus"] = Jellyfin::Support::toJsonValue(m_refreshStatus); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_locations.size() == 0)) { + result["Locations"] = Jellyfin::Support::toJsonValue(m_locations); + } + + + if (!(m_collectionType.isNull())) { + result["CollectionType"] = Jellyfin::Support::toJsonValue(m_collectionType); + } + + result["LibraryOptions"] = Jellyfin::Support::toJsonValue>(m_libraryOptions); + + if (!(m_itemId.isNull())) { + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + } + + + if (!(m_primaryImageItemId.isNull())) { + result["PrimaryImageItemId"] = Jellyfin::Support::toJsonValue(m_primaryImageItemId); + } + + + if (!(!m_refreshProgress.has_value())) { + result["RefreshProgress"] = Jellyfin::Support::toJsonValue>(m_refreshProgress); + } + + + if (!(m_refreshStatus.isNull())) { + result["RefreshStatus"] = Jellyfin::Support::toJsonValue(m_refreshStatus); + } + return result; } diff --git a/core/src/dto/wakeonlaninfo.cpp b/core/src/dto/wakeonlaninfo.cpp index 949aa55..0b1bad8 100644 --- a/core/src/dto/wakeonlaninfo.cpp +++ b/core/src/dto/wakeonlaninfo.cpp @@ -60,9 +60,13 @@ void WakeOnLanInfo::setFromJson(QJsonObject source) { QJsonObject WakeOnLanInfo::toJson() const { QJsonObject result; - result["MacAddress"] = Jellyfin::Support::toJsonValue(m_macAddress); - result["Port"] = Jellyfin::Support::toJsonValue(m_port); - + + + if (!(m_macAddress.isNull())) { + result["MacAddress"] = Jellyfin::Support::toJsonValue(m_macAddress); + } + + result["Port"] = Jellyfin::Support::toJsonValue(m_port); return result; } diff --git a/core/src/dto/xmlattribute.cpp b/core/src/dto/xmlattribute.cpp index a6d52a8..83cf0bd 100644 --- a/core/src/dto/xmlattribute.cpp +++ b/core/src/dto/xmlattribute.cpp @@ -60,9 +60,17 @@ void XmlAttribute::setFromJson(QJsonObject source) { QJsonObject XmlAttribute::toJson() const { QJsonObject result; - result["Name"] = Jellyfin::Support::toJsonValue(m_name); - result["Value"] = Jellyfin::Support::toJsonValue(m_value); - + + + if (!(m_name.isNull())) { + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + } + + + if (!(m_value.isNull())) { + result["Value"] = Jellyfin::Support::toJsonValue(m_value); + } + return result; } diff --git a/core/src/model/deviceprofile.cpp b/core/src/model/deviceprofile.cpp index 114d1c9..0e570fb 100644 --- a/core/src/model/deviceprofile.cpp +++ b/core/src/model/deviceprofile.cpp @@ -140,6 +140,7 @@ DTO::DeviceProfile DeviceProfile::generateProfile() { transcoding1.setMaxAudioChannels("2"); transcoding1.setMinSegments(1); transcoding1.setProtocol("hls"); + transcoding1.setTranscodeSeekInfo(DTO::TranscodeSeekInfo::Auto); transcoding1.setType(DTO::DlnaProfileType::Audio); // Hard code nr 2 DTO::TranscodingProfile transcoding2; @@ -150,6 +151,7 @@ DTO::DeviceProfile DeviceProfile::generateProfile() { transcoding2.setMaxAudioChannels("2"); transcoding2.setMinSegments(1); transcoding2.setProtocol("hls"); + transcoding2.setTranscodeSeekInfo(DTO::TranscodeSeekInfo::Auto); transcoding2.setType(DTO::DlnaProfileType::Video); transcoding2.setVideoCodec("h264"); @@ -161,6 +163,7 @@ DTO::DeviceProfile DeviceProfile::generateProfile() { transcoding3.setVideoCodec("h264"); transcoding3.setContext(DTO::EncodingContext::Static); transcoding3.setProtocol("http"); + transcoding3.setTranscodeSeekInfo(DTO::TranscodeSeekInfo::Auto); QList transcodingProfiles = { transcoding1, transcoding2, transcoding3 @@ -177,6 +180,7 @@ DTO::DeviceProfile DeviceProfile::generateProfile() { transcoding4.setMaxAudioChannels("2"); transcoding4.setMinSegments(1); transcoding4.setBreakOnNonKeyFrames(true); + transcoding4.setTranscodeSeekInfo(DTO::TranscodeSeekInfo::Auto); transcodingProfiles.append(transcoding4); }