Skip to content

Commit

Permalink
Progress, not complete yet
Browse files Browse the repository at this point in the history
- Better handling of events
- Removed commented code
- Distinct handler for AVTransport
- Add subscriptions to other available services
- Avoid some string duplication
  • Loading branch information
GioF71 committed Dec 22, 2024
1 parent 4a2d4f7 commit c87a754
Show file tree
Hide file tree
Showing 6 changed files with 243 additions and 69 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ LAST_FM_PASSWORD_HASH|Your LAST.fm account password encoded using md5
LAST_FM_PASSWORD|Your LAST.fm account password in clear text, used when LAST_FM_PASSWORD_HASH is not provided
ENABLE_NOW_PLAYING|Update `now playing` information if set to `yes` (default)
DURATION_THRESHOLD|Minimum duration required from scrobbling (unless at least half of the duration has elapsed), defaults to `240`
DUMP_UPNP_DATA|Additional logging for UPnP data, defaults to `no`
DUMP_EVENT_KEYS|Dump keys from each event keys, defaults to `no`
DUMP_EVENT_KEY_VALUES|Dump data from each event keys, defaults to `no`

## Running

Expand Down
12 changes: 12 additions & 0 deletions upnp_scrobbler/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ def get_dump_upnp_data() -> bool:
default_value=constants.DEFAULT_DUMP_UPNP_DATA)


def get_dump_event_keys() -> bool:
return get_bool_config(
env_key="DUMP_EVENT_KEYS",
default_value=constants.DEFAULT_DUMP_EVENT_KEYS)


def get_dump_event_key_values() -> bool:
return get_bool_config(
env_key="DUMP_EVENT_KEY_VALUES",
default_value=constants.DEFAULT_DUMP_EVENT_KEY_VALUES)


def get_duration_threshold() -> int:
duration_cfg: str = os.getenv("DURATION_THRESHOLD")
if not duration_cfg: return constants.DEFAULT_DURATION_THRESHOLD
Expand Down
2 changes: 2 additions & 0 deletions upnp_scrobbler/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
DEFAULT_DURATION_THRESHOLD: int = 240
DEFAULT_DUMP_UPNP_DATA: bool = False
DEFAULT_DUMP_EVENT_KEYS: bool = False
DEFAULT_DUMP_EVENT_KEY_VALUES: bool = False
DEFAULT_ENABLE_NOW_PLAYING: bool = True

# we accept new scrobbles for the same song after (seconds) ...
Expand Down
2 changes: 2 additions & 0 deletions upnp_scrobbler/event_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ class EventName(Enum):
CURRENT_TRACK_META_DATA = "CurrentTrackMetaData"
AV_TRANSPORT_URI_META_DATA = "AVTransportURIMetaData"
CURRENT_TRACK_URI = "CurrentTrackURI"
AV_TRANSPORT_URI = "AVTransportURI"
LAST_CHANGE = "LastChange"
Loading

0 comments on commit c87a754

Please sign in to comment.