Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6920c99931 | |||
| d2d71b3c85 | |||
| 6300df8e9e | |||
| b427731bc3 |
@ -13,6 +13,7 @@ logger = logging.getLogger(__name__)
|
|||||||
BNULL = {"blank": True, "null": True}
|
BNULL = {"blank": True, "null": True}
|
||||||
User = get_user_model()
|
User = get_user_model()
|
||||||
|
|
||||||
|
ACCURACY = getattr(settings, "GEOLOC_ACCURACY", 3)
|
||||||
|
|
||||||
class GeoLocation(ScrobblableMixin):
|
class GeoLocation(ScrobblableMixin):
|
||||||
COMPLETION_PERCENT = getattr(settings, "LOCATION_COMPLETION_PERCENT", 100)
|
COMPLETION_PERCENT = getattr(settings, "LOCATION_COMPLETION_PERCENT", 100)
|
||||||
@ -53,11 +54,11 @@ class GeoLocation(ScrobblableMixin):
|
|||||||
int_lon, r_lon = str(data_dict.get("lon", "")).split(".")
|
int_lon, r_lon = str(data_dict.get("lon", "")).split(".")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
trunc_lat = r_lat[0:4]
|
trunc_lat = r_lat[0:GEOLOC_ACCURACY]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
trunc_lat = r_lat
|
trunc_lat = r_lat
|
||||||
try:
|
try:
|
||||||
trunc_lon = r_lon[0:4]
|
trunc_lon = r_lon[0:GEOLOC_ACCURACY]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
trunc_lon = r_lon
|
trunc_lon = r_lon
|
||||||
|
|
||||||
@ -65,12 +66,8 @@ class GeoLocation(ScrobblableMixin):
|
|||||||
data_dict["lon"] = float(f"{int_lon}.{trunc_lon}")
|
data_dict["lon"] = float(f"{int_lon}.{trunc_lon}")
|
||||||
|
|
||||||
int_alt, r_alt = str(data_dict.get("alt", "")).split(".")
|
int_alt, r_alt = str(data_dict.get("alt", "")).split(".")
|
||||||
try:
|
|
||||||
trunc_alt = r_lon[0:4]
|
|
||||||
except IndexError:
|
|
||||||
trunc_alt = r_alt
|
|
||||||
|
|
||||||
data_dict["altitude"] = float(f"{int_alt}.{trunc_alt}")
|
data_dict["altitude"] = float(int_alt)
|
||||||
|
|
||||||
location = cls.objects.filter(
|
location = cls.objects.filter(
|
||||||
lat=data_dict.get("lat"),
|
lat=data_dict.get("lat"),
|
||||||
|
|||||||
@ -108,6 +108,9 @@ class ScrobbleAdmin(admin.ModelAdmin):
|
|||||||
"sport_event",
|
"sport_event",
|
||||||
"book",
|
"book",
|
||||||
"video_game",
|
"video_game",
|
||||||
|
"board_game",
|
||||||
|
"geo_location",
|
||||||
|
"webpage",
|
||||||
)
|
)
|
||||||
list_filter = (
|
list_filter = (
|
||||||
"is_paused",
|
"is_paused",
|
||||||
|
|||||||
@ -201,6 +201,8 @@ def manual_scrobble_event(thesportsdb_id: str, user_id: int):
|
|||||||
|
|
||||||
|
|
||||||
def manual_scrobble_video_game(hltb_id: str, user_id: int):
|
def manual_scrobble_video_game(hltb_id: str, user_id: int):
|
||||||
|
game = VideoGame.objects.filter(hltb_id=hltb_id).first()
|
||||||
|
if not game:
|
||||||
data_dict = lookup_game_from_hltb(hltb_id)
|
data_dict = lookup_game_from_hltb(hltb_id)
|
||||||
game = VideoGame.find_or_create(data_dict)
|
game = VideoGame.find_or_create(data_dict)
|
||||||
|
|
||||||
|
|||||||
@ -451,7 +451,7 @@ def scrobble_start(request, uuid):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
user.profile.redirect_on_webpage
|
user.profile.redirect_to_webpage
|
||||||
and media_obj.__class__.__name__ == Scrobble.MediaType.WEBPAGE
|
and media_obj.__class__.__name__ == Scrobble.MediaType.WEBPAGE
|
||||||
):
|
):
|
||||||
logger.info(f"Redirecting to {media_obj} detail apge")
|
logger.info(f"Redirecting to {media_obj} detail apge")
|
||||||
|
|||||||
@ -65,6 +65,7 @@ LASTFM_API_KEY = os.getenv("VROBBLER_LASTFM_API_KEY")
|
|||||||
LASTFM_SECRET_KEY = os.getenv("VROBBLER_LASTFM_SECRET_KEY")
|
LASTFM_SECRET_KEY = os.getenv("VROBBLER_LASTFM_SECRET_KEY")
|
||||||
IGDB_CLIENT_ID = os.getenv("VROBBLER_IGDB_CLIENT_ID")
|
IGDB_CLIENT_ID = os.getenv("VROBBLER_IGDB_CLIENT_ID")
|
||||||
IGDB_CLIENT_SECRET = os.getenv("VROBBLER_IGDB_CLIENT_SECRET")
|
IGDB_CLIENT_SECRET = os.getenv("VROBBLER_IGDB_CLIENT_SECRET")
|
||||||
|
GEOLOC_ACCURACY = os.getenv("VROBBLER_GEOLOC_ACCURACY", 3)
|
||||||
|
|
||||||
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user