Skip to content
Snippets Groups Projects
Commit ff4f9700 authored by Daniel Quinn's avatar Daniel Quinn :maple_leaf:
Browse files

Merge branch 'release/0.2.1-Bajoran'

parents db35a358 981b69cc
No related branches found
No related tags found
No related merge requests found
# Change Log
## 0.2.1 (Bajoran)
* Added this file
* Fixed the handling of a race condition when Mycroft sends a `stop` signal
over the message bus for one service and a `play` signal for another one.
* Added a click event to auto-play Netflix streams.
* Added some more debugging information
## 0.2.0 (Bajoran)
* Switch to Firefox for the browser actions. I was never happy depending on
Google tech for a Free software project, and since we're using Firefox's
bookmarks anyway, this only made sense.
* Drop the use of environment variables in favour of `/etc/mycroft.yml`.
* Update dependencies.
## 0.1.1 (Andorian)
* Cosmetic updates for PyPI
## 0.1.0 (Andorian)
* Initial release
......@@ -60,9 +60,10 @@ standard settings UI at [home.mycroft.ai](https://home.mycroft.ai/). That's
where, for example, you input your YouTube API key and Utelly API key.
Majel is configured by way of a single config file you place in
`/etc/majel.yml`. Simply copy the example file from the root of this project
as a starting point and edit the values in there to fit your preference. Full
details on what values do what are in the example file.
`/etc/majel.yml`. Simply copy the [example file](https://gitlab.com/danielquinn/majel/-/blob/develop/majel.yml.example)
from the root of this project as a starting point and edit the values in there
to fit your preference. Full details on what values do what are in the example
file.
## What's Next?
......
from pathlib import Path
from shutil import which
from time import sleep
from typing import Dict, List, Type, Union
from mycroft_bus_client import Message
......@@ -100,17 +101,27 @@ class BrowserAction(Action):
it. If it says it can, return an instance of that handler.
"""
for handler in self.get_handlers():
self.logger.info("Checking if %s can handle %s", handler, payload)
name = handler.__class__.__name__
self.logger.info("Checking if %s can handle %s", name, payload)
if handler := handler.build_from_payload(self.driver, payload):
self.logger.info("OK: %s can handle %s", handler, payload)
self.logger.info("OK: %s can handle %s", name, payload)
return handler
def handle_single(self, message: Message) -> None:
# Force a wait to work around a race condition where Mycroft sends both
# a stop event and a play event at roughly the same time.
sleep(1)
self.logger.info(str(message.data))
handler = self.get_handler(message.data.get("url"))
self.is_noisy = handler.handle()
def handle_multiple(self, message: Message) -> None:
# See .handle_single() for details.
sleep(1)
handler = SelectionHandler(self.driver, message.data.get("urls"))
self.is_noisy = handler.handle()
......
......@@ -11,3 +11,6 @@ class NetflixHandler(Handler):
def get_prepared_url(self) -> str:
return f"https://www.netflix.com/watch/{self.payload[30:]}"
def post_fetch(self):
self._click(".nf-big-play-pause > button:nth-child(1)")
......@@ -11,7 +11,6 @@ from .logger import Loggable
class Majel(Loggable):
def __init__(self) -> None:
self.client = MessageBusClient()
self.actions = [a() for a in Action.__subclasses__()]
......@@ -20,6 +19,12 @@ class Majel(Loggable):
for action in self.actions:
for type_, fn in action.get_message_types().items():
self.logger.info(
"Registering %s to %s.%s",
type_,
action.__class__.__name__,
fn.__name__,
)
self.client.on(type_, fn)
self.client.run_forever()
......
[tool.poetry]
name = "majel"
version = "0.2.0"
version = "0.2.1"
description = "A front-end for Mycroft that allows you to do cool things like stream video or surf the web."
authors = ["Daniel Quinn <code@danielquinn.org>"]
license = "AGPL-3.0-or-later"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment