Skip to content

Commit

Permalink
Fix media.py merge conflict fuckups (#25)
Browse files Browse the repository at this point in the history
* 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 <none>
Co-authored-by: Spoked <Spoked@localhost>
  • Loading branch information
Gaisberg and Spoked authored Dec 15, 2023
1 parent 839dc93 commit 77f7f4e
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 76 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
CMD cd /iceberg/frontend && pnpm run preview --host 0.0.0.0 & cd /iceberg/backend && source /venv/bin/activate && exec python main.py
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ version: '3.8'

services:
iceberg:
image: iceberg:latest
image: spoked/iceberg:latest
container_name: Iceberg
restart: unless-stopped
ports:
Expand Down Expand Up @@ -80,5 +80,4 @@ Seperate terminal:

```sh
python backend/main.py
```
```
18 changes: 14 additions & 4 deletions backend/program/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()

Expand Down Expand Up @@ -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):
Expand Down
112 changes: 44 additions & 68 deletions frontend/src/routes/status/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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'
},
};
</script>

<svelte:head>
Expand Down

0 comments on commit 77f7f4e

Please sign in to comment.