mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-04-17 15:13:24 +02:00
Support for handling Single Episode Torrents (#331)
**Description** As explained on #322, MediaManager currently only matches torrents that represent full seasons or season packs. As a result, valid episode-based releases — commonly returned by indexers such as EZTV — are filtered out during scoring and never considered for download. Initial changes to the season parsing logic allow these torrents to be discovered. However, additional changes are required beyond season parsing to properly support single-episode imports. This PR is intended as a work-in-progress / RFC to discuss the required changes and align on the correct approach before completing the implementation. **Things planned to do** [X] Update Web UI to better display episode-level details [ ] Update TV show import logic to handle single episode files, instead of assuming full season files (to avoid integrity errors when episodes are missing) [ ] Create episode file tables to store episode-level data, similar to season files [ ] Implement fetching and downloading logic for single-episode torrents **Notes / current limitations** At the moment, the database and import logic assume one file per season per quality, which works for season packs but not for episode-based releases. These changes are intentionally not completed yet and are part of the discussion this PR aims to start. **Request for feedback** This represents a significant change in how TV content is handled in MediaManager. Before proceeding further, feedback from @maxdorninger on the overall direction and next steps would be greatly appreciated. Once aligned, the remaining tasks can be implemented incrementally. --------- Co-authored-by: Maximilian Dorninger <97409287+maxdorninger@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -35,8 +35,8 @@ from media_manager.notification.models import Notification # noqa: E402
|
||||
from media_manager.torrent.models import Torrent # noqa: E402
|
||||
from media_manager.tv.models import ( # noqa: E402
|
||||
Episode,
|
||||
EpisodeFile,
|
||||
Season,
|
||||
SeasonFile,
|
||||
SeasonRequest,
|
||||
Show,
|
||||
)
|
||||
@@ -47,6 +47,7 @@ target_metadata = Base.metadata
|
||||
# noinspection PyStatementEffect
|
||||
__all__ = [
|
||||
"Episode",
|
||||
"EpisodeFile",
|
||||
"IndexerQueryResult",
|
||||
"Movie",
|
||||
"MovieFile",
|
||||
@@ -54,7 +55,6 @@ __all__ = [
|
||||
"Notification",
|
||||
"OAuthAccount",
|
||||
"Season",
|
||||
"SeasonFile",
|
||||
"SeasonRequest",
|
||||
"Show",
|
||||
"Torrent",
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
"""create episode file table and add episode column to indexerqueryresult
|
||||
|
||||
Revision ID: 3a8fbd71e2c2
|
||||
Revises: 9f3c1b2a4d8e
|
||||
Create Date: 2026-01-08 13:43:00
|
||||
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
from sqlalchemy.dialects import postgresql
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = "3a8fbd71e2c2"
|
||||
down_revision: Union[str, None] = "9f3c1b2a4d8e"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
quality_enum = postgresql.ENUM("uhd", "fullhd", "hd", "sd", "unknown", name="quality",
|
||||
create_type=False,
|
||||
)
|
||||
# Create episode file table
|
||||
op.create_table(
|
||||
"episode_file",
|
||||
sa.Column("episode_id", sa.UUID(), nullable=False),
|
||||
sa.Column("torrent_id", sa.UUID(), nullable=True),
|
||||
sa.Column("file_path_suffix", sa.String(), nullable=False),
|
||||
sa.Column("quality", quality_enum, nullable=False),
|
||||
sa.ForeignKeyConstraint(["episode_id"], ["episode.id"], ondelete="CASCADE"),
|
||||
sa.ForeignKeyConstraint(["torrent_id"], ["torrent.id"], ondelete="SET NULL"),
|
||||
sa.PrimaryKeyConstraint("episode_id", "file_path_suffix"),
|
||||
)
|
||||
# Add episode column to indexerqueryresult
|
||||
op.add_column(
|
||||
"indexer_query_result", sa.Column("episode", postgresql.ARRAY(sa.Integer()), nullable=True),
|
||||
)
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_table("episode_file")
|
||||
op.drop_column("indexer_query_result", "episode")
|
||||
@@ -0,0 +1,31 @@
|
||||
"""add overview column to episode table
|
||||
|
||||
Revision ID: 9f3c1b2a4d8e
|
||||
Revises: 2c61f662ca9e
|
||||
Create Date: 2025-12-29 21:45:00
|
||||
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = "9f3c1b2a4d8e"
|
||||
down_revision: Union[str, None] = "2c61f662ca9e"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# Add overview to episode table
|
||||
op.add_column(
|
||||
"episode",
|
||||
sa.Column("overview", sa.Text(), nullable=True),
|
||||
)
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_column("episode", "overview")
|
||||
|
||||
Reference in New Issue
Block a user