2 * Copyright (C) 2023 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
9 #include "VideoEmbeddedImageFileLoader.h"
12 #include "guilib/Texture.h"
13 #include "imagefiles/ImageFileURL.h"
14 #include "utils/EmbeddedArt.h"
15 #include "utils/StringUtils.h"
16 #include "video/VideoInfoTag.h"
17 #include "video/tags/IVideoInfoTagLoader.h"
18 #include "video/tags/VideoInfoTagLoaderFactory.h"
23 bool CVideoEmbeddedImageFileLoader::CanLoad(const std::string
& specialType
) const
25 return StringUtils::StartsWith(specialType
, "video_");
30 bool GetEmbeddedThumb(const std::string
& path
, const std::string
& type
, EmbeddedArt
& art
)
32 CFileItem
item(path
, false);
33 std::unique_ptr
<IVideoInfoTagLoader
> loader(
34 CVideoInfoTagLoaderFactory::CreateLoader(item
, ADDON::ScraperPtr(), false));
36 std::vector
<EmbeddedArt
> artv
;
38 loader
->Load(tag
, false, &artv
);
40 for (const auto& it
: artv
)
42 if (it
.m_type
== type
)
52 std::unique_ptr
<CTexture
> CVideoEmbeddedImageFileLoader::Load(
53 const IMAGE_FILES::CImageFileURL
& imageFile
) const
56 if (GetEmbeddedThumb(imageFile
.GetTargetFile(), imageFile
.GetSpecialType().substr(6), art
))
57 return CTexture::LoadFromFileInMemory(art
.m_data
.data(), art
.m_size
, art
.m_mime
);
61 } // namespace KODI::VIDEO