[brickset] Fix manual scrobbling and admin
This commit is contained in:
@ -3,6 +3,7 @@ import logging
|
||||
import re
|
||||
from datetime import datetime, timedelta, tzinfo
|
||||
from sqlite3 import IntegrityError
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import pytz
|
||||
from django.apps import apps
|
||||
@ -17,9 +18,10 @@ from scrobbles.tasks import (
|
||||
process_lastfm_import,
|
||||
process_retroarch_import,
|
||||
)
|
||||
from vrobbler.apps.scrobbles.notifications import NtfyNotification
|
||||
from webdav.client import get_webdav_client
|
||||
|
||||
from vrobbler.apps.scrobbles.notifications import NtfyNotification
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
User = get_user_model()
|
||||
|
||||
@ -67,7 +69,8 @@ def get_scrobbles_for_media(media_obj, user: User) -> models.QuerySet:
|
||||
return Scrobble.objects.filter(media_query, user=user)
|
||||
|
||||
|
||||
def get_recently_played_board_games(user: User) -> dict: ...
|
||||
def get_recently_played_board_games(user: User) -> dict:
|
||||
...
|
||||
|
||||
|
||||
def get_long_plays_in_progress(user: User) -> dict:
|
||||
@ -187,8 +190,8 @@ def delete_zombie_scrobbles(dry_run=True):
|
||||
|
||||
def import_from_webdav_for_all_users(restart=False):
|
||||
"""Grab a list of all users with WebDAV enabled and kickoff imports for them"""
|
||||
from scrobbles.models import KoReaderImport
|
||||
from books.koreader import fetch_file_from_webdav
|
||||
from scrobbles.models import KoReaderImport
|
||||
|
||||
# LastFmImport = apps.get_model("scrobbles", "LastFMImport")
|
||||
webdav_enabled_user_ids = UserProfile.objects.filter(
|
||||
@ -271,6 +274,7 @@ def get_file_md5_hash(file_path: str) -> str:
|
||||
file_hash.update(chunk)
|
||||
return file_hash.hexdigest()
|
||||
|
||||
|
||||
def deduplicate_tracks(commit=False) -> int:
|
||||
from music.models import Track
|
||||
|
||||
@ -293,7 +297,11 @@ def deduplicate_tracks(commit=False) -> int:
|
||||
try:
|
||||
other.delete()
|
||||
except IntegrityError as e:
|
||||
print("could not delete ", other.id, f": IntegrityError {e}")
|
||||
print(
|
||||
"could not delete ",
|
||||
other.id,
|
||||
f": IntegrityError {e}",
|
||||
)
|
||||
return len(dups)
|
||||
|
||||
|
||||
@ -318,3 +326,13 @@ def send_stop_notifications_for_in_progress_scrobbles() -> int:
|
||||
notifications_sent += 1
|
||||
|
||||
return notifications_sent
|
||||
|
||||
|
||||
def extract_domain(url):
|
||||
parsed_url = urlparse(url)
|
||||
domain = (
|
||||
parsed_url.netloc.split(".")[-2]
|
||||
+ "."
|
||||
+ parsed_url.netloc.split(".")[-1]
|
||||
)
|
||||
return domain
|
||||
|
||||
Reference in New Issue
Block a user