From c04dcc2e7d834218ef2d4194331e383402495ae1 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 10 Apr 2024 20:07:22 +0200 Subject: Adding upstream version 2:20.4+dfsg. Signed-off-by: Daniel Baumann --- xbmc/filesystem/MusicSearchDirectory.cpp | 52 ++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 xbmc/filesystem/MusicSearchDirectory.cpp (limited to 'xbmc/filesystem/MusicSearchDirectory.cpp') diff --git a/xbmc/filesystem/MusicSearchDirectory.cpp b/xbmc/filesystem/MusicSearchDirectory.cpp new file mode 100644 index 0000000..1d1868a --- /dev/null +++ b/xbmc/filesystem/MusicSearchDirectory.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2005-2018 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 "MusicSearchDirectory.h" + +#include "FileItem.h" +#include "URL.h" +#include "guilib/LocalizeStrings.h" +#include "music/MusicDatabase.h" +#include "utils/log.h" + +using namespace XFILE; + +CMusicSearchDirectory::CMusicSearchDirectory(void) = default; + +CMusicSearchDirectory::~CMusicSearchDirectory(void) = default; + +bool CMusicSearchDirectory::GetDirectory(const CURL& url, CFileItemList &items) +{ + // break up our path + // format is: musicsearch:// + const std::string& search(url.GetHostName()); + + if (search.empty()) + return false; + + // and retrieve the search details + items.SetURL(url); + auto start = std::chrono::steady_clock::now(); + CMusicDatabase db; + db.Open(); + db.Search(search, items); + db.Close(); + + auto end = std::chrono::steady_clock::now(); + auto duration = std::chrono::duration_cast(end - start); + + CLog::Log(LOGDEBUG, "{} ({}) took {} ms", __FUNCTION__, url.GetRedacted(), duration.count()); + + items.SetLabel(g_localizeStrings.Get(137)); // Search + return true; +} + +bool CMusicSearchDirectory::Exists(const CURL& url) +{ + return true; +} -- cgit v1.2.3