From 13ad4f31319315c72fc7afc14516a9a4250db828 Mon Sep 17 00:00:00 2001 From: CrystalP Date: Sun, 17 Nov 2024 10:39:01 -0500 Subject: [PATCH] [cosmetic] AddVideoAsset function cleanup Add doxygen, generic param name, and function, explicit INSERT columns. --- xbmc/video/VideoDatabase.cpp | 25 +++++++++++++------------ xbmc/video/VideoDatabase.h | 12 +++++++++++- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/xbmc/video/VideoDatabase.cpp b/xbmc/video/VideoDatabase.cpp index 2865b6ca2c..177eae333d 100644 --- a/xbmc/video/VideoDatabase.cpp +++ b/xbmc/video/VideoDatabase.cpp @@ -12590,7 +12590,7 @@ void CVideoDatabase::SetVideoVersion(int idFile, int idVideoVersion) bool CVideoDatabase::AddVideoAsset(VideoDbContentType itemType, int dbId, - int idVideoVersion, + int idVideoAsset, VideoAssetType videoAssetType, CFileItem& item) { @@ -12599,14 +12599,12 @@ bool CVideoDatabase::AddVideoAsset(VideoDbContentType itemType, assert(m_pDB->in_transaction() == false); - MediaType mediaType; - if (itemType == VideoDbContentType::MOVIES) - { - mediaType = MediaTypeMovie; - } - else + if (itemType != VideoDbContentType::MOVIES) return false; + MediaType mediaType; + VideoContentTypeToString(itemType, mediaType); + int idFile = AddFile(item.GetPath()); if (idFile < 0) return false; @@ -12618,12 +12616,15 @@ bool CVideoDatabase::AddVideoAsset(VideoDbContentType itemType, m_pDS->query(PrepareSQL("SELECT idFile FROM videoversion WHERE idFile = %i", idFile)); if (m_pDS->num_rows() == 0) - m_pDS->exec(PrepareSQL("INSERT INTO videoversion VALUES(%i, %i, '%s', %i, %i)", idFile, dbId, - mediaType.c_str(), videoAssetType, idVideoVersion)); + m_pDS->exec( + PrepareSQL("INSERT INTO videoversion (idFile, idMedia, media_type, itemType, idType) " + "VALUES(%i, %i, '%s', %i, %i)", + idFile, dbId, mediaType.c_str(), videoAssetType, idVideoAsset)); else - m_pDS->exec(PrepareSQL("UPDATE videoversion SET idMedia = %i, media_type = '%s', itemType = " - "%i, idType = %i WHERE idFile = %i", - dbId, mediaType.c_str(), videoAssetType, idVideoVersion, idFile)); + m_pDS->exec(PrepareSQL("UPDATE videoversion " + "SET idMedia = %i, media_type = '%s', itemType = %i, idType = %i " + "WHERE idFile = %i", + dbId, mediaType.c_str(), videoAssetType, idVideoAsset, idFile)); if (item.GetVideoInfoTag()->HasStreamDetails()) SetStreamDetailsForFileId(item.GetVideoInfoTag()->m_streamDetails, idFile); diff --git a/xbmc/video/VideoDatabase.h b/xbmc/video/VideoDatabase.h index 70c2cd090e..f5784fb6a6 100644 --- a/xbmc/video/VideoDatabase.h +++ b/xbmc/video/VideoDatabase.h @@ -1093,9 +1093,19 @@ public: int AddVideoVersionType(const std::string& typeVideoVersion, VideoAssetTypeOwner owner, VideoAssetType assetType); + /*! + * \brief Create a new video asset from the provided item and type and attach it to an owner + * A file record is created for items with a path new to the database. + * \param[in] itemType Parent's type + * \param[in] dbId Parent's id + * \param[in] idVideoAsset Video asset identifier / name + * \param[in] videoAssetType Type of the video asset + * \param[in] item Item to be made into a video asset + * \return Success status. true:success, false:failure + */ bool AddVideoAsset(VideoDbContentType itemType, int dbId, - int idVideoVersion, + int idVideoAsset, VideoAssetType videoAssetType, CFileItem& item); bool DeleteVideoAsset(int idFile); -- 2.11.4.GIT