Kodi Documentation 23.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
VideoUtils.cpp File Reference
#include "VideoUtils.h"
#include "FileItem.h"
#include "FileItemList.h"
#include "GUIPassword.h"
#include "InfoScanner.h"
#include "ServiceBroker.h"
#include "URL.h"
#include "Util.h"
#include "filesystem/Directory.h"
#include "filesystem/File.h"
#include "filesystem/StackDirectory.h"
#include "interfaces/AnnouncementManager.h"
#include "media/MediaType.h"
#include "network/NetworkFileItemClassify.h"
#include "playlists/PlayListFileItemClassify.h"
#include "profiles/ProfileManager.h"
#include "settings/AdvancedSettings.h"
#include "settings/SettingUtils.h"
#include "settings/Settings.h"
#include "settings/SettingsComponent.h"
#include "settings/lib/Setting.h"
#include "utils/ArtUtils.h"
#include "utils/Digest.h"
#include "utils/FileExtensionProvider.h"
#include "utils/FileUtils.h"
#include "utils/ItemProperties.h"
#include "utils/StringUtils.h"
#include "utils/URIUtils.h"
#include "utils/Variant.h"
#include "utils/XBMCTinyXML2.h"
#include "utils/log.h"
#include "video/VideoDatabase.h"
#include "video/VideoFileItemClassify.h"
#include "video/VideoInfoTag.h"
#include <algorithm>
#include <array>
#include <chrono>
#include <cstdint>
#include <ranges>
#include <vector>

Namespaces

namespace  KODI
 
namespace  KODI::VIDEO
 
namespace  KODI::VIDEO::UTILS
 

Functions

std::string KODI::VIDEO::UTILS::FindTrailer (const CFileItem &item, KODI::REGEXP::RegExpCache *cache=nullptr)
 Find a local trailer file for a given file item.
 
std::string KODI::VIDEO::UTILS::GetOpticalMediaPath (const CFileItem &item)
 Check whether an item is an optical media folder or its parent. This will return the non-empty path to the playable entry point of the media one or two levels down (VIDEO_TS.IFO for DVDs or index.bdmv for BDs). The returned path will be empty if folder does not meet this criterion.
 
void KODI::VIDEO::UTILS::EnumerateVideoExtras (const std::string &folder, const std::function< void(const std::shared_ptr< CFileItem > &)> &callback)
 Call back for each video in a folder of video extras, and in the folders below it. A disc (BDMV or VIDEO_TS) is one video, its index.bdmv or VIDEO_TS.IFO, however many files it holds. The folder may itself be a disc. A folder below it holding a .nomedia file is skipped.
 
std::string KODI::VIDEO::UTILS::GetFastHash (const std::string &directory, const std::vector< std::string > &excludes)
 Retrieve a "fast" hash of the given directory (if available) Performs a stat() on the directory, and uses modified time to create a "fast" hash of the folder. If no modified time is available, the create time is used, and if neither are available, an empty hash is returned. In case exclude from scan expressions are present, the string array will be appended to the md5 hash to ensure we're doing a re-scan whenever the user modifies those.
 
std::string KODI::VIDEO::UTILS::GetFastHash (const std::vector< std::string > &excludes, int64_t time)
 As above but from an already known raw modification time.
 
int KODI::VIDEO::UTILS::GetPathHash (const CFileItemList &items, std::string &hash)
 Retrieve a hash of a folder's listing, from the names, sizes and dates of its items.
 
bool KODI::VIDEO::UTILS::IsAutoPlayNextItem (const CFileItem &item)
 Check whether auto play next item is set for the media type of the given item.
 
bool KODI::VIDEO::UTILS::IsAutoPlayNextItem (const std::string &content)
 Check whether auto play next item is set for the given content type.
 
bool KODI::VIDEO::UTILS::IsPlotHidden (const CVideoInfoTag &tag)
 Whether the plot of tag is hidden, as the user hides those of unwatched items of its type.
 
void KODI::VIDEO::UTILS::SetEpisodeCounts (CFileItem &item, int total, int watched)
 Set the episode count properties of a show or season item.
 
std::optional< int > KODI::VIDEO::UTILS::GetNextPartFromBookmark (const CBookmark &bookmark)
 Parses a playerState string from a bookmark and returns the next stack part number if available.
 
std::optional< std::tuple< int64_t, unsigned int > > KODI::VIDEO::UTILS::GetStackResumeOffsetAndPartNumber (const CFileItem &item)
 Get the resume offset and part number for the given stack item.
 
int64_t KODI::VIDEO::UTILS::GetStackPartResumeOffset (const CFileItem &item, unsigned int partNumber)
 Get the resume offset for a part of a stack item.
 
int64_t KODI::VIDEO::UTILS::GetStackPartStartOffset (const CFileItem &item, unsigned int partNumber)
 Get the start offset for a part of a stack item.
 
ResumeInformation KODI::VIDEO::UTILS::GetItemResumeInformation (const CFileItem &item)
 Check whether playback of the given item can be resumed, get detailed information.
 
std::shared_ptr< CFileItem > KODI::VIDEO::UTILS::LoadVideoFilesFolderInfo (const CFileItem &folder)
 For a given non-library folder containing video files, load info from the video database.
 
std::string KODI::VIDEO::UTILS::NormaliseEditionName (const std::string &name)
 Reduce an edition name to its lower case words, so that two can be compared regardless of the punctuation and separators a filesystem allows (ex. "Director's Cut" vs "Directors.Cut"). Apostrophes are dropped and every other punctuation character becomes a word separator. Non-ascii characters are otherwise kept, so that a localised name still matches itself. The result is wrapped in spaces, so that a plain substring search only ever matches whole words.
 
std::string KODI::VIDEO::UTILS::FindEditionInName (const std::string &name, const std::vector< std::string > &editions)
 Look for the name of a known edition (ex. "Director's Cut") within a name, usually that of the folder a movie is in. Matching ignores case, punctuation and separators, and only ever matches whole words. The longest match wins, so that "Ultimate Collector's Edition" is preferred over the "Collector's Edition" it contains. A match at the very start of name is ignored, as that is a movie whose title is itself an edition name (ex. "The Final Cut (2004)") rather than a version of some other movie.
 
bool KODI::VIDEO::UTILS::CanSaveDiscPlaylist (const CFileItem &item)
 Whether the playlist chosen for an item can be saved to the library, ie. there is a library record to point at it and the profile is allowed to change it.
 
int KODI::VIDEO::UTILS::SaveDiscPlaylistToLibrary (const CFileItem &item, CVideoDatabase &db)
 Point the library record of a movie or episode at the disc playlist the item now has, replacing the file it was scanned with. The caller owns the database transaction, so that this can be rolled back along with any related change.
 
int KODI::VIDEO::UTILS::SaveDiscPlaylistToLibrary (const CFileItem &item, VideoDbContentType type, int mediaId, CVideoDatabase &db)
 As above, for an item whose library record is not the one in its tag, eg. a video version whose tag holds the version's file id rather than the movie it belongs to.
 
bool KODI::VIDEO::UTILS::SaveDiscPlaylist (CFileItem &item)
 Point the library record at the disc playlist the item now has, in its own transaction.
 
void KODI::VIDEO::UTILS::AnnouncePlayCountChanged (const std::string &file, int playCount)
 Announce a change of a file's play count as Files.OnPlayCountChanged, for any file in or outside the library, so that e.g. the add-on whose plugin item it is can react.
 
void KODI::VIDEO::UTILS::AnnounceResumePointChanged (const std::string &file, const CBookmark &resumePoint)
 Announce a change of a file's resume point as Files.OnResumePointChanged, for any file in or outside the library, so that e.g. the add-on whose plugin item it is can react.