Commit Graph

215 Commits

Author SHA1 Message Date
Fabio Manganiello 59c693d6a0
[#394] All `manifest.yaml` converted to `manifest.json`.
YAML isn't part of the Python standard library, while JSON is.

If we want `setup.py` to dynamically parse the available integration
manifest files in order to populate the extra dependencies, then it's
better to rely on a JSON format for manifest files - the parser is part
of the standard library and it doesn't require the user to install
`pyyaml` before `platypush`.
2024-05-17 02:21:57 +02:00
Fabio Manganiello e123463804
[media.chromecast] Refactored implementation.
continuous-integration/drone/push Build is passing Details
Explicitly use a `CastBrowser` object initialized at plugin boot instead
of relying on blocking calls to `pychromecast.get_chromecasts`.

1. It enables better event handling via callbacks instead of
   synchronously waiting for scan batches.

2. It optimizes resources - only one Zeroconf and one CastBrowser object
   will be created in the plugin, and destroyed upon stop.

3. No need for separate `get_chromecast`/`_refresh_chromecasts` methods:
   all the scanning is run continuously, so we can just return the
   results from the maps.
2024-04-17 03:56:45 +02:00
Fabio Manganiello f99f6bdab9
[media.chromecast] Resource clean up + new API adaptations.
continuous-integration/drone/push Build is passing Details
- `pychromecast.get_chromecasts` returns both a list of devices and a
  browser object. Since the Chromecast plugin is the most likely culprit
  of the excessive number of open MDNS sockets, it seems that we may
  need to explicitly stop discovery on the browser and close the
  ZeroConf object after the discovery is done.

- I was still using an ancient version of pychromecast on my RPi4, and I
  didn't notice that more recent versions implemented several breaking
  changes. Adapted the code to cope with those changes.
2024-04-17 02:49:31 +02:00
Fabio Manganiello 33d4c8342d
[#389] Possible fix for "Too many open files" media issue.
continuous-integration/drone/push Build is passing Details
It seems that the process keeps a lot of open connections to Chromecast
devices during playback.

The most likely culprit is the `_refresh_chromecasts` logic.

We should start a `cast` object and register a status listener only if a
Chromecast with the same identifier isn't already registered in the
plugin.
2024-04-15 23:01:10 +02:00
Fabio Manganiello 998b7be7b8
[media.vlc] Always add `--play-and-exit` to args.
continuous-integration/drone/push Build is passing Details
Without this option VLC seems to hang in the background, and it may
cause PulseAudio failures or memory issues after several videos have
been played - each in its own session.
2024-01-18 21:21:15 +01:00
Fabio Manganiello 1c5956c38b
Fixed some docstring warnings.
continuous-integration/drone/push Build was killed Details
2024-01-18 00:26:22 +01:00
Fabio Manganiello e9d91471ce
[media.mplayer] Plugin rewrite.
continuous-integration/drone/push Build is passing Details
Too many things were falling apart, and many others of MPlayer's "API
smells" had never been addressed.

The plugin has now largely been rewritten, and some workarounds (like
accessory monitoring processes) have been added to deal with the fact
that events like end-of-file aren't published by the player, and some
polling is required.
2024-01-16 00:41:01 +01:00
Fabio Manganiello 6fe1ed44ad
[media] Fixed base interface of `media.seek` and `media.set_position`. 2024-01-13 22:39:33 +01:00
Fabio Manganiello cf314f2615
[mpv] Refactored plugin.
I hadn't paid attention to this plugin in a while and the newest mpv API
has diverged so much that it was entirely incompatible with recent mpv
versions.
2024-01-13 22:36:42 +01:00
Fabio Manganiello 641a2fd135
Renamed parameter of `volup`/`voldown` for music plugins.
To be consistent with all other media plugins, the parameter name should
be `step`, not `delta`.

A back-compatibility layer has however been introduced for plugins
(namely `music.mpd` and `music.spotify`) that already exposed the old
interface.
2024-01-13 22:35:18 +01:00
Fabio Manganiello 52fd64a162
[alarm] Added `dismiss_interval` configuration. 2023-12-18 03:01:27 +01:00
Fabio Manganiello 2670d40094
Added `get_default_media_plugin` utility. 2023-12-06 01:31:05 +01:00
Fabio Manganiello fdaff32cd0
Fixed docstring for `chromecast.status`.
continuous-integration/drone/push Build is failing Details
2023-11-18 14:17:17 +01:00
Fabio Manganiello 7bb08bca07
[joystick] Rewritten `joystick` integration as a plugin.
continuous-integration/drone/push Build is passing Details
And removed legacy `joystick*` backends and `inputs` plugin.

Closes: #290
2023-11-16 21:43:56 +01:00
Fabio Manganiello 724f625963
[`media.chromecast`] Skip errors on `cast.wait`.
It may be that the cast thread has been recycled and it's already been
awaited. It's safe to skip the error in these cases.
2023-11-12 15:52:31 +01:00
Fabio Manganiello 1f321c32dc
[`media.chromecast`] Full plugin rewrite.
continuous-integration/drone/push Build is failing Details
2023-11-12 03:08:54 +01:00
Fabio Manganiello 52ee614ec4
[`media`] Added logic to parse local media metadata.
continuous-integration/drone/push Build is failing Details
2023-11-09 02:47:34 +01:00
Fabio Manganiello eb7a96ee94
[`youtube`] Added more metadata fields to search results. 2023-11-09 02:47:32 +01:00
Fabio Manganiello e7bd61e0d4
Black/LINT for Jellyfin plugin. 2023-11-07 00:45:45 +01:00
Fabio Manganiello 1d41df51e7
[`media`] Extended current track with ytdl metadata if available. 2023-11-07 00:45:44 +01:00
Fabio Manganiello 27da2becd7
[`media`] Added `media.get_info` action.
It combines the `-j` and `-g` options of ytdl* to get both the stream
URL and the track metadata.
2023-11-06 02:25:35 +01:00
Fabio Manganiello 71bca662a1
`media.play` should support anything supported by a yt_dlp extractor.
continuous-integration/drone/push Build is passing Details
2023-11-05 02:40:38 +01:00
Fabio Manganiello 2b12984c81
[`youtube`] Full plugin rewrite.
continuous-integration/drone/push Build is failing Details
Instead of relying on the official Google YouTube API (limited, subject
to breaking changes with short/no notice depending on Google's strategy
against scrapers, and with an initial setup that has a high cost), we'll
just stick to Piped from now on.

It's free, it doesn't require API keys, it's unlikely to change, it's
not subject to Google's hostile practices against developers, and
anybody can run an instance.
2023-11-04 12:11:44 +01:00
Fabio Manganiello 44d4ae2a96
[`media`] Made the `youtube-dl` executable configurable.
`youtube-dl` is mostly dead and there are several forks available, thus
we need to give the user the ability to pick which `youtube-dl`
executable fork they want to use.

Among these, `yt-dlp` is probably the most maintained today and it's
also included in many default repos, so it's been added as an extra
requirement for all the media plugins.

Closes: #268
2023-11-04 11:57:09 +01:00
Fabio Manganiello b4bf30945a
[`media`] Black/LINT for `MediaPlugin`. 2023-11-04 00:50:08 +01:00
Fabio Manganiello ba5d505c9b [`youtube`] Black/LINT pass. 2023-11-03 20:54:46 +00:00
Fabio Manganiello ef3b1d20f2 Updated `MediaPlugin` documentation snippet. 2023-10-31 00:44:05 +00:00
Fabio Manganiello 1e93af86f4
Fixed some broken docstring references.
continuous-integration/drone/push Build is passing Details
2023-10-09 01:33:45 +02:00
Fabio Manganiello 3086dd86fc
LINT+Black+stability fixes for some plugins that hadn't been touched in a while.
continuous-integration/drone/push Build is passing Details
- media.mplayer
- media.omxplayer
- media.vlc
- music.mpd
- music.snapcast
2023-10-01 22:55:06 +02:00
Fabio Manganiello c3337ccc6c
[#311] Docs deps autogen sphinx plugin.
continuous-integration/drone/push Build is passing Details
Added an `add_dependencies` plugin to the Sphinx build process that
parses the manifest files of the scanned backends and plugins and
automatically generates the documentation for the required dependencies
and triggered events.

This means that those dependencies are no longer required to be listed
in the docstring of the class itself.

Also in this commit:

- Black/LINT for some integrations that hadn't been touched in a long
  time.

- Deleted some leftovers from previous refactors (deprecated
  `backend.mqtt`, `backend.zwave.mqtt`, `backend.http.request.rss`).

- Deleted deprecated `inotify` backend - replaced by `file.monitor` (see
  #289).
2023-09-24 17:00:08 +02:00
Fabio Manganiello 761f2768cb
[#316] Added RPM dependencies.
continuous-integration/drone/push Build is passing Details
2023-09-21 23:20:06 +02:00
Fabio Manganiello 98e9abde18
Extended manifest files with Python system packages (if available).
continuous-integration/drone/push Build is passing Details
- If a Python optional dependency is available as a system package on
  the target system, try and install it that route rather than pip. It's
  usually faster and it decreases the risk of breaking system packages.

- Added support for apk dependencies in manifest files. This brings the
  number of distros officially supported by all the extensions to four:

  - Alpine
  - Arch
  - Debian
  - Ubuntu
2023-08-16 22:43:51 +02:00
Fabio Manganiello 56dc8d0972
Migrated the webapp to Tornado.
It was just too painful to find a combination of versions of  gunicorn,
gevent, eventlet, pyuwsgi etc. that could work on all of my systems.

On the other hand, Tornado works out of the box with no headaches.

Also in this commit:

- Updated a bunch of outdated/required integration dependencies.
- Black'd and LINTed a couple of old plugins.
2023-05-08 02:06:45 +02:00
Fabio Manganiello d33d760361
Better way to import `declarative_base` from SQLAlchemy.
Import `declarative_base` in a way that is compatible with any
SQLAlchemy version between 1.3 and 2.x.
2023-04-24 23:23:55 +02:00
Fabio Manganiello 2cc80e7f16
Merge branch 'master' into 191-support-for-general-entities-backend-and-plugin 2022-10-07 00:05:54 +02:00
Fabio Manganiello fef7aff245
LINT fixes for mpv plugin 2022-09-30 10:41:56 +02:00
Fabio Manganiello 8a70f1d38e
Replaced deprecated sqlalchemy.ext.declarative with sqlalchemy.orm 2022-04-05 22:47:44 +02:00
Fabio Manganiello fdf6d8fb4e
Better auto-generated documentation and fixed docstring warnings 2022-03-03 20:26:25 +01:00
Fabio Manganiello 0d0797a465
Added Jellyfin integration 2022-03-01 01:32:50 +01:00
Fabio Manganiello 20fc3d91fc
Updated Chromecast plugin to work with pychromecast >= 10.0
pychromecast 10.0 introduced some [breaking changes](https://github.com/home-assistant-libs/pychromecast/pull/556/files)
in the declaration of the Chromecast object -
namely, the `device` attribute has been renamed to
`cast_info`. The code of ChromecastPlugin has been
updated to guarantee compatibility in both cases.
2021-12-11 22:14:47 +01:00
Fabio Manganiello 2560bfa03f
Plex searcher extended to include also audio tracks 2021-12-04 00:08:47 +01:00
Fabio Manganiello 46d8d575ba
Handle and log media workers search errors 2021-12-03 21:54:41 +01:00
Fabio Manganiello 1906876969
FIX: Replaced VLC event.u occurrences
Newer versions of python-vlc have apparently
removed the `event.u` union object from the
events dispatched by the player, resulting in
player callback failures.

The occurrences of `event.u` have therefore
been replaced with the player methods to
correctly retrieve the current state.
2021-10-17 17:56:57 +02:00
Fabio Manganiello f9ce03919b
FIX: Various omxplayer fixes
- Better synchronization with the player upon `play` request - wait until the play started event is received before returning the status

- DBus exceptions should be caught and handled in the status call
2021-10-17 16:54:57 +02:00
Fabio Manganiello c3681e7b2a
FIX: Don't try and set the volume of the omxplayer when the instance may not be ready yet 2021-10-17 16:38:38 +02:00
Fabio Manganiello 144700b693
media.mpv should send MediaPlayRequestEvent with player and plugin parameters 2021-10-17 16:17:20 +02:00
Fabio Manganiello 4a5bb766af
Fixed some media plugins inconsistencies
- Removed replication of logic between media.get_youtube_url (action) and media.get_youtube_video_url (internal method)

- Added differentiation between MediaPlayEvent and MediaResumeEvent
2021-10-17 16:03:57 +02:00
Fabio Manganiello 8c339d0d55
Added support for custom YouTube preferred video/audio formats 2021-10-17 02:53:38 +02:00
Fabio Manganiello f147c44a8a Fixed docs issues 2021-09-22 00:19:14 +02:00
Fabio Manganiello 3bfc5b83ef Moved to manifest files for describing plugins and backends and their dependencies 2021-09-16 17:53:40 +02:00