Handle thumbnail redownload requests

This commit is contained in:
tcely 2025-04-28 15:03:13 -04:00 committed by GitHub
parent ea545d49a6
commit bd0ad3682a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -546,6 +546,7 @@ class MediaItemView(DetailView):
template_name = 'sync/media-item.html'
model = Media
messages = {
'thumbnail': _('Thumbnail has been scheduled to redownload'),
'redownloading': _('Media file has been deleted and scheduled to redownload'),
'skipped': _('Media file has been deleted and marked to never download'),
'enabled': _('Media has been re-enabled and will be downloaded'),
@ -581,6 +582,24 @@ class MediaItemView(DetailView):
data['media_file_path'] = pathlib.Path(self.object.media_file.path) if self.object.media_file else None
return data
def get(self, *args, **kwargs):
if args[0].path.startswith("/media-thumb-redownload/"):
media = Media.objects.get(pk=kwargs["pk"])
if media is None:
return HttpResponseNotFound()
verbose_name = _('Redownload thumbnail for "{}": {}')
download_media_thumbnail(
str(media.pk),
media.thumbnail,
verbose_name=verbose_name.format(media.key, media.name),
)
url = reverse_lazy('sync:media-item')
url = append_uri_params(url, {'message': 'thumbnail'})
return HttpResponseRedirect(url)
else:
return super().get(self, *args, **kwargs)
class MediaRedownloadView(FormView, SingleObjectMixin):
'''