Mercurial > minori
view src/track/media.cc @ 181:d26cd2c00270
dep/animia/fd/proc: use constexpr std::string_view for proc location
this is probably a little slower, but it works Well Enough for what we need it for
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Mon, 04 Dec 2023 12:14:30 -0500 |
parents | 03b444cbe55f |
children | 649786bae914 |
line wrap: on
line source
#include "track/media.h" #include "track/constants.h" #include "animia.h" #include "anitomy/anitomy.h" #include "core/filesystem.h" #include "core/strings.h" #include "core/session.h" #include <string> #include <unordered_map> #include <vector> #include <filesystem> #include <QFile> #include <QTextStream> namespace Track { namespace Media { static bool GetCurrentlyPlayingResults(std::vector<animia::Result>& results) { std::vector<animia::Player> players; players.reserve(session.config.recognition.players.size()); for (const auto& [enabled, player] : session.config.recognition.players) if (enabled && player.type == animia::PlayerType::Default) players.push_back(player); if (!animia::GetResults(players, results)) return false; return true; } /* meh */ bool GetCurrentlyPlaying(std::vector<std::string>& vec) { std::vector<animia::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) { switch (info.type) { case animia::MediaInfoType::File: case animia::MediaInfoType::Title: vec.push_back(std::filesystem::path(info.value).filename().string()); success |= true; default: break; } } } } return success; } } // namespace Media } // namespace Track