Skip to content

Update#77

Open
thomasm789 wants to merge 51 commits intounfoldedcircle:mainfrom
thomasm789:main
Open

Update#77
thomasm789 wants to merge 51 commits intounfoldedcircle:mainfrom
thomasm789:main

Conversation

@thomasm789
Copy link
Contributor

  • Application Lists (using presets and adb), introduces ADB for the first time so could be extended in the future.
  • Send text using commands via simple cmds
  • Centralised Media update Metadata Handling

Known issue

  • Chromecast timing metadata needed to be triggered separately to the title and media image.

@zehnm zehnm self-requested a review May 28, 2025 09:20
Copy link
Contributor

@zehnm zehnm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry for the delayed review.
This is just an initial quick code review and I'll start testing this afternoon.
The simple-justwatch-python-api library needs to be replaced or removed, otherwise we can't include the integration in our firmware due to licensing concerns.
GPLv3 grants the user the right to modify and replace the software, which get's complicated in our embedded firmware with a read-only filesystem. We do have the "custom integration installation" option, but that doesn't technically modify the existing software.
That's why I prefer to play it safe.

sanitize-filename~=1.2.0
async_timeout~=5.0.1
adb_shell==0.4.4
simple-justwatch-python-api>=0.16 No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The https://github.com/Electronic-Mango/simple-justwatch-python-api library is licensed under GPLv3. Unfortunately we cannot include this in our device firmware.
Please either remove it or replace it with another library licensed under BSD, MIT, Apache-2.0 or MPL-2.0

Comment on lines +23 to +29
def _get_config_root() -> Path:
config_home = Path(os.environ.get("UC_CONFIG_HOME", "./config"))
config_home.mkdir(parents=True, exist_ok=True)
return config_home


def _get_data_root() -> Path:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exported functions should not be prefixed with _, they are intended for internal use.

_single_leading_underscore: weak "internal use" indicator. E.g. from M import * does not import objects whose name starts with an underscore.

Comment on lines +111 to +159
# async def encode_icon_to_data_uri(icon_name: str) -> str:
# """
# Encode an image from a local file path or remote URL.
#
# Returns a base64-encoded PNG data URI.
# """
# if isinstance(icon_name, MediaImage):
# icon_name = icon_name.url
#
# if isinstance(icon_name, str) and icon_name.startswith("data:image"):
# _LOG.debug("Icon is already a data URI")
# return icon_name
#
# _LOG.debug("Encoding icon to data URI: %s", icon_name)
# try:
# if _is_url(icon_name):
# async with httpx.AsyncClient() as client:
# response = await client.get(icon_name, timeout=10)
# response.raise_for_status()
# img_bytes = BytesIO(response.content)
#
# def encode_image() -> str:
# img = Image.open(img_bytes)
# img = img.convert("RGBA")
# buffer = BytesIO()
# img.save(buffer, format="PNG")
# encoded = base64.b64encode(buffer.getvalue()).decode("utf-8")
# return f"data:image/png;base64,{encoded}"
#
# return await asyncio.to_thread(encode_image)
#
# def load_and_encode() -> str:
# icon_path = _get_icon_path(icon_name)
# if not icon_path.exists():
# raise FileNotFoundError(f"Icon not found: {icon_name}")
# with open(icon_path, "rb") as f:
# img = Image.open(f)
# img.load()
# img = img.convert("RGBA")
# buffer = BytesIO()
# img.save(buffer, format="PNG")
# encoded = base64.b64encode(buffer.getvalue()).decode("utf-8")
# return f"data:image/png;base64,{encoded}"
#
# return await asyncio.to_thread(load_and_encode)
#
# except Exception as e:
# _LOG.warning("Failed to encode icon to base64 for %s: %s", icon_name, e)
# return ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove commented out code blocks, unless they are used "real soon" and with a comment about the intention.

Comment on lines +301 to +307
adb_cert_path = Path(os.environ.get("UC_CONFIG_HOME", "./config")) / "certs" / f"adb_{choice}"
adb_cert_path_pub = Path(os.environ.get("UC_CONFIG_HOME", "./config")) / "certs" / f"adb_{choice}.pub"
if adb_cert_path.exists():
adb_cert_path.unlink()
if adb_cert_path_pub.exists():
adb_cert_path_pub.unlink()
appslist_path = Path(os.environ.get("UC_CONFIG_HOME", "./config")) / f"appslist_{choice}.json"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the already imported get_config_root() function to get the configuration path to avoid duplicating logic.

from adb_shell.auth.keygen import keygen
from adb_shell.auth.sign_pythonrsa import PythonRSASigner

ADB_CERTS_DIR = Path(os.environ.get("UC_CONFIG_HOME", "./config")) / "certs"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the defined get_config_root() function in config.py to get the configuration path to avoid duplicating logic.

@thomasm789
Copy link
Contributor Author

thomasm789 commented May 28, 2025

Sure. Was using this package for the purposes of sourcing media artwork for idenfied media playing when chromecast is enabled, specifically media that wasn't YouTube or natively provided via Chromecast. Do you have any suggested alternatives? There appears to be https://github.com/dawoudt/JustWatchAPI which is MIT and provides similar methods so would be an easy swap out.

I haven't had an opportunity to do a clean up so there's some approaches that need to be refactored. But due to other commitments I haven't had time to review and make further contributions. I might have some time later next week. But any edits are welcome.

@zehnm
Copy link
Contributor

zehnm commented May 28, 2025

No worries, I can push some linting fixes and disable the package.
According to an open issue the mentioned JustWatchAPI doesn't work anymore, but there are few suggestions in the comments. I'll check, maybe we can use something.

Run isort, black etc and a few manual fixes.
There are still a few Pylint issues left that need to be addressed after
testing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants