Mercurial > minori
diff src/track/media.cc @ 301:b1f625b0227c
*: convert all files CRLF -> LF
some files were in DOS format, others were in unix. now everything
(that at least is under our control) should all be the same format
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Mon, 13 May 2024 15:04:51 -0400 |
parents | 657fda1b9cac |
children | b1f4d1867ab1 |
line wrap: on
line diff
--- a/src/track/media.cc Mon May 13 14:56:37 2024 -0400 +++ b/src/track/media.cc Mon May 13 15:04:51 2024 -0400 @@ -1,65 +1,65 @@ -#include "track/media.h" -#include "core/filesystem.h" -#include "core/session.h" -#include "core/strings.h" - -#include <QFile> -#include <QTextStream> - -#include <filesystem> -#include <string> -#include <unordered_map> -#include <vector> - -#include <iostream> - -#include "animone.h" - -namespace Track { -namespace Media { - -static bool GetCurrentlyPlayingResults(std::vector<animone::Result>& results) { - std::vector<animone::Player> players; - - players.reserve(session.config.recognition.players.size()); - for (const auto& [enabled, player] : session.config.recognition.players) - if (enabled && player.type == animone::PlayerType::Default) - players.push_back(player); - - return animone::GetResults(players, results); -} - -/* meh */ -bool GetCurrentlyPlaying(std::vector<std::string>& vec) { - std::vector<animone::Result> results; - - if (!GetCurrentlyPlayingResults(results)) - return false; - - bool success = false; - - for (const auto& result : results) { - for (const auto& media : result.media) { - for (const auto& info : media.information) { - std::cout << info.value << std::endl; - - switch (info.type) { - case animone::MediaInfoType::File: - vec.push_back(std::filesystem::path(info.value).filename().u8string()); - success |= true; - break; - case animone::MediaInfoType::Title: - vec.push_back(info.value); - success |= true; - break; - default: break; - } - } - } - } - - return success; -} - -} // namespace Media -} // namespace Track +#include "track/media.h" +#include "core/filesystem.h" +#include "core/session.h" +#include "core/strings.h" + +#include <QFile> +#include <QTextStream> + +#include <filesystem> +#include <string> +#include <unordered_map> +#include <vector> + +#include <iostream> + +#include "animone.h" + +namespace Track { +namespace Media { + +static bool GetCurrentlyPlayingResults(std::vector<animone::Result>& results) { + std::vector<animone::Player> players; + + players.reserve(session.config.recognition.players.size()); + for (const auto& [enabled, player] : session.config.recognition.players) + if (enabled && player.type == animone::PlayerType::Default) + players.push_back(player); + + return animone::GetResults(players, results); +} + +/* meh */ +bool GetCurrentlyPlaying(std::vector<std::string>& vec) { + std::vector<animone::Result> results; + + if (!GetCurrentlyPlayingResults(results)) + return false; + + bool success = false; + + for (const auto& result : results) { + for (const auto& media : result.media) { + for (const auto& info : media.information) { + std::cout << info.value << std::endl; + + switch (info.type) { + case animone::MediaInfoType::File: + vec.push_back(std::filesystem::path(info.value).filename().u8string()); + success |= true; + break; + case animone::MediaInfoType::Title: + vec.push_back(info.value); + success |= true; + break; + default: break; + } + } + } + } + + return success; +} + +} // namespace Media +} // namespace Track