audio streaming app plyr.fm
38
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: generate 96x96 WebP thumbnails for artwork (#976)

* feat: generate 96x96 WebP thumbnails for track/album/playlist artwork

Full-resolution images (potentially megabytes) were served for 48px
display contexts. This adds thumbnail generation on upload, a storage
protocol for type safety, fixes the image delete key prefix bug, and
includes a backfill script for existing images.

- Add StorageProtocol for type-safe dependency injection
- Generate 96x96 WebP thumbnails via Pillow on image upload
- Add thumbnail_url column to tracks, albums, playlists
- Fix image delete key missing images/ prefix
- Add build_image_url() to consolidate URL construction
- Frontend falls back to image_url when thumbnail_url is null
- Backfill script: scripts/backfill_thumbnails.py

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* refactor: improve test_storage_types patterns

- Return mock client from factory instead of module-level global
- Replace inspect.getsource assertion with behavioral delete test
that verifies the actual key passed to head_object

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: move deferred imports to top-level, add generate_and_save tests

- Move BytesIO and generate_and_save imports to module level in
uploads.py, albums.py, lists.py, and metadata_service.py
- Restore accidentally deleted comments in metadata_service.py
- Add test coverage for generate_and_save success/failure paths
- Add thumbnail_url to Playlist frontend type

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

authored by

nate nowack
Claude Opus 4.6
and committed by
GitHub
3ce3f6d2 de95e320

+804 -133
+33
backend/alembic/versions/2026_02_27_120000_add_thumbnail_url_column.py
··· 1 + """add thumbnail_url column 2 + 3 + Revision ID: a1b2c3d4e5f6 4 + Revises: 97e520a2e2fa 5 + Create Date: 2026-02-27 12:00:00.000000 6 + 7 + """ 8 + 9 + from collections.abc import Sequence 10 + 11 + import sqlalchemy as sa 12 + 13 + from alembic import op 14 + 15 + # revision identifiers, used by Alembic. 16 + revision: str = "a1b2c3d4e5f6" 17 + down_revision: str | Sequence[str] | None = "97e520a2e2fa" 18 + branch_labels: str | Sequence[str] | None = None 19 + depends_on: str | Sequence[str] | None = None 20 + 21 + 22 + def upgrade() -> None: 23 + """Add nullable thumbnail_url column to tracks, albums, and playlists.""" 24 + op.add_column("tracks", sa.Column("thumbnail_url", sa.String(), nullable=True)) 25 + op.add_column("albums", sa.Column("thumbnail_url", sa.String(), nullable=True)) 26 + op.add_column("playlists", sa.Column("thumbnail_url", sa.String(), nullable=True)) 27 + 28 + 29 + def downgrade() -> None: 30 + """Remove thumbnail_url columns.""" 31 + op.drop_column("playlists", "thumbnail_url") 32 + op.drop_column("albums", "thumbnail_url") 33 + op.drop_column("tracks", "thumbnail_url")
+1
backend/pyproject.toml
··· 31 31 "redis>=7.1.0", 32 32 "beartype>=0.22.8", 33 33 "turbopuffer>=0.5.0", 34 + "Pillow>=11.0.0", 34 35 ] 35 36 36 37 requires-python = ">=3.11"
+2 -1
backend/src/backend/_internal/export_tasks.py
··· 20 20 from backend.config import settings 21 21 from backend.models import Track 22 22 from backend.models.job import JobStatus 23 + from backend.storage import storage 23 24 from backend.storage.r2 import UploadProgressTracker 24 25 from backend.utilities.database import db_session 25 26 from backend.utilities.progress import R2ProgressTracker ··· 138 139 track = info["track"] 139 140 try: 140 141 response = await s3_client.get_object( 141 - Bucket=settings.storage.r2_bucket, 142 + Bucket=storage.audio_bucket_name, 142 143 Key=info["key"], 143 144 ) 144 145
+58
backend/src/backend/_internal/thumbnails.py
··· 1 + """thumbnail generation for track/album/playlist artwork.""" 2 + 3 + import logging 4 + from io import BytesIO 5 + 6 + from PIL import Image 7 + 8 + logger = logging.getLogger(__name__) 9 + 10 + 11 + def generate_thumbnail(image_data: bytes, size: int = 96, quality: int = 80) -> bytes: 12 + """generate a square WebP thumbnail from image data. 13 + 14 + center-crops to square, resizes with LANCZOS, encodes as WebP. 15 + 16 + args: 17 + image_data: raw image bytes (any format Pillow supports) 18 + size: output dimension in pixels (square) 19 + quality: WebP compression quality (0-100) 20 + 21 + returns: 22 + WebP-encoded thumbnail bytes 23 + """ 24 + img = Image.open(BytesIO(image_data)) 25 + 26 + # convert to RGB (handles RGBA, palette, etc.) 27 + if img.mode not in ("RGB", "L"): 28 + img = img.convert("RGB") 29 + 30 + # center-crop to square 31 + w, h = img.size 32 + if w != h: 33 + side = min(w, h) 34 + left = (w - side) // 2 35 + top = (h - side) // 2 36 + img = img.crop((left, top, left + side, top + side)) 37 + 38 + # resize with high-quality resampling 39 + img = img.resize((size, size), Image.Resampling.LANCZOS) 40 + 41 + # encode as WebP 42 + buf = BytesIO() 43 + img.save(buf, format="WEBP", quality=quality) 44 + return buf.getvalue() 45 + 46 + 47 + async def generate_and_save( 48 + image_data: bytes, image_id: str, context: str = "image" 49 + ) -> str | None: 50 + """generate thumbnail and save to storage. returns thumbnail URL or None on failure.""" 51 + from backend.storage import storage 52 + 53 + try: 54 + thumb_data = generate_thumbnail(image_data) 55 + return await storage.save_thumbnail(thumb_data, image_id) 56 + except Exception as e: 57 + logger.warning("failed to generate %s thumbnail: %s", context, e) 58 + return None
+13 -21
backend/src/backend/api/albums.py
··· 27 27 from backend._internal.auth import get_session 28 28 from backend._internal.clients.moderation import get_moderation_client 29 29 from backend._internal.notifications import notification_service 30 + from backend._internal.thumbnails import generate_and_save 30 31 from backend.config import settings 31 32 from backend.models import Album, Artist, Track, TrackLike, get_db 32 33 from backend.schemas import TrackResponse ··· 306 307 request: Request, 307 308 session_id_cookie: Annotated[str | None, Cookie(alias="session_id")] = None, 308 309 ) -> AlbumResponse: 309 - """get album details with all tracks for a specific artist. 310 - 311 - if the album has an ATProto list record, tracks are returned in the 312 - order stored in that record. otherwise, tracks are ordered by created_at. 313 - """ 310 + """get album details with tracks (ordered by ATProto list record or created_at).""" 314 311 # check Redis cache first 315 312 cache_key = _album_cache_key(handle, slug) 316 313 try: ··· 507 504 # save returns the file_id (hash) 508 505 image_id = await storage.save(image_obj, image.filename) 509 506 510 - # construct R2 URL directly (images are stored under images/ prefix) 511 - image_url = f"{storage.public_image_bucket_url}/images/{image_id}{ext}" 507 + image_url = storage.build_image_url(image_id, ext) 508 + 509 + thumbnail_url = await generate_and_save(bytes(image_data), image_id, "album") 512 510 513 511 # scan image for policy violations (non-blocking) 514 512 if settings.moderation.image_moderation_enabled: ··· 544 542 # update album with new image 545 543 album.image_id = image_id 546 544 album.image_url = image_url 545 + album.thumbnail_url = thumbnail_url 547 546 await db.commit() 548 547 549 548 await invalidate_album_cache(auth_session.handle, album.slug) 550 549 551 - return {"image_url": image_url, "image_id": image_id} 550 + return { 551 + "image_url": image_url, 552 + "image_id": image_id, 553 + "thumbnail_url": thumbnail_url, 554 + } 552 555 553 556 except HTTPException: 554 557 raise ··· 568 571 str | None, Query(description="new album description") 569 572 ] = None, 570 573 ) -> AlbumMetadata: 571 - """update album metadata (title, description). 572 - 573 - when title changes: 574 - - all tracks in the album have their ATProto records updated 575 - - the album's ATProto list record name is updated 576 - """ 574 + """update album metadata (title, description). syncs ATProto records on title change.""" 577 575 from backend._internal.atproto.records.fm_plyr.list import update_list_record 578 576 from backend._internal.atproto.records.fm_plyr.track import ( 579 577 build_track_record, ··· 717 715 Query(description="if true, also delete all tracks in the album"), 718 716 ] = False, 719 717 ) -> DeleteAlbumResponse: 720 - """delete an album. 721 - 722 - by default, tracks are orphaned (album_id set to null) and remain 723 - available as standalone tracks. with cascade=true, tracks are also deleted. 724 - 725 - also deletes the ATProto list record if one exists. 726 - """ 718 + """delete album. tracks are orphaned unless cascade=true. removes ATProto list record.""" 727 719 from backend._internal.atproto.records import delete_record_by_uri 728 720 729 721 # verify album exists and belongs to the authenticated artist
+13 -19
backend/src/backend/api/lists.py
··· 32 32 ) 33 33 from backend._internal.auth import get_session 34 34 from backend._internal.recommendations import get_playlist_recommendations 35 + from backend._internal.thumbnails import generate_and_save 35 36 from backend.config import settings 36 37 from backend.models import Artist, Playlist, Track, TrackLike, UserPreferences, get_db 37 38 from backend.schemas import DeletedResponse, TrackResponse ··· 178 179 session: AuthSession = Depends(require_auth), 179 180 db: AsyncSession = Depends(get_db), 180 181 ) -> ReorderResponse: 181 - """reorder items in a list by rkey. 182 - 183 - the items array order becomes the new display order. 184 - only the list owner can reorder their own list. 185 - 186 - the rkey is the last segment of the AT URI (at://did/collection/rkey). 187 - """ 182 + """reorder items in a list by rkey. items array order = new display order.""" 188 183 from backend.config import settings 189 184 190 185 # construct the full AT URI ··· 323 318 artist_did: str, 324 319 db: AsyncSession = Depends(get_db), 325 320 ) -> list[PlaylistResponse]: 326 - """list public playlists for an artist (no auth required). 327 - 328 - returns playlists where show_on_profile is true. 329 - used to display collections on artist profile pages. 330 - """ 321 + """list public playlists for an artist (no auth required).""" 331 322 result = await db.execute( 332 323 select(Playlist, Artist) 333 324 .join(Artist, Playlist.owner_did == Artist.did) ··· 358 349 playlist_id: str, 359 350 db: AsyncSession = Depends(get_db), 360 351 ) -> PlaylistResponse: 361 - """get playlist metadata (public, no auth required). 362 - 363 - used for link previews and og tags. 364 - """ 352 + """get playlist metadata (public, no auth required). used for link previews.""" 365 353 result = await db.execute( 366 354 select(Playlist, Artist) 367 355 .join(Artist, Playlist.owner_did == Artist.did) ··· 779 767 # save returns the file_id (hash) 780 768 image_id = await storage.save(image_obj, image.filename) 781 769 782 - # construct R2 URL directly (images are stored under images/ prefix) 783 - image_url = f"{storage.public_image_bucket_url}/images/{image_id}{ext}" 770 + image_url = storage.build_image_url(image_id, ext) 771 + 772 + thumbnail_url = await generate_and_save(bytes(image_data), image_id, "playlist") 784 773 785 774 # delete old image if exists (prevent R2 object leaks) 786 775 if playlist.image_id: ··· 790 779 # update playlist with new image 791 780 playlist.image_id = image_id 792 781 playlist.image_url = image_url 782 + playlist.thumbnail_url = thumbnail_url 793 783 await db.commit() 794 784 795 - return {"image_url": image_url, "image_id": image_id} 785 + return { 786 + "image_url": image_url, 787 + "image_id": image_id, 788 + "thumbnail_url": thumbnail_url, 789 + } 796 790 797 791 except HTTPException: 798 792 raise
+10 -10
backend/src/backend/api/tracks/listing.py
··· 2 2 3 3 import asyncio 4 4 from datetime import datetime 5 - from typing import Annotated 5 + from typing import TYPE_CHECKING, Annotated, cast 6 6 7 7 import logfire 8 8 from botocore.exceptions import ClientError ··· 37 37 from backend.utilities.tags import DEFAULT_HIDDEN_TAGS 38 38 39 39 from .router import router 40 + 41 + if TYPE_CHECKING: 42 + from backend.storage.r2 import R2Storage 40 43 41 44 42 45 class TracksListResponse(BaseModel): ··· 290 293 limit: int = 10, 291 294 session: AuthSession | None = Depends(get_optional_session), 292 295 ) -> list[TrackResponse]: 293 - """Get top tracks by like count. 294 - 295 - Returns tracks ordered by number of likes (most liked first). 296 - Only returns tracks that have at least one like. 297 - """ 296 + """get top tracks by like count (most liked first, at least one like).""" 298 297 limit = max(1, min(limit, 50)) 299 298 300 299 # get top track IDs with like counts in a single query ··· 497 496 if not audio_format: 498 497 return 499 498 key = f"audio/{file_id}{audio_format.extension}" 499 + r2 = cast("R2Storage", storage) 500 500 async with semaphore: 501 501 try: 502 - async with storage.async_session.client( 502 + async with r2.async_session.client( 503 503 "s3", 504 - endpoint_url=storage.endpoint_url, 505 - aws_access_key_id=storage.aws_access_key_id, 506 - aws_secret_access_key=storage.aws_secret_access_key, 504 + endpoint_url=r2.endpoint_url, 505 + aws_access_key_id=r2.aws_access_key_id, 506 + aws_secret_access_key=r2.aws_secret_access_key, 507 507 ) as client: 508 508 response = await client.head_object( 509 509 Bucket=storage.audio_bucket_name, Key=key
+9 -4
backend/src/backend/api/tracks/metadata_service.py
··· 15 15 from backend._internal.clients.moderation import get_moderation_client 16 16 from backend._internal.image import ImageFormat 17 17 from backend._internal.notifications import notification_service 18 + from backend._internal.thumbnails import generate_and_save 18 19 from backend.config import settings 19 20 from backend.models import Track 20 21 from backend.storage import storage ··· 113 114 return True 114 115 115 116 116 - async def upload_track_image(image: UploadFile) -> tuple[str, str | None]: 117 - """Persist a track image and return (image_id, public_url).""" 117 + async def upload_track_image( 118 + image: UploadFile, 119 + ) -> tuple[str, str | None, str | None]: 120 + """Persist a track image and return (image_id, public_url, thumbnail_url).""" 118 121 if not image.filename: 119 122 raise HTTPException(status_code=400, detail="image filename missing") 120 123 ··· 136 139 image_id = await storage.save(image_obj, f"images/{image.filename}") 137 140 image_url = await storage.get_url(image_id, file_type="image") 138 141 142 + thumbnail_url = await generate_and_save(image_data, image_id, "track") 143 + 139 144 # scan image for policy violations (non-blocking) 140 145 if settings.moderation.image_moderation_enabled: 141 146 try: 142 147 client = get_moderation_client() 143 148 content_type = image_format.media_type if image_format else "image/png" 144 149 result = await client.scan_image(image_data, image_id, content_type) 145 - # note: if image is flagged, it's automatically added to sensitive_images 150 + # if image is flagged, it's automatically added to sensitive_images 146 151 # by the moderation service. the image is still saved and returned - 147 152 # sensitive images are just blurred in the UI, not rejected. 148 153 if not result.is_safe: ··· 156 161 # log but don't block upload - moderation is best-effort 157 162 logger.warning("image moderation failed for %s: %s", image_id, e) 158 163 159 - return image_id, image_url 164 + return image_id, image_url, thumbnail_url
+3 -1
backend/src/backend/api/tracks/mutations.py
··· 236 236 await storage.delete(track.image_id) 237 237 track.image_id = None 238 238 track.image_url = None 239 + track.thumbnail_url = None 239 240 image_changed = True 240 241 elif image and image.filename: 241 242 # handle image upload/replacement 242 - image_id, image_url = await upload_track_image(image) 243 + image_id, image_url, thumbnail_url = await upload_track_image(image) 243 244 244 245 if track.image_id: 245 246 # only delete old image from R2 if album doesn't share it ··· 253 254 254 255 track.image_id = image_id 255 256 track.image_url = image_url 257 + track.thumbnail_url = thumbnail_url 256 258 image_changed = True 257 259 258 260 # handle tags update
+22 -12
backend/src/backend/api/tracks/uploads.py
··· 6 6 import logging 7 7 import tempfile 8 8 from dataclasses import dataclass 9 + from io import BytesIO 9 10 from pathlib import Path 10 11 from typing import Annotated 11 12 ··· 46 47 schedule_embedding_generation, 47 48 schedule_genre_classification, 48 49 ) 50 + from backend._internal.thumbnails import generate_and_save 49 51 from backend.config import settings 50 52 from backend.models import Artist, Track, UserPreferences 51 53 from backend.models.job import JobStatus, JobType ··· 194 196 image_path: str, 195 197 image_filename: str, 196 198 image_content_type: str | None, 197 - ) -> tuple[str | None, str | None]: 198 - """save image to storage, returning (image_id, image_url) or (None, None).""" 199 + ) -> tuple[str | None, str | None, str | None]: 200 + """save image to storage, returning (image_id, image_url, thumbnail_url) or (None, None, None).""" 199 201 await job_service.update_progress( 200 202 upload_id, 201 203 JobStatus.PROCESSING, ··· 207 209 ) 208 210 if not is_valid or not image_format: 209 211 logger.warning(f"unsupported image format: {image_filename}") 210 - return None, None 212 + return None, None, None 211 213 212 214 try: 213 215 with open(image_path, "rb") as image_obj: 214 - image_id = await storage.save(image_obj, f"images/{image_filename}") 215 - image_url = await storage.get_url(image_id, file_type="image") 216 - return image_id, image_url 216 + image_data = image_obj.read() 217 + 218 + image_id = await storage.save(BytesIO(image_data), f"images/{image_filename}") 219 + image_url = await storage.get_url(image_id, file_type="image") 220 + thumbnail_url = await generate_and_save(image_data, image_id, "track") 221 + 222 + return image_id, image_url, thumbnail_url 217 223 except Exception as e: 218 224 logger.warning(f"failed to save image: {e}", exc_info=True) 219 - return None, None 225 + return None, None, None 220 226 221 227 222 228 @dataclass ··· 586 592 ) 587 593 588 594 589 - async def _store_image(ctx: UploadContext) -> tuple[str | None, str | None]: 590 - """phase 5: store image (optional). returns (image_id, image_url).""" 595 + async def _store_image( 596 + ctx: UploadContext, 597 + ) -> tuple[str | None, str | None, str | None]: 598 + """phase 5: store image (optional). returns (image_id, image_url, thumbnail_url).""" 591 599 if not ctx.image_path or not ctx.image_filename: 592 - return None, None 600 + return None, None, None 593 601 return await _save_image_to_storage( 594 602 ctx.upload_id, ctx.image_path, ctx.image_filename, ctx.image_content_type 595 603 ) ··· 602 610 pds_result: PdsBlobResult | None, 603 611 image_id: str | None, 604 612 image_url: str | None, 613 + thumbnail_url: str | None = None, 605 614 ) -> Track: 606 615 """phase 6: create ATProto record + DB track record.""" 607 616 ext = Path(ctx.filename).suffix.lower() ··· 711 720 atproto_record_cid=atproto_cid, 712 721 image_id=image_id, 713 722 image_url=image_url, 723 + thumbnail_url=thumbnail_url, 714 724 support_gate=ctx.support_gate, 715 725 audio_storage=audio_storage, 716 726 pds_blob_cid=pds_result.cid if pds_result else None, ··· 790 800 pds_result = await _upload_to_pds(ctx, audio_info, sr) 791 801 792 802 # phase 5: store image (optional) 793 - image_id, image_url = await _store_image(ctx) 803 + image_id, image_url, thumbnail_url = await _store_image(ctx) 794 804 795 805 # phase 6: create records (ATProto + DB) 796 806 track = await _create_records( 797 - ctx, audio_info, sr, pds_result, image_id, image_url 807 + ctx, audio_info, sr, pds_result, image_id, image_url, thumbnail_url 798 808 ) 799 809 800 810 # phase 7: post-upload tasks (tags, notifications, background jobs)
+1
backend/src/backend/models/album.py
··· 36 36 description: Mapped[str | None] = mapped_column(String, nullable=True) 37 37 image_id: Mapped[str | None] = mapped_column(String, nullable=True) 38 38 image_url: Mapped[str | None] = mapped_column(String, nullable=True) 39 + thumbnail_url: Mapped[str | None] = mapped_column(String, nullable=True) 39 40 atproto_record_uri: Mapped[str | None] = mapped_column(String, nullable=True) 40 41 atproto_record_cid: Mapped[str | None] = mapped_column(String, nullable=True) 41 42 created_at: Mapped[datetime] = mapped_column(
+1
backend/src/backend/models/playlist.py
··· 34 34 name: Mapped[str] = mapped_column(String, nullable=False) 35 35 image_id: Mapped[str | None] = mapped_column(String, nullable=True) 36 36 image_url: Mapped[str | None] = mapped_column(String, nullable=True) 37 + thumbnail_url: Mapped[str | None] = mapped_column(String, nullable=True) 37 38 atproto_record_uri: Mapped[str] = mapped_column( 38 39 String, 39 40 nullable=False,
+1
backend/src/backend/models/track.py
··· 92 92 # image reference 93 93 image_id: Mapped[str | None] = mapped_column(String, nullable=True, index=True) 94 94 image_url: Mapped[str | None] = mapped_column(String, nullable=True) 95 + thumbnail_url: Mapped[str | None] = mapped_column(String, nullable=True) 95 96 96 97 # notification tracking 97 98 notification_sent: Mapped[bool] = mapped_column(
+4
backend/src/backend/schemas.py
··· 53 53 slug: str 54 54 title: str 55 55 image_url: str | None 56 + thumbnail_url: str | None = None 56 57 57 58 @classmethod 58 59 async def from_album( ··· 70 71 slug=album.slug, 71 72 title=album.title, 72 73 image_url=image_url, 74 + thumbnail_url=album.thumbnail_url, 73 75 ) 74 76 75 77 ··· 100 102 play_count: int 101 103 created_at: str 102 104 image_url: str | None 105 + thumbnail_url: str | None = None 103 106 is_liked: bool 104 107 like_count: int 105 108 comment_count: int ··· 213 216 play_count=track.play_count, 214 217 created_at=track.created_at.isoformat(), 215 218 image_url=image_url, 219 + thumbnail_url=track.thumbnail_url, 216 220 is_liked=is_liked, 217 221 like_count=like_count, 218 222 comment_count=comment_count,
+8 -2
backend/src/backend/storage/__init__.py
··· 1 1 """storage implementations.""" 2 2 3 + from typing import TYPE_CHECKING 4 + 5 + from backend.storage.protocol import StorageProtocol 3 6 from backend.storage.r2 import R2Storage 4 7 5 8 _storage: R2Storage | None = None ··· 21 24 return getattr(_get_storage(), name) 22 25 23 26 24 - storage = _StorageProxy() 27 + if TYPE_CHECKING: 28 + storage: StorageProtocol 29 + else: 30 + storage = _StorageProxy() 25 31 26 - __all__ = ["storage"] 32 + __all__ = ["StorageProtocol", "storage"]
+64
backend/src/backend/storage/protocol.py
··· 1 + """storage protocol for type-safe dependency injection.""" 2 + 3 + from collections.abc import Callable 4 + from io import BytesIO 5 + from typing import BinaryIO, Protocol, runtime_checkable 6 + 7 + 8 + @runtime_checkable 9 + class StorageProtocol(Protocol): 10 + """interface for media storage backends.""" 11 + 12 + audio_bucket_name: str 13 + image_bucket_name: str 14 + public_audio_bucket_url: str 15 + public_image_bucket_url: str 16 + 17 + async def save( 18 + self, 19 + file: BinaryIO | BytesIO, 20 + filename: str, 21 + progress_callback: Callable[[float], None] | None = None, 22 + ) -> str: ... 23 + 24 + async def get_url( 25 + self, 26 + file_id: str, 27 + *, 28 + file_type: str | None = None, 29 + extension: str | None = None, 30 + ) -> str | None: ... 31 + 32 + async def get_file_data( 33 + self, 34 + file_id: str, 35 + file_type: str, 36 + ) -> bytes | None: ... 37 + 38 + async def delete(self, file_id: str, file_type: str | None = None) -> bool: ... 39 + 40 + async def save_gated( 41 + self, 42 + file: BinaryIO | BytesIO, 43 + filename: str, 44 + progress_callback: Callable[[float], None] | None = None, 45 + ) -> str: ... 46 + 47 + async def generate_presigned_url( 48 + self, 49 + file_id: str, 50 + extension: str, 51 + expires_in: int | None = None, 52 + ) -> str: ... 53 + 54 + async def move_audio( 55 + self, 56 + file_id: str, 57 + extension: str, 58 + *, 59 + to_private: bool, 60 + ) -> str | None: ... 61 + 62 + def build_image_url(self, image_id: str, ext: str) -> str: ... 63 + 64 + async def save_thumbnail(self, thumbnail_data: bytes, image_id: str) -> str: ...
+25 -23
backend/src/backend/storage/r2.py
··· 125 125 filename: str, 126 126 progress_callback: Callable[[float], None] | None = None, 127 127 ) -> str: 128 - """save media file to R2 using streaming upload. 129 - 130 - uses chunked hashing and aioboto3's upload_fileobj for constant 131 - memory usage regardless of file size. 132 - 133 - supports both audio and image files. 134 - 135 - args: 136 - file: file-like object to upload 137 - filename: original filename (used to determine media type) 138 - progress_callback: optional callback for upload progress (receives 0-100 percentage) 139 - """ 128 + """save media file to R2 using streaming upload with chunked hashing.""" 140 129 with logfire.span("R2 save", filename=filename): 141 130 # compute hash in chunks (constant memory) 142 131 file_id = hash_file_chunked(file)[:16] ··· 469 458 from backend._internal.image import ImageFormat 470 459 471 460 for image_format in ImageFormat: 472 - key = f"{file_id}.{image_format.value}" 461 + key = f"images/{file_id}.{image_format.value}" 473 462 474 463 try: 475 464 # check if object exists first ··· 507 496 filename: str, 508 497 progress_callback: Callable[[float], None] | None = None, 509 498 ) -> str: 510 - """save supporter-gated audio file to private R2 bucket. 511 - 512 - same as save() but uses the private bucket with no public URL. 513 - files in this bucket are only accessible via presigned URLs. 514 - 515 - args: 516 - file: file-like object to upload 517 - filename: original filename (used to determine media type) 518 - progress_callback: optional callback for upload progress 519 - """ 499 + """save supporter-gated audio to private R2 bucket (presigned URL access only).""" 520 500 if not self.private_audio_bucket_name: 521 501 raise ValueError("R2_PRIVATE_BUCKET not configured") 522 502 ··· 638 618 expires_in=expiry, 639 619 ) 640 620 return url 621 + 622 + def build_image_url(self, image_id: str, ext: str) -> str: 623 + """construct public image URL without HEAD checks.""" 624 + return f"{self.public_image_bucket_url}/images/{image_id}.{ext.lstrip('.')}" 625 + 626 + async def save_thumbnail(self, thumbnail_data: bytes, image_id: str) -> str: 627 + """save a WebP thumbnail alongside the original image in R2.""" 628 + key = f"images/{image_id}_thumb.webp" 629 + with logfire.span("R2 save_thumbnail", image_id=image_id, key=key): 630 + async with self.async_session.client( 631 + "s3", 632 + endpoint_url=self.endpoint_url, 633 + aws_access_key_id=self.aws_access_key_id, 634 + aws_secret_access_key=self.aws_secret_access_key, 635 + ) as client: 636 + await client.upload_fileobj( 637 + BytesIO(thumbnail_data), 638 + self.image_bucket_name, 639 + key, 640 + ExtraArgs={"ContentType": "image/webp"}, 641 + ) 642 + return f"{self.public_image_bucket_url}/{key}" 641 643 642 644 async def move_audio( 643 645 self,
+4
backend/tests/test_background_tasks.py
··· 167 167 mock_file.__aexit__.return_value = None 168 168 mock_file.write = AsyncMock() 169 169 170 + mock_storage = MagicMock() 171 + mock_storage.audio_bucket_name = "test-audio-bucket" 172 + 170 173 with ( 171 174 patch( 172 175 "backend._internal.export_tasks.aioboto3.Session", ··· 177 180 patch("backend._internal.export_tasks.os.unlink"), 178 181 patch("backend._internal.export_tasks.db_session") as mock_db_session, 179 182 patch("backend._internal.export_tasks.job_service", mock_job_service), 183 + patch("backend._internal.export_tasks.storage", mock_storage), 180 184 ): 181 185 mock_db_session.return_value.__aenter__.return_value = mock_db 182 186
+101 -36
backend/tests/test_storage_types.py
··· 1 - """test storage type hints accept BytesIO. 2 - 3 - regression test for: https://github.com/zzstoatzz/plyr.fm/pull/736 4 - beartype was rejecting BytesIO for BinaryIO type hint in R2Storage.save() 5 - """ 1 + """test storage types, protocol conformance, and bug regressions.""" 6 2 7 3 from io import BytesIO 8 - from unittest.mock import AsyncMock, patch 4 + from unittest.mock import AsyncMock, MagicMock, patch 9 5 6 + from backend.storage.protocol import StorageProtocol 10 7 from backend.storage.r2 import R2Storage 11 8 12 9 13 - async def test_r2_save_accepts_bytesio(): 14 - """R2Storage.save() should accept BytesIO objects. 15 - 16 - BytesIO is the standard way to create in-memory binary streams, 17 - and is used throughout the codebase for image uploads. 18 - 19 - This test verifies that the type hint on save() is compatible 20 - with BytesIO, which beartype validates at runtime. 21 - """ 22 - # create a minimal image-like BytesIO 23 - image_data = b"\x89PNG\r\n\x1a\n" + b"\x00" * 100 # fake PNG header 24 - file_obj = BytesIO(image_data) 10 + def _mock_r2_storage() -> tuple[R2Storage, AsyncMock]: 11 + """create an R2Storage with mocked internals. returns (storage, mock_s3_client).""" 12 + with patch.object(R2Storage, "__init__", lambda self: None): 13 + s = R2Storage() 14 + s.async_session = AsyncMock() 15 + s.image_bucket_name = "test-images" 16 + s.audio_bucket_name = "test-audio" 17 + s.private_audio_bucket_name = "test-private" 18 + s.public_audio_bucket_url = "https://audio.test.dev" 19 + s.public_image_bucket_url = "https://images.test.dev" 20 + s.presigned_url_expiry = 3600 21 + s.endpoint_url = "https://test.r2.dev" 22 + s.aws_access_key_id = "test" 23 + s.aws_secret_access_key = "test" 25 24 26 - # mock the R2 client internals 27 - with ( 28 - patch.object(R2Storage, "__init__", lambda self: None), 29 - patch("backend.storage.r2.hash_file_chunked", return_value="abc123def456"), 30 - ): 31 - storage = R2Storage() 32 - storage.async_session = AsyncMock() 33 - storage.image_bucket_name = "test-images" 34 - storage.audio_bucket_name = "test-audio" 35 - 36 - # mock the async context manager for S3 client 37 25 mock_client = AsyncMock() 38 26 mock_client.upload_fileobj = AsyncMock() 27 + mock_client.head_object = AsyncMock() 28 + mock_client.delete_object = AsyncMock() 39 29 40 30 mock_cm = AsyncMock() 41 31 mock_cm.__aenter__ = AsyncMock(return_value=mock_client) 42 32 mock_cm.__aexit__ = AsyncMock(return_value=None) 43 - storage.async_session.client = lambda *args, **kwargs: mock_cm 44 - storage.endpoint_url = "https://test.r2.dev" 45 - storage.aws_access_key_id = "test" 46 - storage.aws_secret_access_key = "test" 33 + s.async_session.client = lambda *args, **kwargs: mock_cm 47 34 48 - # this should NOT raise a beartype error 49 - # before the fix: BeartypeCallHintParamViolation 50 - file_id = await storage.save(file_obj, "test.png") 35 + return s, mock_client 36 + 37 + 38 + async def test_r2_save_accepts_bytesio(): 39 + """R2Storage.save() should accept BytesIO objects. 40 + 41 + regression test for: https://github.com/zzstoatzz/plyr.fm/pull/736 42 + """ 43 + image_data = b"\x89PNG\r\n\x1a\n" + b"\x00" * 100 44 + file_obj = BytesIO(image_data) 45 + 46 + with patch("backend.storage.r2.hash_file_chunked", return_value="abc123def456"): 47 + s, mock_client = _mock_r2_storage() 48 + file_id = await s.save(file_obj, "test.png") 51 49 52 50 assert file_id == "abc123def456"[:16] 53 51 mock_client.upload_fileobj.assert_called_once() 52 + 53 + 54 + def test_r2_storage_conforms_to_protocol(): 55 + """R2Storage should satisfy StorageProtocol.""" 56 + s, _ = _mock_r2_storage() 57 + assert isinstance(s, StorageProtocol) 58 + 59 + 60 + def test_build_image_url(): 61 + """build_image_url constructs correct public URL.""" 62 + s, _ = _mock_r2_storage() 63 + 64 + assert ( 65 + s.build_image_url("abc123", ".png") 66 + == "https://images.test.dev/images/abc123.png" 67 + ) 68 + assert ( 69 + s.build_image_url("abc123", "webp") 70 + == "https://images.test.dev/images/abc123.webp" 71 + ) 72 + 73 + 74 + async def test_image_delete_uses_correct_key_prefix(): 75 + """regression: image delete must use images/ prefix in key. 76 + 77 + before fix, delete used key f"{file_id}.{format}" (missing images/ prefix), 78 + so HEAD check would 404 and images were never actually deleted from R2. 79 + """ 80 + s, mock_client = _mock_r2_storage() 81 + 82 + # mock db_session to return refcount=1 (safe to delete) 83 + mock_db = AsyncMock() 84 + mock_result = MagicMock() 85 + mock_result.scalar_one.return_value = 1 86 + mock_db.execute = AsyncMock(return_value=mock_result) 87 + 88 + mock_db_cm = AsyncMock() 89 + mock_db_cm.__aenter__ = AsyncMock(return_value=mock_db) 90 + mock_db_cm.__aexit__ = AsyncMock(return_value=None) 91 + 92 + with patch("backend.storage.r2.db_session", return_value=mock_db_cm): 93 + await s.delete("abc123") 94 + 95 + # verify head_object was called with images/ prefix 96 + head_calls = mock_client.head_object.call_args_list 97 + assert len(head_calls) > 0 98 + image_keys = [ 99 + c.kwargs.get("Key", c[1].get("Key")) for c in head_calls if "images/" in str(c) 100 + ] 101 + assert all(k.startswith("images/") for k in image_keys) 102 + 103 + 104 + async def test_save_thumbnail(): 105 + """save_thumbnail uploads WebP to correct key.""" 106 + s, mock_client = _mock_r2_storage() 107 + thumb_data = b"RIFF\x00\x00\x00\x00WEBP" 108 + 109 + url = await s.save_thumbnail(thumb_data, "abc123") 110 + 111 + assert url == "https://images.test.dev/images/abc123_thumb.webp" 112 + mock_client.upload_fileobj.assert_called_once() 113 + 114 + # verify the key and content type 115 + call_kwargs = mock_client.upload_fileobj.call_args 116 + assert call_kwargs[0][1] == "test-images" # bucket 117 + assert call_kwargs[0][2] == "images/abc123_thumb.webp" # key 118 + assert call_kwargs[1]["ExtraArgs"]["ContentType"] == "image/webp"
+106
backend/tests/test_thumbnails.py
··· 1 + """tests for thumbnail generation.""" 2 + 3 + from io import BytesIO 4 + from unittest.mock import AsyncMock, patch 5 + 6 + from PIL import Image 7 + 8 + from backend._internal.thumbnails import generate_and_save, generate_thumbnail 9 + 10 + 11 + def _make_png(width: int, height: int, mode: str = "RGB") -> bytes: 12 + """create a minimal PNG image in memory.""" 13 + img = Image.new(mode, (width, height), color="red") 14 + buf = BytesIO() 15 + img.save(buf, format="PNG") 16 + return buf.getvalue() 17 + 18 + 19 + def test_generate_thumbnail_square_input(): 20 + """square input produces 96x96 WebP output.""" 21 + png_data = _make_png(500, 500) 22 + result = generate_thumbnail(png_data) 23 + 24 + img = Image.open(BytesIO(result)) 25 + assert img.size == (96, 96) 26 + assert img.format == "WEBP" 27 + 28 + 29 + def test_generate_thumbnail_landscape_input(): 30 + """landscape input is center-cropped then resized to 96x96.""" 31 + png_data = _make_png(800, 400) 32 + result = generate_thumbnail(png_data) 33 + 34 + img = Image.open(BytesIO(result)) 35 + assert img.size == (96, 96) 36 + assert img.format == "WEBP" 37 + 38 + 39 + def test_generate_thumbnail_portrait_input(): 40 + """portrait input is center-cropped then resized to 96x96.""" 41 + png_data = _make_png(400, 800) 42 + result = generate_thumbnail(png_data) 43 + 44 + img = Image.open(BytesIO(result)) 45 + assert img.size == (96, 96) 46 + assert img.format == "WEBP" 47 + 48 + 49 + def test_generate_thumbnail_rgba_input(): 50 + """RGBA input is converted to RGB before encoding.""" 51 + png_data = _make_png(200, 200, mode="RGBA") 52 + result = generate_thumbnail(png_data) 53 + 54 + img = Image.open(BytesIO(result)) 55 + assert img.size == (96, 96) 56 + assert img.format == "WEBP" 57 + 58 + 59 + def test_generate_thumbnail_custom_size(): 60 + """custom size parameter produces that size.""" 61 + png_data = _make_png(500, 500) 62 + result = generate_thumbnail(png_data, size=48) 63 + 64 + img = Image.open(BytesIO(result)) 65 + assert img.size == (48, 48) 66 + 67 + 68 + def test_generate_thumbnail_small_input(): 69 + """input smaller than target size is still resized (upscaled).""" 70 + png_data = _make_png(32, 32) 71 + result = generate_thumbnail(png_data) 72 + 73 + img = Image.open(BytesIO(result)) 74 + assert img.size == (96, 96) 75 + 76 + 77 + def test_generate_thumbnail_returns_bytes(): 78 + """result is valid bytes that can be uploaded.""" 79 + png_data = _make_png(100, 100) 80 + result = generate_thumbnail(png_data) 81 + 82 + assert isinstance(result, bytes) 83 + assert len(result) > 0 84 + # WebP magic bytes 85 + assert result[:4] == b"RIFF" 86 + 87 + 88 + async def test_generate_and_save_returns_url(): 89 + """generate_and_save returns thumbnail URL on success.""" 90 + png_data = _make_png(100, 100) 91 + mock_storage = AsyncMock() 92 + mock_storage.save_thumbnail = AsyncMock( 93 + return_value="https://images.test/thumb.webp" 94 + ) 95 + 96 + with patch("backend.storage.storage", mock_storage): 97 + url = await generate_and_save(png_data, "img123", "track") 98 + 99 + assert url == "https://images.test/thumb.webp" 100 + mock_storage.save_thumbnail.assert_called_once() 101 + 102 + 103 + async def test_generate_and_save_returns_none_on_failure(): 104 + """generate_and_save returns None and logs warning on failure.""" 105 + url = await generate_and_save(b"not-an-image", "img123", "track") 106 + assert url is None
+89
backend/uv.lock
··· 342 342 { name = "mutagen" }, 343 343 { name = "orjson" }, 344 344 { name = "passlib", extra = ["bcrypt"] }, 345 + { name = "pillow" }, 345 346 { name = "psycopg", extra = ["binary"] }, 346 347 { name = "pydantic" }, 347 348 { name = "pydantic-settings" }, ··· 391 392 { name = "mutagen", specifier = ">=1.47.0" }, 392 393 { name = "orjson", specifier = ">=3.11.4" }, 393 394 { name = "passlib", extras = ["bcrypt"], specifier = ">=1.7.4" }, 395 + { name = "pillow", specifier = ">=11.0.0" }, 394 396 { name = "psycopg", extras = ["binary"], specifier = ">=3.2.12" }, 395 397 { name = "pydantic", specifier = ">=2.11.0" }, 396 398 { name = "pydantic-settings", specifier = ">=2.7.0" }, ··· 1999 2001 sdist = { url = "https://files.pythonhosted.org/packages/42/92/cc564bf6381ff43ce1f4d06852fc19a2f11d180f23dc32d9588bee2f149d/pexpect-4.9.0.tar.gz", hash = "sha256:ee7d41123f3c9911050ea2c2dac107568dc43b2d3b0c7557a33212c398ead30f", size = 166450, upload-time = "2023-11-25T09:07:26.339Z" } 2000 2002 wheels = [ 2001 2003 { url = "https://files.pythonhosted.org/packages/9e/c3/059298687310d527a58bb01f3b1965787ee3b40dce76752eda8b44e9a2c5/pexpect-4.9.0-py2.py3-none-any.whl", hash = "sha256:7236d1e080e4936be2dc3e326cec0af72acf9212a7e1d060210e70a47e253523", size = 63772, upload-time = "2023-11-25T06:56:14.81Z" }, 2004 + ] 2005 + 2006 + [[package]] 2007 + name = "pillow" 2008 + version = "12.1.1" 2009 + source = { registry = "https://pypi.org/simple" } 2010 + sdist = { url = "https://files.pythonhosted.org/packages/1f/42/5c74462b4fd957fcd7b13b04fb3205ff8349236ea74c7c375766d6c82288/pillow-12.1.1.tar.gz", hash = "sha256:9ad8fa5937ab05218e2b6a4cff30295ad35afd2f83ac592e68c0d871bb0fdbc4", size = 46980264, upload-time = "2026-02-11T04:23:07.146Z" } 2011 + wheels = [ 2012 + { url = "https://files.pythonhosted.org/packages/2b/46/5da1ec4a5171ee7bf1a0efa064aba70ba3d6e0788ce3f5acd1375d23c8c0/pillow-12.1.1-cp311-cp311-macosx_10_10_x86_64.whl", hash = "sha256:e879bb6cd5c73848ef3b2b48b8af9ff08c5b71ecda8048b7dd22d8a33f60be32", size = 5304084, upload-time = "2026-02-11T04:20:27.501Z" }, 2013 + { url = "https://files.pythonhosted.org/packages/78/93/a29e9bc02d1cf557a834da780ceccd54e02421627200696fcf805ebdc3fb/pillow-12.1.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:365b10bb9417dd4498c0e3b128018c4a624dc11c7b97d8cc54effe3b096f4c38", size = 4657866, upload-time = "2026-02-11T04:20:29.827Z" }, 2014 + { url = "https://files.pythonhosted.org/packages/13/84/583a4558d492a179d31e4aae32eadce94b9acf49c0337c4ce0b70e0a01f2/pillow-12.1.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:d4ce8e329c93845720cd2014659ca67eac35f6433fd3050393d85f3ecef0dad5", size = 6232148, upload-time = "2026-02-11T04:20:31.329Z" }, 2015 + { url = "https://files.pythonhosted.org/packages/d5/e2/53c43334bbbb2d3b938978532fbda8e62bb6e0b23a26ce8592f36bcc4987/pillow-12.1.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:fc354a04072b765eccf2204f588a7a532c9511e8b9c7f900e1b64e3e33487090", size = 8038007, upload-time = "2026-02-11T04:20:34.225Z" }, 2016 + { url = "https://files.pythonhosted.org/packages/b8/a6/3d0e79c8a9d58150dd98e199d7c1c56861027f3829a3a60b3c2784190180/pillow-12.1.1-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:7e7976bf1910a8116b523b9f9f58bf410f3e8aa330cd9a2bb2953f9266ab49af", size = 6345418, upload-time = "2026-02-11T04:20:35.858Z" }, 2017 + { url = "https://files.pythonhosted.org/packages/a2/c8/46dfeac5825e600579157eea177be43e2f7ff4a99da9d0d0a49533509ac5/pillow-12.1.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:597bd9c8419bc7c6af5604e55847789b69123bbe25d65cc6ad3012b4f3c98d8b", size = 7034590, upload-time = "2026-02-11T04:20:37.91Z" }, 2018 + { url = "https://files.pythonhosted.org/packages/af/bf/e6f65d3db8a8bbfeaf9e13cc0417813f6319863a73de934f14b2229ada18/pillow-12.1.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:2c1fc0f2ca5f96a3c8407e41cca26a16e46b21060fe6d5b099d2cb01412222f5", size = 6458655, upload-time = "2026-02-11T04:20:39.496Z" }, 2019 + { url = "https://files.pythonhosted.org/packages/f9/c2/66091f3f34a25894ca129362e510b956ef26f8fb67a0e6417bc5744e56f1/pillow-12.1.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:578510d88c6229d735855e1f278aa305270438d36a05031dfaae5067cc8eb04d", size = 7159286, upload-time = "2026-02-11T04:20:41.139Z" }, 2020 + { url = "https://files.pythonhosted.org/packages/7b/5a/24bc8eb526a22f957d0cec6243146744966d40857e3d8deb68f7902ca6c1/pillow-12.1.1-cp311-cp311-win32.whl", hash = "sha256:7311c0a0dcadb89b36b7025dfd8326ecfa36964e29913074d47382706e516a7c", size = 6328663, upload-time = "2026-02-11T04:20:43.184Z" }, 2021 + { url = "https://files.pythonhosted.org/packages/31/03/bef822e4f2d8f9d7448c133d0a18185d3cce3e70472774fffefe8b0ed562/pillow-12.1.1-cp311-cp311-win_amd64.whl", hash = "sha256:fbfa2a7c10cc2623f412753cddf391c7f971c52ca40a3f65dc5039b2939e8563", size = 7031448, upload-time = "2026-02-11T04:20:44.696Z" }, 2022 + { url = "https://files.pythonhosted.org/packages/49/70/f76296f53610bd17b2e7d31728b8b7825e3ac3b5b3688b51f52eab7c0818/pillow-12.1.1-cp311-cp311-win_arm64.whl", hash = "sha256:b81b5e3511211631b3f672a595e3221252c90af017e399056d0faabb9538aa80", size = 2453651, upload-time = "2026-02-11T04:20:46.243Z" }, 2023 + { url = "https://files.pythonhosted.org/packages/07/d3/8df65da0d4df36b094351dce696f2989bec731d4f10e743b1c5f4da4d3bf/pillow-12.1.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:ab323b787d6e18b3d91a72fc99b1a2c28651e4358749842b8f8dfacd28ef2052", size = 5262803, upload-time = "2026-02-11T04:20:47.653Z" }, 2024 + { url = "https://files.pythonhosted.org/packages/d6/71/5026395b290ff404b836e636f51d7297e6c83beceaa87c592718747e670f/pillow-12.1.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:adebb5bee0f0af4909c30db0d890c773d1a92ffe83da908e2e9e720f8edf3984", size = 4657601, upload-time = "2026-02-11T04:20:49.328Z" }, 2025 + { url = "https://files.pythonhosted.org/packages/b1/2e/1001613d941c67442f745aff0f7cc66dd8df9a9c084eb497e6a543ee6f7e/pillow-12.1.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:bb66b7cc26f50977108790e2456b7921e773f23db5630261102233eb355a3b79", size = 6234995, upload-time = "2026-02-11T04:20:51.032Z" }, 2026 + { url = "https://files.pythonhosted.org/packages/07/26/246ab11455b2549b9233dbd44d358d033a2f780fa9007b61a913c5b2d24e/pillow-12.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:aee2810642b2898bb187ced9b349e95d2a7272930796e022efaf12e99dccd293", size = 8045012, upload-time = "2026-02-11T04:20:52.882Z" }, 2027 + { url = "https://files.pythonhosted.org/packages/b2/8b/07587069c27be7535ac1fe33874e32de118fbd34e2a73b7f83436a88368c/pillow-12.1.1-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:a0b1cd6232e2b618adcc54d9882e4e662a089d5768cd188f7c245b4c8c44a397", size = 6349638, upload-time = "2026-02-11T04:20:54.444Z" }, 2028 + { url = "https://files.pythonhosted.org/packages/ff/79/6df7b2ee763d619cda2fb4fea498e5f79d984dae304d45a8999b80d6cf5c/pillow-12.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7aac39bcf8d4770d089588a2e1dd111cbaa42df5a94be3114222057d68336bd0", size = 7041540, upload-time = "2026-02-11T04:20:55.97Z" }, 2029 + { url = "https://files.pythonhosted.org/packages/2c/5e/2ba19e7e7236d7529f4d873bdaf317a318896bac289abebd4bb00ef247f0/pillow-12.1.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:ab174cd7d29a62dd139c44bf74b698039328f45cb03b4596c43473a46656b2f3", size = 6462613, upload-time = "2026-02-11T04:20:57.542Z" }, 2030 + { url = "https://files.pythonhosted.org/packages/03/03/31216ec124bb5c3dacd74ce8efff4cc7f52643653bad4825f8f08c697743/pillow-12.1.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:339ffdcb7cbeaa08221cd401d517d4b1fe7a9ed5d400e4a8039719238620ca35", size = 7166745, upload-time = "2026-02-11T04:20:59.196Z" }, 2031 + { url = "https://files.pythonhosted.org/packages/1f/e7/7c4552d80052337eb28653b617eafdef39adfb137c49dd7e831b8dc13bc5/pillow-12.1.1-cp312-cp312-win32.whl", hash = "sha256:5d1f9575a12bed9e9eedd9a4972834b08c97a352bd17955ccdebfeca5913fa0a", size = 6328823, upload-time = "2026-02-11T04:21:01.385Z" }, 2032 + { url = "https://files.pythonhosted.org/packages/3d/17/688626d192d7261bbbf98846fc98995726bddc2c945344b65bec3a29d731/pillow-12.1.1-cp312-cp312-win_amd64.whl", hash = "sha256:21329ec8c96c6e979cd0dfd29406c40c1d52521a90544463057d2aaa937d66a6", size = 7033367, upload-time = "2026-02-11T04:21:03.536Z" }, 2033 + { url = "https://files.pythonhosted.org/packages/ed/fe/a0ef1f73f939b0eca03ee2c108d0043a87468664770612602c63266a43c4/pillow-12.1.1-cp312-cp312-win_arm64.whl", hash = "sha256:af9a332e572978f0218686636610555ae3defd1633597be015ed50289a03c523", size = 2453811, upload-time = "2026-02-11T04:21:05.116Z" }, 2034 + { url = "https://files.pythonhosted.org/packages/d5/11/6db24d4bd7685583caeae54b7009584e38da3c3d4488ed4cd25b439de486/pillow-12.1.1-cp313-cp313-ios_13_0_arm64_iphoneos.whl", hash = "sha256:d242e8ac078781f1de88bf823d70c1a9b3c7950a44cdf4b7c012e22ccbcd8e4e", size = 4062689, upload-time = "2026-02-11T04:21:06.804Z" }, 2035 + { url = "https://files.pythonhosted.org/packages/33/c0/ce6d3b1fe190f0021203e0d9b5b99e57843e345f15f9ef22fcd43842fd21/pillow-12.1.1-cp313-cp313-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:02f84dfad02693676692746df05b89cf25597560db2857363a208e393429f5e9", size = 4138535, upload-time = "2026-02-11T04:21:08.452Z" }, 2036 + { url = "https://files.pythonhosted.org/packages/a0/c6/d5eb6a4fb32a3f9c21a8c7613ec706534ea1cf9f4b3663e99f0d83f6fca8/pillow-12.1.1-cp313-cp313-ios_13_0_x86_64_iphonesimulator.whl", hash = "sha256:e65498daf4b583091ccbb2556c7000abf0f3349fcd57ef7adc9a84a394ed29f6", size = 3601364, upload-time = "2026-02-11T04:21:10.194Z" }, 2037 + { url = "https://files.pythonhosted.org/packages/14/a1/16c4b823838ba4c9c52c0e6bbda903a3fe5a1bdbf1b8eb4fff7156f3e318/pillow-12.1.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:6c6db3b84c87d48d0088943bf33440e0c42370b99b1c2a7989216f7b42eede60", size = 5262561, upload-time = "2026-02-11T04:21:11.742Z" }, 2038 + { url = "https://files.pythonhosted.org/packages/bb/ad/ad9dc98ff24f485008aa5cdedaf1a219876f6f6c42a4626c08bc4e80b120/pillow-12.1.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:8b7e5304e34942bf62e15184219a7b5ad4ff7f3bb5cca4d984f37df1a0e1aee2", size = 4657460, upload-time = "2026-02-11T04:21:13.786Z" }, 2039 + { url = "https://files.pythonhosted.org/packages/9e/1b/f1a4ea9a895b5732152789326202a82464d5254759fbacae4deea3069334/pillow-12.1.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:18e5bddd742a44b7e6b1e773ab5db102bd7a94c32555ba656e76d319d19c3850", size = 6232698, upload-time = "2026-02-11T04:21:15.949Z" }, 2040 + { url = "https://files.pythonhosted.org/packages/95/f4/86f51b8745070daf21fd2e5b1fe0eb35d4db9ca26e6d58366562fb56a743/pillow-12.1.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:fc44ef1f3de4f45b50ccf9136999d71abb99dca7706bc75d222ed350b9fd2289", size = 8041706, upload-time = "2026-02-11T04:21:17.723Z" }, 2041 + { url = "https://files.pythonhosted.org/packages/29/9b/d6ecd956bb1266dd1045e995cce9b8d77759e740953a1c9aad9502a0461e/pillow-12.1.1-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5a8eb7ed8d4198bccbd07058416eeec51686b498e784eda166395a23eb99138e", size = 6346621, upload-time = "2026-02-11T04:21:19.547Z" }, 2042 + { url = "https://files.pythonhosted.org/packages/71/24/538bff45bde96535d7d998c6fed1a751c75ac7c53c37c90dc2601b243893/pillow-12.1.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:47b94983da0c642de92ced1702c5b6c292a84bd3a8e1d1702ff923f183594717", size = 7038069, upload-time = "2026-02-11T04:21:21.378Z" }, 2043 + { url = "https://files.pythonhosted.org/packages/94/0e/58cb1a6bc48f746bc4cb3adb8cabff73e2742c92b3bf7a220b7cf69b9177/pillow-12.1.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:518a48c2aab7ce596d3bf79d0e275661b846e86e4d0e7dec34712c30fe07f02a", size = 6460040, upload-time = "2026-02-11T04:21:23.148Z" }, 2044 + { url = "https://files.pythonhosted.org/packages/6c/57/9045cb3ff11eeb6c1adce3b2d60d7d299d7b273a2e6c8381a524abfdc474/pillow-12.1.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:a550ae29b95c6dc13cf69e2c9dc5747f814c54eeb2e32d683e5e93af56caa029", size = 7164523, upload-time = "2026-02-11T04:21:25.01Z" }, 2045 + { url = "https://files.pythonhosted.org/packages/73/f2/9be9cb99f2175f0d4dbadd6616ce1bf068ee54a28277ea1bf1fbf729c250/pillow-12.1.1-cp313-cp313-win32.whl", hash = "sha256:a003d7422449f6d1e3a34e3dd4110c22148336918ddbfc6a32581cd54b2e0b2b", size = 6332552, upload-time = "2026-02-11T04:21:27.238Z" }, 2046 + { url = "https://files.pythonhosted.org/packages/3f/eb/b0834ad8b583d7d9d42b80becff092082a1c3c156bb582590fcc973f1c7c/pillow-12.1.1-cp313-cp313-win_amd64.whl", hash = "sha256:344cf1e3dab3be4b1fa08e449323d98a2a3f819ad20f4b22e77a0ede31f0faa1", size = 7040108, upload-time = "2026-02-11T04:21:29.462Z" }, 2047 + { url = "https://files.pythonhosted.org/packages/d5/7d/fc09634e2aabdd0feabaff4a32f4a7d97789223e7c2042fd805ea4b4d2c2/pillow-12.1.1-cp313-cp313-win_arm64.whl", hash = "sha256:5c0dd1636633e7e6a0afe7bf6a51a14992b7f8e60de5789018ebbdfae55b040a", size = 2453712, upload-time = "2026-02-11T04:21:31.072Z" }, 2048 + { url = "https://files.pythonhosted.org/packages/19/2a/b9d62794fc8a0dd14c1943df68347badbd5511103e0d04c035ffe5cf2255/pillow-12.1.1-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:0330d233c1a0ead844fc097a7d16c0abff4c12e856c0b325f231820fee1f39da", size = 5264880, upload-time = "2026-02-11T04:21:32.865Z" }, 2049 + { url = "https://files.pythonhosted.org/packages/26/9d/e03d857d1347fa5ed9247e123fcd2a97b6220e15e9cb73ca0a8d91702c6e/pillow-12.1.1-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:5dae5f21afb91322f2ff791895ddd8889e5e947ff59f71b46041c8ce6db790bc", size = 4660616, upload-time = "2026-02-11T04:21:34.97Z" }, 2050 + { url = "https://files.pythonhosted.org/packages/f7/ec/8a6d22afd02570d30954e043f09c32772bfe143ba9285e2fdb11284952cd/pillow-12.1.1-cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:2e0c664be47252947d870ac0d327fea7e63985a08794758aa8af5b6cb6ec0c9c", size = 6269008, upload-time = "2026-02-11T04:21:36.623Z" }, 2051 + { url = "https://files.pythonhosted.org/packages/3d/1d/6d875422c9f28a4a361f495a5f68d9de4a66941dc2c619103ca335fa6446/pillow-12.1.1-cp313-cp313t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:691ab2ac363b8217f7d31b3497108fb1f50faab2f75dfb03284ec2f217e87bf8", size = 8073226, upload-time = "2026-02-11T04:21:38.585Z" }, 2052 + { url = "https://files.pythonhosted.org/packages/a1/cd/134b0b6ee5eda6dc09e25e24b40fdafe11a520bc725c1d0bbaa5e00bf95b/pillow-12.1.1-cp313-cp313t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:e9e8064fb1cc019296958595f6db671fba95209e3ceb0c4734c9baf97de04b20", size = 6380136, upload-time = "2026-02-11T04:21:40.562Z" }, 2053 + { url = "https://files.pythonhosted.org/packages/7a/a9/7628f013f18f001c1b98d8fffe3452f306a70dc6aba7d931019e0492f45e/pillow-12.1.1-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:472a8d7ded663e6162dafdf20015c486a7009483ca671cece7a9279b512fcb13", size = 7067129, upload-time = "2026-02-11T04:21:42.521Z" }, 2054 + { url = "https://files.pythonhosted.org/packages/1e/f8/66ab30a2193b277785601e82ee2d49f68ea575d9637e5e234faaa98efa4c/pillow-12.1.1-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:89b54027a766529136a06cfebeecb3a04900397a3590fd252160b888479517bf", size = 6491807, upload-time = "2026-02-11T04:21:44.22Z" }, 2055 + { url = "https://files.pythonhosted.org/packages/da/0b/a877a6627dc8318fdb84e357c5e1a758c0941ab1ddffdafd231983788579/pillow-12.1.1-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:86172b0831b82ce4f7877f280055892b31179e1576aa00d0df3bb1bbf8c3e524", size = 7190954, upload-time = "2026-02-11T04:21:46.114Z" }, 2056 + { url = "https://files.pythonhosted.org/packages/83/43/6f732ff85743cf746b1361b91665d9f5155e1483817f693f8d57ea93147f/pillow-12.1.1-cp313-cp313t-win32.whl", hash = "sha256:44ce27545b6efcf0fdbdceb31c9a5bdea9333e664cda58a7e674bb74608b3986", size = 6336441, upload-time = "2026-02-11T04:21:48.22Z" }, 2057 + { url = "https://files.pythonhosted.org/packages/3b/44/e865ef3986611bb75bfabdf94a590016ea327833f434558801122979cd0e/pillow-12.1.1-cp313-cp313t-win_amd64.whl", hash = "sha256:a285e3eb7a5a45a2ff504e31f4a8d1b12ef62e84e5411c6804a42197c1cf586c", size = 7045383, upload-time = "2026-02-11T04:21:50.015Z" }, 2058 + { url = "https://files.pythonhosted.org/packages/a8/c6/f4fb24268d0c6908b9f04143697ea18b0379490cb74ba9e8d41b898bd005/pillow-12.1.1-cp313-cp313t-win_arm64.whl", hash = "sha256:cc7d296b5ea4d29e6570dabeaed58d31c3fea35a633a69679fb03d7664f43fb3", size = 2456104, upload-time = "2026-02-11T04:21:51.633Z" }, 2059 + { url = "https://files.pythonhosted.org/packages/03/d0/bebb3ffbf31c5a8e97241476c4cf8b9828954693ce6744b4a2326af3e16b/pillow-12.1.1-cp314-cp314-ios_13_0_arm64_iphoneos.whl", hash = "sha256:417423db963cb4be8bac3fc1204fe61610f6abeed1580a7a2cbb2fbda20f12af", size = 4062652, upload-time = "2026-02-11T04:21:53.19Z" }, 2060 + { url = "https://files.pythonhosted.org/packages/2d/c0/0e16fb0addda4851445c28f8350d8c512f09de27bbb0d6d0bbf8b6709605/pillow-12.1.1-cp314-cp314-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:b957b71c6b2387610f556a7eb0828afbe40b4a98036fc0d2acfa5a44a0c2036f", size = 4138823, upload-time = "2026-02-11T04:22:03.088Z" }, 2061 + { url = "https://files.pythonhosted.org/packages/6b/fb/6170ec655d6f6bb6630a013dd7cf7bc218423d7b5fa9071bf63dc32175ae/pillow-12.1.1-cp314-cp314-ios_13_0_x86_64_iphonesimulator.whl", hash = "sha256:097690ba1f2efdeb165a20469d59d8bb03c55fb6621eb2041a060ae8ea3e9642", size = 3601143, upload-time = "2026-02-11T04:22:04.909Z" }, 2062 + { url = "https://files.pythonhosted.org/packages/59/04/dc5c3f297510ba9a6837cbb318b87dd2b8f73eb41a43cc63767f65cb599c/pillow-12.1.1-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:2815a87ab27848db0321fb78c7f0b2c8649dee134b7f2b80c6a45c6831d75ccd", size = 5266254, upload-time = "2026-02-11T04:22:07.656Z" }, 2063 + { url = "https://files.pythonhosted.org/packages/05/30/5db1236b0d6313f03ebf97f5e17cda9ca060f524b2fcc875149a8360b21c/pillow-12.1.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:f7ed2c6543bad5a7d5530eb9e78c53132f93dfa44a28492db88b41cdab885202", size = 4657499, upload-time = "2026-02-11T04:22:09.613Z" }, 2064 + { url = "https://files.pythonhosted.org/packages/6f/18/008d2ca0eb612e81968e8be0bbae5051efba24d52debf930126d7eaacbba/pillow-12.1.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:652a2c9ccfb556235b2b501a3a7cf3742148cd22e04b5625c5fe057ea3e3191f", size = 6232137, upload-time = "2026-02-11T04:22:11.434Z" }, 2065 + { url = "https://files.pythonhosted.org/packages/70/f1/f14d5b8eeb4b2cd62b9f9f847eb6605f103df89ef619ac68f92f748614ea/pillow-12.1.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:d6e4571eedf43af33d0fc233a382a76e849badbccdf1ac438841308652a08e1f", size = 8042721, upload-time = "2026-02-11T04:22:13.321Z" }, 2066 + { url = "https://files.pythonhosted.org/packages/5a/d6/17824509146e4babbdabf04d8171491fa9d776f7061ff6e727522df9bd03/pillow-12.1.1-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:b574c51cf7d5d62e9be37ba446224b59a2da26dc4c1bb2ecbe936a4fb1a7cb7f", size = 6347798, upload-time = "2026-02-11T04:22:15.449Z" }, 2067 + { url = "https://files.pythonhosted.org/packages/d1/ee/c85a38a9ab92037a75615aba572c85ea51e605265036e00c5b67dfafbfe2/pillow-12.1.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a37691702ed687799de29a518d63d4682d9016932db66d4e90c345831b02fb4e", size = 7039315, upload-time = "2026-02-11T04:22:17.24Z" }, 2068 + { url = "https://files.pythonhosted.org/packages/ec/f3/bc8ccc6e08a148290d7523bde4d9a0d6c981db34631390dc6e6ec34cacf6/pillow-12.1.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:f95c00d5d6700b2b890479664a06e754974848afaae5e21beb4d83c106923fd0", size = 6462360, upload-time = "2026-02-11T04:22:19.111Z" }, 2069 + { url = "https://files.pythonhosted.org/packages/f6/ab/69a42656adb1d0665ab051eec58a41f169ad295cf81ad45406963105408f/pillow-12.1.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:559b38da23606e68681337ad74622c4dbba02254fc9cb4488a305dd5975c7eeb", size = 7165438, upload-time = "2026-02-11T04:22:21.041Z" }, 2070 + { url = "https://files.pythonhosted.org/packages/02/46/81f7aa8941873f0f01d4b55cc543b0a3d03ec2ee30d617a0448bf6bd6dec/pillow-12.1.1-cp314-cp314-win32.whl", hash = "sha256:03edcc34d688572014ff223c125a3f77fb08091e4607e7745002fc214070b35f", size = 6431503, upload-time = "2026-02-11T04:22:22.833Z" }, 2071 + { url = "https://files.pythonhosted.org/packages/40/72/4c245f7d1044b67affc7f134a09ea619d4895333d35322b775b928180044/pillow-12.1.1-cp314-cp314-win_amd64.whl", hash = "sha256:50480dcd74fa63b8e78235957d302d98d98d82ccbfac4c7e12108ba9ecbdba15", size = 7176748, upload-time = "2026-02-11T04:22:24.64Z" }, 2072 + { url = "https://files.pythonhosted.org/packages/e4/ad/8a87bdbe038c5c698736e3348af5c2194ffb872ea52f11894c95f9305435/pillow-12.1.1-cp314-cp314-win_arm64.whl", hash = "sha256:5cb1785d97b0c3d1d1a16bc1d710c4a0049daefc4935f3a8f31f827f4d3d2e7f", size = 2544314, upload-time = "2026-02-11T04:22:26.685Z" }, 2073 + { url = "https://files.pythonhosted.org/packages/6c/9d/efd18493f9de13b87ede7c47e69184b9e859e4427225ea962e32e56a49bc/pillow-12.1.1-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:1f90cff8aa76835cba5769f0b3121a22bd4eb9e6884cfe338216e557a9a548b8", size = 5268612, upload-time = "2026-02-11T04:22:29.884Z" }, 2074 + { url = "https://files.pythonhosted.org/packages/f8/f1/4f42eb2b388eb2ffc660dcb7f7b556c1015c53ebd5f7f754965ef997585b/pillow-12.1.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:1f1be78ce9466a7ee64bfda57bdba0f7cc499d9794d518b854816c41bf0aa4e9", size = 4660567, upload-time = "2026-02-11T04:22:31.799Z" }, 2075 + { url = "https://files.pythonhosted.org/packages/01/54/df6ef130fa43e4b82e32624a7b821a2be1c5653a5fdad8469687a7db4e00/pillow-12.1.1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:42fc1f4677106188ad9a55562bbade416f8b55456f522430fadab3cef7cd4e60", size = 6269951, upload-time = "2026-02-11T04:22:33.921Z" }, 2076 + { url = "https://files.pythonhosted.org/packages/a9/48/618752d06cc44bb4aae8ce0cd4e6426871929ed7b46215638088270d9b34/pillow-12.1.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:98edb152429ab62a1818039744d8fbb3ccab98a7c29fc3d5fcef158f3f1f68b7", size = 8074769, upload-time = "2026-02-11T04:22:35.877Z" }, 2077 + { url = "https://files.pythonhosted.org/packages/c3/bd/f1d71eb39a72fa088d938655afba3e00b38018d052752f435838961127d8/pillow-12.1.1-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:d470ab1178551dd17fdba0fef463359c41aaa613cdcd7ff8373f54be629f9f8f", size = 6381358, upload-time = "2026-02-11T04:22:37.698Z" }, 2078 + { url = "https://files.pythonhosted.org/packages/64/ef/c784e20b96674ed36a5af839305f55616f8b4f8aa8eeccf8531a6e312243/pillow-12.1.1-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6408a7b064595afcab0a49393a413732a35788f2a5092fdc6266952ed67de586", size = 7068558, upload-time = "2026-02-11T04:22:39.597Z" }, 2079 + { url = "https://files.pythonhosted.org/packages/73/cb/8059688b74422ae61278202c4e1ad992e8a2e7375227be0a21c6b87ca8d5/pillow-12.1.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:5d8c41325b382c07799a3682c1c258469ea2ff97103c53717b7893862d0c98ce", size = 6493028, upload-time = "2026-02-11T04:22:42.73Z" }, 2080 + { url = "https://files.pythonhosted.org/packages/c6/da/e3c008ed7d2dd1f905b15949325934510b9d1931e5df999bb15972756818/pillow-12.1.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:c7697918b5be27424e9ce568193efd13d925c4481dd364e43f5dff72d33e10f8", size = 7191940, upload-time = "2026-02-11T04:22:44.543Z" }, 2081 + { url = "https://files.pythonhosted.org/packages/01/4a/9202e8d11714c1fc5951f2e1ef362f2d7fbc595e1f6717971d5dd750e969/pillow-12.1.1-cp314-cp314t-win32.whl", hash = "sha256:d2912fd8114fc5545aa3a4b5576512f64c55a03f3ebcca4c10194d593d43ea36", size = 6438736, upload-time = "2026-02-11T04:22:46.347Z" }, 2082 + { url = "https://files.pythonhosted.org/packages/f3/ca/cbce2327eb9885476b3957b2e82eb12c866a8b16ad77392864ad601022ce/pillow-12.1.1-cp314-cp314t-win_amd64.whl", hash = "sha256:4ceb838d4bd9dab43e06c363cab2eebf63846d6a4aeaea283bbdfd8f1a8ed58b", size = 7182894, upload-time = "2026-02-11T04:22:48.114Z" }, 2083 + { url = "https://files.pythonhosted.org/packages/ec/d2/de599c95ba0a973b94410477f8bf0b6f0b5e67360eb89bcb1ad365258beb/pillow-12.1.1-cp314-cp314t-win_arm64.whl", hash = "sha256:7b03048319bfc6170e93bd60728a1af51d3dd7704935feb228c4d4faab35d334", size = 2546446, upload-time = "2026-02-11T04:22:50.342Z" }, 2084 + { url = "https://files.pythonhosted.org/packages/56/11/5d43209aa4cb58e0cc80127956ff1796a68b928e6324bbf06ef4db34367b/pillow-12.1.1-pp311-pypy311_pp73-macosx_10_15_x86_64.whl", hash = "sha256:600fd103672b925fe62ed08e0d874ea34d692474df6f4bf7ebe148b30f89f39f", size = 5228606, upload-time = "2026-02-11T04:22:52.106Z" }, 2085 + { url = "https://files.pythonhosted.org/packages/5f/d5/3b005b4e4fda6698b371fa6c21b097d4707585d7db99e98d9b0b87ac612a/pillow-12.1.1-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:665e1b916b043cef294bc54d47bf02d87e13f769bc4bc5fa225a24b3a6c5aca9", size = 4622321, upload-time = "2026-02-11T04:22:53.827Z" }, 2086 + { url = "https://files.pythonhosted.org/packages/df/36/ed3ea2d594356fd8037e5a01f6156c74bc8d92dbb0fa60746cc96cabb6e8/pillow-12.1.1-pp311-pypy311_pp73-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:495c302af3aad1ca67420ddd5c7bd480c8867ad173528767d906428057a11f0e", size = 5247579, upload-time = "2026-02-11T04:22:56.094Z" }, 2087 + { url = "https://files.pythonhosted.org/packages/54/9a/9cc3e029683cf6d20ae5085da0dafc63148e3252c2f13328e553aaa13cfb/pillow-12.1.1-pp311-pypy311_pp73-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:8fd420ef0c52c88b5a035a0886f367748c72147b2b8f384c9d12656678dfdfa9", size = 6989094, upload-time = "2026-02-11T04:22:58.288Z" }, 2088 + { url = "https://files.pythonhosted.org/packages/00/98/fc53ab36da80b88df0967896b6c4b4cd948a0dc5aa40a754266aa3ae48b3/pillow-12.1.1-pp311-pypy311_pp73-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f975aa7ef9684ce7e2c18a3aa8f8e2106ce1e46b94ab713d156b2898811651d3", size = 5313850, upload-time = "2026-02-11T04:23:00.554Z" }, 2089 + { url = "https://files.pythonhosted.org/packages/30/02/00fa585abfd9fe9d73e5f6e554dc36cc2b842898cbfc46d70353dae227f8/pillow-12.1.1-pp311-pypy311_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:8089c852a56c2966cf18835db62d9b34fef7ba74c726ad943928d494fa7f4735", size = 5963343, upload-time = "2026-02-11T04:23:02.934Z" }, 2090 + { url = "https://files.pythonhosted.org/packages/f2/26/c56ce33ca856e358d27fda9676c055395abddb82c35ac0f593877ed4562e/pillow-12.1.1-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:cb9bb857b2d057c6dfc72ac5f3b44836924ba15721882ef103cecb40d002d80e", size = 7029880, upload-time = "2026-02-11T04:23:04.783Z" }, 2002 2091 ] 2003 2092 2004 2093 [[package]]
+2 -2
frontend/src/lib/components/TrackCard.svelte
··· 88 88 > 89 89 <div class="artwork" class:gated={track.gated}> 90 90 {#if track.image_url} 91 - <SensitiveImage src={track.image_url}> 91 + <SensitiveImage src={track.thumbnail_url ?? track.image_url}> 92 92 <img 93 - src={track.image_url} 93 + src={track.thumbnail_url ?? track.image_url} 94 94 alt="{track.title} artwork" 95 95 loading={imageLoading} 96 96 />
+2 -2
frontend/src/lib/components/TrackItem.svelte
··· 227 227 > 228 228 <div class="track-image-wrapper" class:gated={track.gated}> 229 229 {#if track.image_url && !trackImageError} 230 - <SensitiveImage src={track.image_url}> 230 + <SensitiveImage src={track.thumbnail_url ?? track.image_url}> 231 231 <div class="track-image"> 232 232 <img 233 - src={track.image_url} 233 + src={track.thumbnail_url ?? track.image_url} 234 234 alt="{track.title} artwork" 235 235 width="48" 236 236 height="48"
+3
frontend/src/lib/types.ts
··· 12 12 track_count: number; 13 13 total_plays: number; 14 14 image_url?: string; 15 + thumbnail_url?: string; 15 16 } 16 17 17 18 export interface AlbumMetadata extends AlbumSummary { ··· 52 53 tags?: string[]; 53 54 created_at?: string; 54 55 image_url?: string; 56 + thumbnail_url?: string; 55 57 is_liked?: boolean; 56 58 copyright_flagged?: boolean | null; // null = not scanned, false = clear, true = flagged 57 59 copyright_match?: string | null; // "Title by Artist" of primary match ··· 132 134 owner_handle: string; 133 135 track_count: number; 134 136 image_url?: string; 137 + thumbnail_url?: string; 135 138 show_on_profile: boolean; 136 139 atproto_record_uri: string; 137 140 created_at: string;
+229
scripts/backfill_thumbnails.py
··· 1 + #!/usr/bin/env -S uv run --script --quiet 2 + """backfill thumbnails for existing track/album/playlist images. 3 + 4 + ## Context 5 + 6 + Track artwork and avatars display at 48px but full-resolution images are 7 + served. This generates 96x96 WebP thumbnails (2x retina) and stores them 8 + alongside the originals in R2. 9 + 10 + ## Usage 11 + 12 + ```bash 13 + # dry run (show what would be thumbnailed) 14 + uv run scripts/backfill_thumbnails.py --dry-run 15 + 16 + # generate first 5 thumbnails 17 + uv run scripts/backfill_thumbnails.py --limit 5 18 + 19 + # full backfill with custom concurrency 20 + uv run scripts/backfill_thumbnails.py --concurrency 20 21 + ``` 22 + """ 23 + 24 + import argparse 25 + import asyncio 26 + import logging 27 + import time 28 + 29 + import httpx 30 + from sqlalchemy import select, update 31 + 32 + from backend._internal.thumbnails import generate_thumbnail 33 + from backend.models import Album, Track 34 + from backend.models.playlist import Playlist 35 + from backend.storage import storage 36 + from backend.utilities.database import db_session 37 + 38 + logging.basicConfig( 39 + level=logging.INFO, 40 + format="%(asctime)s - %(levelname)s - %(message)s", 41 + ) 42 + logger = logging.getLogger(__name__) 43 + 44 + 45 + async def _process_one( 46 + row: dict, 47 + http: httpx.AsyncClient, 48 + sem: asyncio.Semaphore, 49 + counter: dict[str, int], 50 + total: int, 51 + ) -> None: 52 + """download original image, generate thumbnail, upload and update DB.""" 53 + async with sem: 54 + idx = counter["started"] + 1 55 + counter["started"] += 1 56 + 57 + try: 58 + logger.info( 59 + "thumbnailing [%d/%d] %s %s: %s", 60 + idx, 61 + total, 62 + row["table"], 63 + row["id"], 64 + row["image_url"], 65 + ) 66 + 67 + resp = await http.get(row["image_url"]) 68 + resp.raise_for_status() 69 + 70 + thumb_data = generate_thumbnail(resp.content) 71 + thumbnail_url = await storage.save_thumbnail(thumb_data, row["image_id"]) 72 + 73 + # update DB row 74 + async with db_session() as db: 75 + await db.execute( 76 + update(row["model"]) 77 + .where(row["model"].id == row["id"]) 78 + .values(thumbnail_url=thumbnail_url) 79 + ) 80 + await db.commit() 81 + 82 + counter["generated"] += 1 83 + logger.info( 84 + "generated thumbnail for %s %s (%d bytes)", 85 + row["table"], 86 + row["id"], 87 + len(thumb_data), 88 + ) 89 + 90 + except Exception: 91 + logger.exception("failed to thumbnail %s %s", row["table"], row["id"]) 92 + counter["failed"] += 1 93 + 94 + 95 + async def backfill_thumbnails( 96 + dry_run: bool = False, 97 + limit: int | None = None, 98 + concurrency: int = 10, 99 + ) -> None: 100 + """backfill thumbnails for images missing thumbnail_url.""" 101 + 102 + rows: list[dict] = [] 103 + 104 + async with db_session() as db: 105 + # tracks with images but no thumbnail 106 + stmt = ( 107 + select(Track) 108 + .where(Track.image_id.isnot(None), Track.thumbnail_url.is_(None)) 109 + .order_by(Track.id) 110 + ) 111 + if limit: 112 + stmt = stmt.limit(limit) 113 + result = await db.execute(stmt) 114 + for track in result.scalars(): 115 + if track.image_url: 116 + rows.append( 117 + { 118 + "table": "track", 119 + "id": track.id, 120 + "image_id": track.image_id, 121 + "image_url": track.image_url, 122 + "model": Track, 123 + } 124 + ) 125 + 126 + # albums with images but no thumbnail 127 + remaining = (limit - len(rows)) if limit else None 128 + if remaining is None or remaining > 0: 129 + stmt = ( 130 + select(Album) 131 + .where(Album.image_id.isnot(None), Album.thumbnail_url.is_(None)) 132 + .order_by(Album.id) 133 + ) 134 + if remaining: 135 + stmt = stmt.limit(remaining) 136 + result = await db.execute(stmt) 137 + for album in result.scalars(): 138 + if album.image_url: 139 + rows.append( 140 + { 141 + "table": "album", 142 + "id": album.id, 143 + "image_id": album.image_id, 144 + "image_url": album.image_url, 145 + "model": Album, 146 + } 147 + ) 148 + 149 + # playlists with images but no thumbnail 150 + remaining = (limit - len(rows)) if limit else None 151 + if remaining is None or remaining > 0: 152 + stmt = ( 153 + select(Playlist) 154 + .where(Playlist.image_id.isnot(None), Playlist.thumbnail_url.is_(None)) 155 + .order_by(Playlist.id) 156 + ) 157 + if remaining: 158 + stmt = stmt.limit(remaining) 159 + result = await db.execute(stmt) 160 + for playlist in result.scalars(): 161 + if playlist.image_url: 162 + rows.append( 163 + { 164 + "table": "playlist", 165 + "id": playlist.id, 166 + "image_id": playlist.image_id, 167 + "image_url": playlist.image_url, 168 + "model": Playlist, 169 + } 170 + ) 171 + 172 + if not rows: 173 + logger.info("no images found needing thumbnails") 174 + return 175 + 176 + logger.info("found %d images to thumbnail (concurrency=%d)", len(rows), concurrency) 177 + 178 + if dry_run: 179 + for row in rows: 180 + logger.info( 181 + "would thumbnail: %s %s (image_id=%s)", 182 + row["table"], 183 + row["id"], 184 + row["image_id"], 185 + ) 186 + return 187 + 188 + sem = asyncio.Semaphore(concurrency) 189 + counter: dict[str, int] = {"started": 0, "generated": 0, "failed": 0} 190 + t0 = time.monotonic() 191 + 192 + async with httpx.AsyncClient(timeout=httpx.Timeout(60.0)) as http: 193 + tasks = [_process_one(row, http, sem, counter, len(rows)) for row in rows] 194 + await asyncio.gather(*tasks) 195 + 196 + elapsed = time.monotonic() - t0 197 + logger.info( 198 + "backfill complete: %d generated, %d failed, %d total in %.0fs (%.1f/s)", 199 + counter["generated"], 200 + counter["failed"], 201 + len(rows), 202 + elapsed, 203 + len(rows) / elapsed if elapsed > 0 else 0, 204 + ) 205 + 206 + 207 + async def main() -> None: 208 + parser = argparse.ArgumentParser(description="backfill image thumbnails") 209 + parser.add_argument( 210 + "--dry-run", action="store_true", help="show what would be done" 211 + ) 212 + parser.add_argument("--limit", type=int, default=None, help="max images to process") 213 + parser.add_argument( 214 + "--concurrency", type=int, default=10, help="concurrent workers" 215 + ) 216 + args = parser.parse_args() 217 + 218 + if args.dry_run: 219 + logger.info("running in DRY RUN mode — no uploads will be made") 220 + 221 + await backfill_thumbnails( 222 + dry_run=args.dry_run, 223 + limit=args.limit, 224 + concurrency=args.concurrency, 225 + ) 226 + 227 + 228 + if __name__ == "__main__": 229 + asyncio.run(main())