From 77f7f4e597b8d3c98eef8420ad43a28f5bc02919 Mon Sep 17 00:00:00 2001 From: Gaisberg <93206976+Gaisberg@users.noreply.github.com> Date: Fri, 15 Dec 2023 09:45:27 +0200 Subject: [PATCH] Fix media.py merge conflict fuckups (#25) * Fix media.py merge conflict fuckups * Change to 0.0.0.0 host on frontend. Expose backend api for dev work. * Remove empty quote at bottom of readme * Fix statusInfo for states in backend. --------- Co-authored-by: Gaisberg Co-authored-by: Spoked --- Dockerfile | 4 +- README.md | 3 +- backend/program/media.py | 18 +++- frontend/src/routes/status/+page.svelte | 112 ++++++++++-------------- 4 files changed, 61 insertions(+), 76 deletions(-) diff --git a/Dockerfile b/Dockerfile index 62ad2df5..a3863ba2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,6 +20,6 @@ RUN cd /iceberg/frontend && \ pnpm install && \ pnpm run build -EXPOSE 4173 +EXPOSE 4173 8080 -CMD cd /iceberg/frontend && pnpm run preview --host & cd /iceberg/backend && source /venv/bin/activate && exec python main.py \ No newline at end of file +CMD cd /iceberg/frontend && pnpm run preview --host 0.0.0.0 & cd /iceberg/backend && source /venv/bin/activate && exec python main.py \ No newline at end of file diff --git a/README.md b/README.md index b80aa9a3..c3031525 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ version: '3.8' services: iceberg: - image: iceberg:latest + image: spoked/iceberg:latest container_name: Iceberg restart: unless-stopped ports: @@ -80,5 +80,4 @@ Seperate terminal: ```sh python backend/main.py -``` ``` \ No newline at end of file diff --git a/backend/program/media.py b/backend/program/media.py index 331918b6..b8ff7ecf 100644 --- a/backend/program/media.py +++ b/backend/program/media.py @@ -48,20 +48,19 @@ def state(self): return MediaItemState.LIBRARY if self.symlinked: return MediaItemState.SYMLINK - if self.is_cached() or self.file: + if self.is_cached(): return MediaItemState.DOWNLOAD if len(self.streams) > 0: return MediaItemState.SCRAPE if self.title: return MediaItemState.CONTENT return MediaItemState.UNKNOWN - def is_cached(self): if self.streams: return any(stream.get("cached", None) for stream in self.streams.values()) return False - + def is_scraped(self): return len(self.streams) > 0 @@ -73,6 +72,17 @@ def is_checked_for_availability(self): ) return False + def to_dict(self): + return { + "title": self.title, + "imdb_id": self.imdb_id, + "state": self.state.name, + "imdb_link": self.imdb_link if hasattr(self, 'imdb_link') else None, + "aired_at": self.aired_at, + "genres": self.genres, + "guid": self.guid, + } + def is_not_cached(self): return not self.is_cached() @@ -118,7 +128,7 @@ def __init__(self, item): self.locations = item.get("locations", []) self.seasons = item.get("seasons", []) self.type = "show" - + @property def state(self): if all(season.state is MediaItemState.LIBRARY for season in self.seasons): diff --git a/frontend/src/routes/status/+page.svelte b/frontend/src/routes/status/+page.svelte index 82febf12..eb97bdad 100644 --- a/frontend/src/routes/status/+page.svelte +++ b/frontend/src/routes/status/+page.svelte @@ -20,74 +20,50 @@ toast.success('Refreshed data'); } - const statusInfo: StatusInfo = { - ERROR: { - text: formatState('ERROR'), - color: 'text-red-500', - bg: 'bg-red-500', - description: 'Error occurred during processing' - }, - UNKNOWN: { - text: formatState('UNKNOWN'), - color: 'text-red-500', - bg: 'bg-red-500', - description: 'Unknown status' - }, - LIBRARY: { - text: 'In Library', - color: 'text-green-400', - bg: 'bg-green-400', - description: 'Item is in your library' - }, - LIBRARY_ONGOING: { - text: formatState('LIBRARY_ONGOING'), - color: 'text-green-400', - bg: 'bg-green-400', - description: 'Item is in your library and is ongoing' - }, - LIBRARY_METADATA: { - text: formatState('LIBRARY_METADATA'), - color: 'text-gray-500', - bg: 'bg-gray-500', - description: 'TODO: Add description' - }, - CONTENT: { - text: 'Requested', - color: 'text-purple-500', - bg: 'bg-purple-500', - description: 'Item is requested from external service' - }, - SCRAPED: { - text: formatState('SCRAPED'), - color: 'text-yellow-500', - bg: 'bg-yellow-500', - description: 'Item is scraped and will be downloaded' - }, - SCRAPED_NOT_FOUND: { - text: formatState('SCRAPED_NOT_FOUND'), - color: 'text-red-500', - bg: 'bg-red-500', - description: 'Item was unable to be scraped' - }, - PARTIALLY_SCRAPED: { - text: formatState('PARTIALLY_SCRAPED'), - color: 'text-yellow-500', - bg: 'bg-yellow-500', - description: 'Item was partially scraped' - }, - DOWNLOADING: { - text: formatState('DOWNLOADING'), - color: 'text-yellow-500', - bg: 'bg-yellow-500', - description: 'Item is currently downloading' - }, - PARTIALLY_DOWNLOADING: { - text: formatState('PARTIALLY_DOWNLOADING'), - color: 'text-yellow-500', - bg: 'bg-yellow-500', - description: 'Item is partially downloading' - } - }; + const statusInfo: StatusInfo = { + UNKNOWN: { + text: formatState('Unknown'), + color: 'text-red-500', + bg: 'bg-red-500', + description: 'Unknown status' + }, + CONTENT: { + text: 'Requested', + color: 'text-purple-500', + bg: 'bg-purple-500', + description: 'Item is requested from external service' + }, + SCRAPE: { + text: formatState('Scraped'), + color: 'text-yellow-500', + bg: 'bg-yellow-500', + description: 'Item is scraped and will be downloaded' + }, + DOWNLOAD: { + text: formatState('Download'), + color: 'text-yellow-500', + bg: 'bg-yellow-500', + description: 'Item is currently downloading' + }, + SYMLINK: { + text: formatState('Symlink'), + color: 'text-yellow-500', + bg: 'bg-yellow-500', + description: 'Item is currently being symmlinked' + }, + LIBRARY: { + text: 'In Library', + color: 'text-green-400', + bg: 'bg-green-400', + description: 'Item is in your library' + }, + LIBRARY_PARTIAL: { + text: formatState('Library Partial'), + color: 'text-blue-400', + bg: 'bg-blue-400', + description: 'Item is in your library and is ongoing' + }, + };