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 "VideoGeneratedImageFileLoader.h"
11 #include "DVDFileInfo.h"
13 #include "ServiceBroker.h"
15 #include "filesystem/DirectoryCache.h"
16 #include "guilib/Texture.h"
17 #include "imagefiles/ImageFileURL.h"
18 #include "settings/Settings.h"
19 #include "settings/SettingsComponent.h"
20 #include "utils/URIUtils.h"
21 #include "video/VideoFileItemClassify.h"
22 #include "video/VideoInfoTag.h"
29 bool CVideoGeneratedImageFileLoader::CanLoad(const std::string
& specialType
) const
31 return specialType
== "video";
36 void SetupRarOptions(CFileItem
& item
, const std::string
& path
)
38 std::string
path2(path
);
39 if (IsVideoDb(item
) && item
.HasVideoInfoTag())
40 path2
= item
.GetVideoInfoTag()->m_strFileNameAndPath
;
42 std::string opts
= url
.GetOptions();
43 if (opts
.find("flags") != std::string::npos
)
50 if (IsVideoDb(item
) && item
.HasVideoInfoTag())
51 item
.GetVideoInfoTag()->m_strFileNameAndPath
= url
.Get();
53 item
.SetPath(url
.Get());
54 g_directoryCache
.ClearDirectory(url
.GetWithoutFilename());
58 std::unique_ptr
<CTexture
> CVideoGeneratedImageFileLoader::Load(
59 const IMAGE_FILES::CImageFileURL
& imageFile
) const
61 if (!CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(
62 CSettings::SETTING_MYVIDEOS_EXTRACTTHUMB
))
67 const std::string
& filePath
= imageFile
.GetTargetFile();
68 CFileItem item
{filePath
, false};
70 if (URIUtils::IsInRAR(filePath
))
71 SetupRarOptions(item
, filePath
);
73 std::string chapterOption
= imageFile
.GetOption("chapter");
75 std::from_chars(chapterOption
.data(), chapterOption
.data() + chapterOption
.size(), chapter
);
77 return CDVDFileInfo::ExtractThumbToTexture(item
, chapter
);
80 } // namespace KODI::VIDEO