blob: 6ef1b93ef91cbf907ad27df4eb4156cef857d78a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
/*
* Copyright (C) 2023 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "VideoGeneratedImageFileLoader.h"
#include "DVDFileInfo.h"
#include "FileItem.h"
#include "ServiceBroker.h"
#include "URL.h"
#include "filesystem/DirectoryCache.h"
#include "guilib/Texture.h"
#include "settings/Settings.h"
#include "settings/SettingsComponent.h"
#include "utils/URIUtils.h"
#include "video/VideoFileItemClassify.h"
#include "video/VideoInfoTag.h"
using namespace KODI::VIDEO;
bool VIDEO::CVideoGeneratedImageFileLoader::CanLoad(const std::string& specialType) const
{
return specialType == "video";
}
namespace
{
void SetupRarOptions(CFileItem& item, const std::string& path)
{
std::string path2(path);
if (IsVideoDb(item) && item.HasVideoInfoTag())
path2 = item.GetVideoInfoTag()->m_strFileNameAndPath;
CURL url(path2);
std::string opts = url.GetOptions();
if (opts.find("flags") != std::string::npos)
return;
if (opts.size())
opts += "&flags=8";
else
opts = "?flags=8";
url.SetOptions(opts);
if (IsVideoDb(item) && item.HasVideoInfoTag())
item.GetVideoInfoTag()->m_strFileNameAndPath = url.Get();
else
item.SetPath(url.Get());
g_directoryCache.ClearDirectory(url.GetWithoutFilename());
}
} // namespace
std::unique_ptr<CTexture> VIDEO::CVideoGeneratedImageFileLoader::Load(
const std::string& specialType, const std::string& filePath, unsigned int, unsigned int) const
{
if (!CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(
CSettings::SETTING_MYVIDEOS_EXTRACTTHUMB))
{
return {};
}
CFileItem item{filePath, false};
if (URIUtils::IsInRAR(filePath))
SetupRarOptions(item, filePath);
return CDVDFileInfo::ExtractThumbToTexture(item);
}
|