[webpages] Push to archivebox in a different place

This commit is contained in:
2024-04-19 11:00:07 -04:00
parent f87bc5fd55
commit 89541a13f2
3 changed files with 13 additions and 10 deletions

View File

@ -27,7 +27,7 @@ def set_default_timezone(apps, schema_editor):
) )
): ):
s.timezone = "Europe/Paris" s.timezone = "Europe/Paris"
s.save(update_fields=["timezone"], push_media=False) s.save(update_fields=["timezone"])
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -554,7 +554,7 @@ class Scrobble(TimeStampedModel):
long_play_seconds = models.BigIntegerField(**BNULL) long_play_seconds = models.BigIntegerField(**BNULL)
long_play_complete = models.BooleanField(**BNULL) long_play_complete = models.BooleanField(**BNULL)
def save(self, push_media=True, *args, **kwargs): def save(self, *args, **kwargs):
if not self.uuid: if not self.uuid:
self.uuid = uuid4() self.uuid = uuid4()
@ -569,11 +569,12 @@ class Scrobble(TimeStampedModel):
self.timestamp = self.timestamp.replace(microsecond=0) self.timestamp = self.timestamp.replace(microsecond=0)
self.media_type = self.MediaType(self.media_obj.__class__.__name__) self.media_type = self.MediaType(self.media_obj.__class__.__name__)
pushable_media = ( return super(Scrobble, self).save(*args, **kwargs)
hasattr(self.media_obj, "push_to_archivebox")
and callable(self.media_obj.push_to_archivebox) def push_to_archivebox(self):
and push_media pushable_media = hasattr(
) self.media_obj, "push_to_archivebox"
) and callable(self.media_obj.push_to_archivebox)
if pushable_media and self.user.profile.archivebox_url: if pushable_media and self.user.profile.archivebox_url:
try: try:
@ -591,8 +592,6 @@ class Scrobble(TimeStampedModel):
}, },
) )
return super(Scrobble, self).save(*args, **kwargs)
@property @property
def tzinfo(self): def tzinfo(self):
return pytz.timezone(self.timezone) return pytz.timezone(self.timezone)
@ -913,6 +912,7 @@ class Scrobble(TimeStampedModel):
"source": source, "source": source,
}, },
) )
return cls.create(scrobble_data) return cls.create(scrobble_data)
@classmethod @classmethod

View File

@ -341,7 +341,10 @@ def manual_scrobble_webpage(url: str, user_id: int):
}, },
) )
return Scrobble.create_or_update(webpage, user_id, scrobble_dict) scrobble = Scrobble.create_or_update(webpage, user_id, scrobble_dict)
# possibly async this?
scrobble.push_to_archivebox()
return scrobble
def gpslogger_scrobble_location(data_dict: dict, user_id: int) -> Scrobble: def gpslogger_scrobble_location(data_dict: dict, user_id: int) -> Scrobble: