Giter VIP home page Giter VIP logo

anisthesia's Introduction

Anisthesia

Anisthesia is a media detection library for Windows.

  • Detects running media players and web browsers
  • Retrieves information about the currently playing video

Usage

This is a work in progress. Usage in public applications is not yet recommended.

#include <iostream>
#include <vector>
#include <anisthesia.hpp>

int main() {
  std::vector<anisthesia::Player> players;
  if (!anisthesia::ParsePlayersFile("data/players.anisthesia", players)) {
    return 1;
  }

  const auto media_proc = [](const anisthesia::MediaInfo&) {
    return true;  // Accept all media
  };

  std::vector<anisthesia::win::Result> results;
  if (!anisthesia::win::GetResults(players, media_proc, results)) {
    return 1;
  }

  const auto get_type = [](const anisthesia::MediaInfoType& type) {
    switch (type) {
      case anisthesia::MediaInfoType::File: return "File";
      case anisthesia::MediaInfoType::Tab: return "Tab";
      case anisthesia::MediaInfoType::Title: return "Title";
      case anisthesia::MediaInfoType::Url: return "URL";
      default: return "Other";
    }
  };

  for (const auto& result : results) {
    std::cout << result.player.name << '\n';
    for (const auto& media : result.media) {
      for (const auto& information : media.information) {
        std::cout << "\t" << get_type(information.type);
        std::cout << "\t\"" << information.value << "\"\n";
      }
    }
  }

  return 0;
}

License

Licensed under the MIT License.

anisthesia's People

Contributors

erengy avatar snickler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

anisthesia's Issues

Media detection over HTTP

Anisthesia currently has the following strategies for media detection:

  • open_files: Lists files opened by a media player process.
  • window_title: Reads the window title of a media player.
  • ui_automation: Reads the address bar and the tabs of a web browser.

These methods either do not work or are not reliable for some media players/servers such as Plex (erengy/taiga#115), Kodi (erengy/taiga#192), Emby (erengy/taiga#268, erengy/taiga#1007) and Jellyfin. In order to support them, we need to be able to work with HTTP APIs.

Here lies the problem. Quoting from erengy/taiga#115 (comment):

Anisthesia doesn't have the capabilities to communicate over HTTP, parse JSON/XML documents, etc. C++'s standard library doesn't come with those, embedding them into the library is a bad idea, and I'd rather avoid introducing third-party dependencies...

I see two options:

  1. Introduce dependencies to Anisthesia (e.g. hypr, json, pugixml)
  2. Offload implementation details to applications (e.g. Taiga)

Either way, adding Anisthesia to your project becomes more complicated. For the first option, you would need to compile the dependencies too. For the second option, you would be responsible for handling the HTTP requests, etc.

The first option is probably easier for me personally, since I'd just use the same libraries for both Anisthesia and Taiga. But I'm not sure which one would be the best choice overall.

Lag when multiple Firefox instances are running

Hello there,

there's a noticable lag when using Taiga[1], with streaming recognition enabled, while running ~10 Firefox processes. Chrome does not appear to cause the same issue.
It seems to be in win_ui_automation.cpp where a WinRT transform error is thrown with "No such interface supported". Meanwhile a handle named \Sessions\1\BaseNamedObjects\HOOK_SHMEM_00000000_0000777c_00000070_0000606c respawns every few seconds.

This can be reproduced easily by running Taiga (atm 746d87d2) and opening a few Firefox windows.

[1] I'd provide a minimal working example but my C++ knowledge is limited.

Web browsers

Supported

Web browser Tested version
Brave Browser 0.60.45 (64-bit)
Google Chrome 60.0.3112.78 (64-bit)
Internet Explorer 11.483.15063.0 (64-bit)
LibreWolf 122.0-2
Microsoft Edge 79.0.309.65 (64-bit)
Mozilla Firefox 55.0b12 (64-bit)
Opera 46.0.2597.57
Waterfox 54.0.1 (64-bit)

Not supported

Web browser Tested version Comments
Microsoft Edge 40.15063.0.0 (64-bit) Old version based on EdgeHTML. See #2 (comment).
Opera Neon 1.0.2531.0 Tabs not detectable due to nontraditional design.
Pale Moon 27.4.0 (64-bit) Doesn't expose UIA tree. URL and tabs not detectable.
Vivaldi 1.14.1077.60 Doesn't expose UIA tree. URL and tabs not detectable.

Media players

Supported

Media player Tested version Comments
5KPlayer 4.5 (32-bit)
Ace Player HD 2.2.7 (32-bit) Not recommended.
ALLPlayer 7.3 (32-bit) Not recommended.
Baka MPlayer 2.0.4 (64-bit) Going to be replaced by mochi-player.
BESTplayer 2.131 (32-bit) Discontinued. Only in Polish.
bomi 0.9.11 (64-bit) Discontinued. Find a fork or use mpv instead.
BS.Player 2.71 (32-bit)
DivX Player 10.8.4 (32-bit) Not recommended.
GOM Player 2.3.17.5274 (32-bit) Not recommended.
Kantaris 0.7.9 (32-bit) Not recommended.
KMPlayer 4.2.2.38 (32-bit) Not recommended. Use PotPlayer instead.
KMPlayer 64X 2020.03.24.15 (64-bit) Not recommended. Use MPC-BE or MPC-HC instead.
Kodi 17.3 (32-bit)
Light Alloy 4.10.2 (32-bit)
Media Player Classic 6.4.9.1 (32-bit) Discontinued. Use MPC-BE or MPC-HC instead.
Media Player Classic Qute Theater 18.03 (64-bit)
Miro 6.0 (32-bit) Discontinued.
MPC-BE 1.5.1 (64-bit)
MPC-HC 1.7.13.1 (64-bit)
MPCSTAR 5.4 (32-bit) Discontinued.
MPDN 2.48.0.3603 (64-bit)
mpv 0.26.0 (64-bit)
mpv.net 5.4.2.0 (64-bit)
MV2Player 0.7 RC2 (32-bit) Discontinued.
PotPlayer 1.7.2710 (64-bit)
SMPlayer 21.8.0 (64-bit)
Splash 2.1.0 (32-bit) Not recommended.
SPlayer 3.7 (32-bit) Not recommended.
UMPlayer 0.95 (32-bit) Discontinued. Use SMPlayer instead.
VLC media player 2.2.6 (64-bit)
WebTorrent Desktop 0.18.0 (64-bit)
Winamp 5.666 (32-bit) For audio, use foobar2000 or AIMP instead.
Windows Media Player 12.0.15063.332 (64-bit)
Zoom Player 13.7.1 (32-bit) Not recommended.

Planned

Not supported

Media player Tested version Comments
Movies & TV 10.17062.12910 (64-bit) UWP apps cannot be detected.
Windows Media Center 6.1.7600.16385 (32-bit) Discontinued. In system directory.

Ignore Chrome's "playing audio" string.

While having Taiga recognize me watching on Crunchyroll I encountered one issue. Google Chrome started putting "- playing audio" string to page title everytime page plays audio. The problem is that if there's quite long silence the string goes away from page title and Taiga redetects it as new episode being watched. When silence comes to end, Chrome puts "playing audio" in the page title again and I am getting notified about watching new episode again.

It's not as annoying as it was before as with v1.3 taiga doesn't play sound with the notification anymore, but action center get's kinda spammed.

Detected episode with "playing audio" string in Polish:
2018-04-09 10_21_30-crunchyroll - watch karakai jozu no takagi-san episode 12 - letter _ first day o

Plex media Player recognition

Hello,

I make use of an application (taiga) that makes use of your media detection library. Many users are using Plex as their go-to media player. Kindly ask to include this, since it has been planned since 2017.

Would love to hear from you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.