From f18d81296bbaa205c0ebff65218419b4f4eb791a Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Thu, 23 Nov 2023 23:27:16 +0100 Subject: [PATCH] Use constant for location providers --- vrobbler/apps/locations/constants.py | 7 +++++++ vrobbler/apps/scrobbles/scrobblers.py | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 vrobbler/apps/locations/constants.py diff --git a/vrobbler/apps/locations/constants.py b/vrobbler/apps/locations/constants.py new file mode 100644 index 0000000..dca9f7b --- /dev/null +++ b/vrobbler/apps/locations/constants.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 +from collections import defaultdict + + +LOCATION_PROVIDERS = defaultdict(lambda: "Unknown") +LOCATION_PROVIDERS["gps"] = "GPS" +LOCATION_PROVIDERS["network"] = "Wifi Triangulation" diff --git a/vrobbler/apps/scrobbles/scrobblers.py b/vrobbler/apps/scrobbles/scrobblers.py index 9cc0b1e..0a358a0 100644 --- a/vrobbler/apps/scrobbles/scrobblers.py +++ b/vrobbler/apps/scrobbles/scrobblers.py @@ -24,6 +24,7 @@ from videogames.howlongtobeat import lookup_game_from_hltb from videogames.models import VideoGame from videos.models import Video from locations.models import GeoLocation, RawGeoLocation +from vrobbler.apps.locations.constants import LOCATION_PROVIDERS logger = logging.getLogger(__name__) @@ -273,7 +274,8 @@ def gpslogger_scrobble_location( } scrobble = Scrobble.create_or_update(location, user_id, extra_data) - provider = f"gps source - {data_dict.get('prov')}" + + provider = f"data source: {LOCATION_PROVIDERS[data_dict.get('prov')]}" if scrobble.notes: scrobble.notes = scrobble.notes + f"\n{provider}" else: