Skip to content

[python] Need help with building a metadata script. #276

Answered by dharmx
dharmx asked this question in Q&A
Discussion options

You must be logged in to vote

Solved. Forgot about this.

#!/usr/bin/env --split-string=python -u

import json
import os
import pathlib
import shutil
import subprocess

import gi
gi.require_version("Playerctl", "2.0")
from gi.repository import GLib, Playerctl
import requests


def on_metadata(*args):
    # sourcery skip: identity-comprehension, remove-redundant-constructor-in-dict-union
    metadata = {
        "mpris:artUrl": default_cover,
        "xesam:artist": "Unknown",
        "xesam:title": "Unknown",
        "xesam:album": "Unknown",
        "status": "Stopped",
    } | {key: val for key, val in dict(args[1]).items() if val}
    name = args[0].props.player_name
    metadata["player"] = name or "none"
    metadata

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dharmx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant