Use constant for location providers

This commit is contained in:
2023-11-23 23:27:16 +01:00
parent e86d8cc9fe
commit f18d81296b
2 changed files with 10 additions and 1 deletions

View File

@ -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"

View File

@ -24,6 +24,7 @@ from videogames.howlongtobeat import lookup_game_from_hltb
from videogames.models import VideoGame from videogames.models import VideoGame
from videos.models import Video from videos.models import Video
from locations.models import GeoLocation, RawGeoLocation from locations.models import GeoLocation, RawGeoLocation
from vrobbler.apps.locations.constants import LOCATION_PROVIDERS
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -273,7 +274,8 @@ def gpslogger_scrobble_location(
} }
scrobble = Scrobble.create_or_update(location, user_id, extra_data) 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: if scrobble.notes:
scrobble.notes = scrobble.notes + f"\n{provider}" scrobble.notes = scrobble.notes + f"\n{provider}"
else: else: