Skip to content

Commit

Permalink
Added series status and last air date
Browse files Browse the repository at this point in the history
  • Loading branch information
morpheus65535 authored Dec 18, 2024
1 parent f81780f commit c8e2894
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 28 deletions.
6 changes: 6 additions & 0 deletions bazarr/api/series/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ class Series(Resource):
'alternativeTitles': fields.List(fields.String),
'audio_language': fields.Nested(get_audio_language_model),
'episodeFileCount': fields.Integer(default=0),
'ended': fields.Boolean(),
'episodeMissingCount': fields.Integer(default=0),
'fanart': fields.String(),
'imdbId': fields.String(),
'lastAired': fields.String(),
'monitored': fields.Boolean(),
'overview': fields.String(),
'path': fields.String(),
Expand Down Expand Up @@ -100,6 +102,8 @@ def get(self):
TableShows.tags,
TableShows.title,
TableShows.year,
TableShows.ended,
TableShows.lastAired,
episodeFileCount.c.episodeFileCount,
episodeMissingCount.c.episodeMissingCount) \
.select_from(TableShows) \
Expand Down Expand Up @@ -128,6 +132,8 @@ def get(self):
'tags': x.tags,
'title': x.title,
'year': x.year,
'ended': x.ended,
'lastAired': x.lastAired,
'episodeFileCount': x.episodeFileCount,
'episodeMissingCount': x.episodeMissingCount,
}) for x in database.execute(stmt).all()]
Expand Down
2 changes: 2 additions & 0 deletions bazarr/app/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,10 @@ class TableShows(Base):
alternativeTitles = mapped_column(Text)
audio_language = mapped_column(Text)
created_at_timestamp = mapped_column(DateTime)
ended = mapped_column(Text)
fanart = mapped_column(Text)
imdbId = mapped_column(Text)
lastAired = mapped_column(Text)
monitored = mapped_column(Text)
overview = mapped_column(Text)
path = mapped_column(Text, nullable=False, unique=True)
Expand Down
40 changes: 24 additions & 16 deletions bazarr/sonarr/sync/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import os

from dateutil import parser

from app.config import settings
from app.database import TableShows, database, select
from constants import MINIMUM_VIDEO_SIZE
Expand Down Expand Up @@ -45,6 +47,10 @@ def seriesParser(show, action, tags_dict, language_profiles, serie_default_profi

imdbId = show['imdbId'] if 'imdbId' in show else None

ended = 'True' if 'ended' in show and show['ended'] else 'False'

lastAired = parser.parse(show['lastAired']).strftime("%Y-%m-%d") if 'lastAired' in show and show['lastAired'] else None

audio_language = []
if not settings.general.parse_embedded_audio_track:
if get_sonarr_info.is_legacy():
Expand All @@ -56,22 +62,24 @@ def seriesParser(show, action, tags_dict, language_profiles, serie_default_profi
audio_language = []

parsed_series = {
'title': show["title"],
'path': show["path"],
'tvdbId': int(show["tvdbId"]),
'sonarrSeriesId': int(show["id"]),
'overview': overview,
'poster': poster,
'fanart': fanart,
'audio_language': str(audio_language),
'sortTitle': show['sortTitle'],
'year': str(show['year']),
'alternativeTitles': str(alternate_titles),
'tags': str(tags),
'seriesType': show['seriesType'],
'imdbId': imdbId,
'monitored': str(bool(show['monitored']))
}
'title': show["title"],
'path': show["path"],
'tvdbId': int(show["tvdbId"]),
'sonarrSeriesId': int(show["id"]),
'overview': overview,
'poster': poster,
'fanart': fanart,
'audio_language': str(audio_language),
'sortTitle': show['sortTitle'],
'year': str(show['year']),
'alternativeTitles': str(alternate_titles),
'tags': str(tags),
'seriesType': show['seriesType'],
'imdbId': imdbId,
'monitored': str(bool(show['monitored'])),
'ended': ended,
'lastAired': lastAired,
}

if action == 'insert':
parsed_series['profileId'] = serie_default_profile
Expand Down
11 changes: 11 additions & 0 deletions frontend/src/pages/Episodes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ import { showNotification } from "@mantine/notifications";
import {
faAdjust,
faBriefcase,
faCalendar,
faCircleChevronDown,
faCircleChevronRight,
faCloudUploadAlt,
faHdd,
faPlay,
faSearch,
faStop,
faSync,
faTriangleExclamation,
faWrench,
Expand Down Expand Up @@ -67,6 +70,14 @@ const SeriesEpisodesView: FunctionComponent = () => {
icon: faTriangleExclamation,
text: `${series?.episodeMissingCount} missing subtitles`,
},
{
icon: series?.ended ? faStop : faPlay,
text: series?.ended ? "Ended" : "Continuing",
},
{
icon: faCalendar,
text: `Last ${series?.ended ? "aired on" : "known airdate"}: ${series?.lastAired}`,
},
{
icon: faAdjust,
text: series?.seriesType ?? "",
Expand Down
32 changes: 20 additions & 12 deletions frontend/src/pages/Series/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { FunctionComponent, useMemo } from "react";
import { Link } from "react-router-dom";
import { Anchor, Container, Progress } from "@mantine/core";
import { Anchor, Container, Group, Progress } from "@mantine/core";
import { useDocumentTitle } from "@mantine/hooks";
import { faBookmark as farBookmark } from "@fortawesome/free-regular-svg-icons";
import { faBookmark, faWrench } from "@fortawesome/free-solid-svg-icons";
import {
faBookmark,
faPlay,
faStop,
faWrench,
} from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { ColumnDef } from "@tanstack/react-table";
import { useSeriesModification, useSeriesPagination } from "@/apis/hooks";
Expand All @@ -23,16 +28,19 @@ const SeriesView: FunctionComponent = () => {
const columns = useMemo<ColumnDef<Item.Series>[]>(
() => [
{
id: "monitored",
cell: ({
row: {
original: { monitored },
},
}) => (
<FontAwesomeIcon
title={monitored ? "monitored" : "unmonitored"}
icon={monitored ? faBookmark : farBookmark}
></FontAwesomeIcon>
id: "status",
cell: ({ row: { original } }) => (
<Group gap="xs" wrap="nowrap">
<FontAwesomeIcon
title={original.monitored ? "monitored" : "unmonitored"}
icon={original.monitored ? faBookmark : farBookmark}
></FontAwesomeIcon>

<FontAwesomeIcon
title={original.ended ? "Ended" : "Continuing"}
icon={original.ended ? faStop : faPlay}
></FontAwesomeIcon>
</Group>
),
},
{
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/types/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ declare namespace Item {
SeriesIdType & {
episodeFileCount: number;
episodeMissingCount: number;
ended: boolean;
lastAired: string;
seriesType: SonarrSeriesType;
tvdbId: number;
};
Expand Down
38 changes: 38 additions & 0 deletions migrations/versions/4274a5dfc4ad_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""empty message
Revision ID: 4274a5dfc4ad
Revises: 8baf97427327
Create Date: 2024-12-15 21:19:19.406290
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '4274a5dfc4ad'
down_revision = '8baf97427327'
branch_labels = None
depends_on = None

bind = op.get_context().bind
insp = sa.inspect(bind)


def column_exists(table_name, column_name):
columns = insp.get_columns(table_name)
return any(c["name"] == column_name for c in columns)


def upgrade():
if not column_exists('table_shows', 'ended'):
with op.batch_alter_table('table_shows', schema=None) as batch_op:
batch_op.add_column(sa.Column('ended', sa.TEXT(), nullable=True))

if not column_exists('table_shows', 'lastAired'):
with op.batch_alter_table('table_shows', schema=None) as batch_op:
batch_op.add_column(sa.Column('lastAired', sa.TEXT(), nullable=True))


def downgrade():
pass

0 comments on commit c8e2894

Please sign in to comment.