(self, obj)
| 57 | return instance |
| 58 | |
| 59 | def get_cache_url(self, obj): |
| 60 | # Cache-busting: append a short hash of the logo's source URL so the browser |
| 61 | # fetches fresh when the logo changes (e.g., M3U logo replaced by SD logo). |
| 62 | # The backend ignores the 'v' parameter — it's purely for browser cache invalidation. |
| 63 | # See SD integration PR notes for context on why this was added. |
| 64 | import hashlib |
| 65 | url_hash = hashlib.md5((obj.url or '').encode()).hexdigest()[:8] |
| 66 | base_path = reverse("api:channels:logo-cache", args=[obj.id]) |
| 67 | cache_url = f"{base_path}?v={url_hash}" |
| 68 | request = self.context.get("request") |
| 69 | if request: |
| 70 | return build_absolute_uri_with_port(request, cache_url) |
| 71 | return cache_url |
| 72 | |
| 73 | def get_channel_count(self, obj): |
| 74 | """Get the number of channels using this logo""" |
nothing calls this directly
no test coverage detected