[scrobbles] Clean up various sources
This commit is contained in:
@ -167,7 +167,7 @@ def web_scrobbler_scrobble_media(
|
|||||||
|
|
||||||
|
|
||||||
def manual_scrobble_video(
|
def manual_scrobble_video(
|
||||||
video_id: str, user_id: int, action: Optional[str] = None
|
video_id: str, user_id: int, source: str = "IMDb", action: Optional[str] = None
|
||||||
):
|
):
|
||||||
if "tt" in video_id:
|
if "tt" in video_id:
|
||||||
video = Video.get_from_imdb_id(video_id)
|
video = Video.get_from_imdb_id(video_id)
|
||||||
@ -176,7 +176,6 @@ def manual_scrobble_video(
|
|||||||
video = Video.get_from_youtube_id(video_id)
|
video = Video.get_from_youtube_id(video_id)
|
||||||
|
|
||||||
# When manually scrobbling, try finding a source from the series
|
# When manually scrobbling, try finding a source from the series
|
||||||
source = "Vrobbler"
|
|
||||||
if video.tv_series:
|
if video.tv_series:
|
||||||
source = video.tv_series.preferred_source
|
source = video.tv_series.preferred_source
|
||||||
scrobble_dict = {
|
scrobble_dict = {
|
||||||
@ -205,7 +204,7 @@ def manual_scrobble_video(
|
|||||||
|
|
||||||
|
|
||||||
def manual_scrobble_event(
|
def manual_scrobble_event(
|
||||||
thesportsdb_id: str, user_id: int, action: Optional[str] = None
|
thesportsdb_id: str, user_id: int, source: str = "TheSportsDB", action: Optional[str] = None
|
||||||
):
|
):
|
||||||
data_dict = lookup_event_from_thesportsdb(thesportsdb_id)
|
data_dict = lookup_event_from_thesportsdb(thesportsdb_id)
|
||||||
|
|
||||||
@ -220,7 +219,7 @@ def manual_scrobble_event(
|
|||||||
|
|
||||||
|
|
||||||
def manual_scrobble_video_game(
|
def manual_scrobble_video_game(
|
||||||
hltb_id: str, user_id: int, action: Optional[str] = None
|
hltb_id: str, user_id: int, source: str = "HLTB", action: Optional[str] = None
|
||||||
):
|
):
|
||||||
game = VideoGame.objects.filter(hltb_id=hltb_id).first()
|
game = VideoGame.objects.filter(hltb_id=hltb_id).first()
|
||||||
if not game:
|
if not game:
|
||||||
@ -242,7 +241,7 @@ def manual_scrobble_video_game(
|
|||||||
"user_id": user_id,
|
"user_id": user_id,
|
||||||
"timestamp": timezone.now(),
|
"timestamp": timezone.now(),
|
||||||
"playback_position_seconds": 0,
|
"playback_position_seconds": 0,
|
||||||
"source": "Vrobbler",
|
"source": source,
|
||||||
"long_play_complete": False,
|
"long_play_complete": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,10 +259,9 @@ def manual_scrobble_video_game(
|
|||||||
|
|
||||||
|
|
||||||
def manual_scrobble_book(
|
def manual_scrobble_book(
|
||||||
title: str, user_id: int, action: Optional[str] = None
|
title: str, user_id: int, source: str = "Google Books", action: Optional[str] = None
|
||||||
):
|
):
|
||||||
log = {}
|
log = {}
|
||||||
source = "Vrobbler"
|
|
||||||
page = None
|
page = None
|
||||||
url = ""
|
url = ""
|
||||||
|
|
||||||
@ -328,7 +326,7 @@ def manual_scrobble_book(
|
|||||||
|
|
||||||
|
|
||||||
def manual_scrobble_board_game(
|
def manual_scrobble_board_game(
|
||||||
bggeek_id: str, user_id: int, action: Optional[str] = None
|
bggeek_id: str, user_id: int, source: str = "BGG", action: Optional[str] = None
|
||||||
) -> Scrobble | None:
|
) -> Scrobble | None:
|
||||||
boardgame = BoardGame.find_or_create(bggeek_id)
|
boardgame = BoardGame.find_or_create(bggeek_id)
|
||||||
|
|
||||||
@ -340,7 +338,7 @@ def manual_scrobble_board_game(
|
|||||||
"user_id": user_id,
|
"user_id": user_id,
|
||||||
"timestamp": timezone.now(),
|
"timestamp": timezone.now(),
|
||||||
"playback_position_seconds": 0,
|
"playback_position_seconds": 0,
|
||||||
"source": "Vrobbler",
|
"source": source,
|
||||||
}
|
}
|
||||||
logger.info(
|
logger.info(
|
||||||
"[vrobbler-scrobble] board game scrobble request received",
|
"[vrobbler-scrobble] board game scrobble request received",
|
||||||
@ -530,7 +528,7 @@ def email_scrobble_board_game(
|
|||||||
|
|
||||||
|
|
||||||
def manual_scrobble_from_url(
|
def manual_scrobble_from_url(
|
||||||
url: str, user_id: int, action: Optional[str] = None
|
url: str, user_id: int, source: str = "Vrobbler", action: Optional[str] = None
|
||||||
) -> Scrobble:
|
) -> Scrobble:
|
||||||
"""We have scrobblable media URLs, and then any other webpages that
|
"""We have scrobblable media URLs, and then any other webpages that
|
||||||
we want to scrobble as a media type in and of itself. This checks whether
|
we want to scrobble as a media type in and of itself. This checks whether
|
||||||
@ -564,7 +562,7 @@ def manual_scrobble_from_url(
|
|||||||
item_id = "tt" + str(item_id)
|
item_id = "tt" + str(item_id)
|
||||||
|
|
||||||
scrobble_fn = MANUAL_SCROBBLE_FNS[content_key]
|
scrobble_fn = MANUAL_SCROBBLE_FNS[content_key]
|
||||||
return eval(scrobble_fn)(item_id, user_id, action=action)
|
return eval(scrobble_fn)(item_id, user_id, source=source, action=action)
|
||||||
|
|
||||||
|
|
||||||
def todoist_scrobble_task_finish(
|
def todoist_scrobble_task_finish(
|
||||||
@ -843,9 +841,10 @@ def emacs_scrobble_task(
|
|||||||
return scrobble
|
return scrobble
|
||||||
|
|
||||||
|
|
||||||
def manual_scrobble_task(url: str, user_id: int, action: Optional[str] = None):
|
def manual_scrobble_task(url: str, user_id: int, source: str = "Vrobbler", action: Optional[str] = None):
|
||||||
source_id = re.findall(r"\d+", url)[0]
|
source_id = re.findall(r"\d+", url)[0]
|
||||||
|
|
||||||
|
description = ""
|
||||||
if "todoist" in url:
|
if "todoist" in url:
|
||||||
source = "Todoist"
|
source = "Todoist"
|
||||||
title = "Generic Todoist task"
|
title = "Generic Todoist task"
|
||||||
@ -874,7 +873,7 @@ def manual_scrobble_task(url: str, user_id: int, action: Optional[str] = None):
|
|||||||
|
|
||||||
|
|
||||||
def manual_scrobble_webpage(
|
def manual_scrobble_webpage(
|
||||||
url: str, user_id: int, action: Optional[str] = None
|
url: str, user_id: int, source: str = "Bookmarklet", action: Optional[str] = None
|
||||||
):
|
):
|
||||||
webpage = WebPage.find_or_create({"url": url})
|
webpage = WebPage.find_or_create({"url": url})
|
||||||
|
|
||||||
@ -882,7 +881,7 @@ def manual_scrobble_webpage(
|
|||||||
"user_id": user_id,
|
"user_id": user_id,
|
||||||
"timestamp": timezone.now(),
|
"timestamp": timezone.now(),
|
||||||
"playback_position_seconds": 0,
|
"playback_position_seconds": 0,
|
||||||
"source": "Vrobbler",
|
"source": source,
|
||||||
}
|
}
|
||||||
logger.info(
|
logger.info(
|
||||||
"[vrobbler-scrobble] webpage scrobble request received",
|
"[vrobbler-scrobble] webpage scrobble request received",
|
||||||
@ -1001,7 +1000,7 @@ def web_scrobbler_scrobble_video_or_song(
|
|||||||
|
|
||||||
|
|
||||||
def manual_scrobble_beer(
|
def manual_scrobble_beer(
|
||||||
untappd_id: str, user_id: int, action: Optional[str] = None
|
untappd_id: str, user_id: int, source: str = "Untappd", action: Optional[str] = None
|
||||||
):
|
):
|
||||||
beer = Beer.find_or_create(untappd_id)
|
beer = Beer.find_or_create(untappd_id)
|
||||||
|
|
||||||
@ -1013,7 +1012,7 @@ def manual_scrobble_beer(
|
|||||||
"user_id": user_id,
|
"user_id": user_id,
|
||||||
"timestamp": timezone.now(),
|
"timestamp": timezone.now(),
|
||||||
"playback_position_seconds": 0,
|
"playback_position_seconds": 0,
|
||||||
"source": "Vrobbler",
|
"source": source,
|
||||||
}
|
}
|
||||||
logger.info(
|
logger.info(
|
||||||
"[vrobbler-scrobble] beer scrobble request received",
|
"[vrobbler-scrobble] beer scrobble request received",
|
||||||
@ -1030,7 +1029,7 @@ def manual_scrobble_beer(
|
|||||||
|
|
||||||
|
|
||||||
def manual_scrobble_puzzle(
|
def manual_scrobble_puzzle(
|
||||||
ipdb_id: str, user_id: int, action: Optional[str] = None
|
ipdb_id: str, user_id: int, source: str = "IPDb", action: Optional[str] = None
|
||||||
):
|
):
|
||||||
puzzle = Puzzle.find_or_create(ipdb_id)
|
puzzle = Puzzle.find_or_create(ipdb_id)
|
||||||
|
|
||||||
@ -1042,7 +1041,7 @@ def manual_scrobble_puzzle(
|
|||||||
"user_id": user_id,
|
"user_id": user_id,
|
||||||
"timestamp": timezone.now(),
|
"timestamp": timezone.now(),
|
||||||
"playback_position_seconds": 0,
|
"playback_position_seconds": 0,
|
||||||
"source": "Vrobbler",
|
"source": source,
|
||||||
}
|
}
|
||||||
logger.info(
|
logger.info(
|
||||||
"[vrobbler-scrobble] puzzle scrobble request received",
|
"[vrobbler-scrobble] puzzle scrobble request received",
|
||||||
@ -1059,7 +1058,7 @@ def manual_scrobble_puzzle(
|
|||||||
|
|
||||||
|
|
||||||
def manual_scrobble_brickset(
|
def manual_scrobble_brickset(
|
||||||
brickset_id: str, user_id: int, action: Optional[str] = None
|
brickset_id: str, user_id: int, source: str = "BrickSet", action: Optional[str] = None
|
||||||
):
|
):
|
||||||
brickset = BrickSet.find_or_create(brickset_id)
|
brickset = BrickSet.find_or_create(brickset_id)
|
||||||
|
|
||||||
@ -1071,7 +1070,7 @@ def manual_scrobble_brickset(
|
|||||||
"user_id": user_id,
|
"user_id": user_id,
|
||||||
"timestamp": timezone.now(),
|
"timestamp": timezone.now(),
|
||||||
"playback_position_seconds": 0,
|
"playback_position_seconds": 0,
|
||||||
"source": "Vrobbler",
|
"source": source,
|
||||||
"log": {"serial_scrobble_id": ""},
|
"log": {"serial_scrobble_id": ""},
|
||||||
}
|
}
|
||||||
logger.info(
|
logger.info(
|
||||||
|
|||||||
@ -127,8 +127,9 @@ class RecentScrobbleList(ListView):
|
|||||||
if user.is_authenticated:
|
if user.is_authenticated:
|
||||||
if scrobble_url := self.request.GET.get("scrobble_url", ""):
|
if scrobble_url := self.request.GET.get("scrobble_url", ""):
|
||||||
action = self.request.GET.get("action", "")
|
action = self.request.GET.get("action", "")
|
||||||
|
source = self.request.GET.get("source", "Bookmarklet")
|
||||||
scrobble = manual_scrobble_from_url(
|
scrobble = manual_scrobble_from_url(
|
||||||
scrobble_url, self.request.user.id, action
|
scrobble_url, self.request.user.id, source, action
|
||||||
)
|
)
|
||||||
return HttpResponseRedirect(scrobble.redirect_url(user.id))
|
return HttpResponseRedirect(scrobble.redirect_url(user.id))
|
||||||
return super().get(*args, **kwargs)
|
return super().get(*args, **kwargs)
|
||||||
|
|||||||
Reference in New Issue
Block a user