| 1 |
/* |
| 2 |
* Copyright (C) 2023 Team Kodi |
| 3 |
* This file is part of Kodi - https://kodi.tv |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSES/README.md for more information. |
| 7 |
*/ |
| 8 |
|
| 9 |
#include "VideoTagExtractionHelper.h" |
| 10 |
|
| 11 |
#include "FileItem.h" |
| 12 |
#include "ServiceBroker.h" |
| 13 |
#include "TextureDatabase.h" |
| 14 |
#include "settings/Settings.h" |
| 15 |
#include "settings/SettingsComponent.h" |
| 16 |
#include "utils/URIUtils.h" |
| 17 |
#include "video/VideoInfoTag.h" |
| 18 |
#include "video/tags/VideoTagLoaderFFmpeg.h" |
| 19 |
|
| 20 |
using namespace VIDEO::TAGS; |
| 21 |
|
| 22 |
bool CVideoTagExtractionHelper::IsExtractionSupportedFor(const CFileItem& item) |
| 23 |
{ |
| 24 |
return CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool( |
| 25 |
CSettings::SETTING_MYVIDEOS_USETAGS) && |
| 26 |
URIUtils::HasExtension(item.GetDynPath(), ".mkv|.mp4|.avi|.m4v"); |
| 27 |
} |
| 28 |
|
| 29 |
std::string CVideoTagExtractionHelper::ExtractEmbeddedArtFor(const CFileItem& item, |
| 30 |
const std::string& artType) |
| 31 |
{ |
| 32 |
CVideoTagLoaderFFmpeg loader(item, nullptr, false); |
| 33 |
CVideoInfoTag tag; |
| 34 |
loader.Load(tag, false, nullptr); |
| 35 |
for (const auto& it : tag.m_coverArt) |
| 36 |
{ |
| 37 |
if (it.m_type == artType) |
| 38 |
return CTextureUtils::GetWrappedImageURL(item.GetDynPath(), "video_" + artType); |
| 39 |
} |
| 40 |
return {}; |
| 41 |
} |