Skip to content

Latest commit

 

History

History
144 lines (113 loc) · 5.07 KB

File metadata and controls

144 lines (113 loc) · 5.07 KB

Season Support Implementation for Shows and Anime

Overview

This implementation adds comprehensive season support to the ContinueJS media tracking application for TV Shows and Anime. It handles the complexity of different API responses and provides a flexible system for tracking progress across seasons.

🎯 Solutions Implemented

1. Flexible Season Data Model

  • SeasonInfo interface handles multiple season representation formats
  • Supports both explicit season selection and automatic detection
  • Handles API inconsistencies gracefully

2. API Integration

  • Anime (Jikan API): Extracts season info from titles + manual override
  • TV Shows (TMDB API): Fetches detailed season information with episode counts
  • Season Detection: Smart parsing of anime titles for season numbers

3. User Experience

  • Automatic Season Detection: For anime titles like "Attack on Titan Season 2"
  • Manual Season Selection: For shows with multiple seasons
  • Season Display: Shows current season and progress in cards
  • Flexible Input: Manual season input for edge cases

🔧 Key Features

Season-Aware Progress Tracking

// Example: Attack on Titan Season 2, Episode 5
"S2E5 of 12" instead of "Episode 17 of 25"

Smart Season Detection

extractSeasonFromAnimeTitle("Attack on Titan Season 2")
// → { seasonNumber: 2, cleanTitle: "Attack on Titan" }

Multi-Season Show Support

// Game of Thrones - User selects Season 3
// Progress shows: "S3E7 of 10" + "Season 3 of 8"

🎬 Example Usage Scenarios

Scenario 1: Adding Attack on Titan Season 2

  1. User searches "Attack on Titan"
  2. Results show "Attack on Titan Season 2"
  3. System detects season automatically
  4. Shows: "Season 2 (Spring 2017) • 12 episodes"
  5. Progress tracks as "S2E5 of 12"

Scenario 2: Adding Game of Thrones

  1. User searches "Game of Thrones"
  2. System fetches show details (8 seasons)
  3. User selects "Season 3" (10 episodes)
  4. Progress tracks as "S3E7 of 10 • Season 3 of 8"

Scenario 3: Continuing Anime Series

  1. User has "Attack on Titan" Season 1 completed
  2. Adds Season 2 → automatically detects as separate season
  3. Both seasons tracked independently with proper progress

🛠️ Technical Implementation

Core Files Added/Modified:

  1. /lib/types.ts - Added SeasonInfo interface and extended existing types
  2. /lib/season-utils.ts - Season detection, formatting, and progress utilities
  3. /api/media/show-details/[id]/route.ts - New endpoint for detailed show info
  4. /components/media/AddMediaDialog.tsx - Season selection UI
  5. /components/media/MediaCard.tsx - Season display in cards
  6. /components/media/EditMediaDialog.tsx - Season editing support
  7. /lib/media-utils.ts - Season-aware progress display

Key Data Structures:

interface SeasonInfo {
  currentSeason?: number;        // Which season user is watching
  totalSeasons?: number;         // Total seasons available  
  seasonName?: string;           // Custom name (e.g., "Final Season")
  episodesInSeason?: number;     // Episodes in current season
  seasonYear?: number;           // Year the season aired
  seasonPeriod?: string;         // Spring/Summer/Fall/Winter for anime
}

API Response Handling:

// Anime API (Jikan) - Multiple entries per season
[
  { title: "Attack on Titan", season: "spring", year: 2013 },
  { title: "Attack on Titan Season 2", season: "spring", year: 2017 },
  { title: "Attack on Titan Season 3", season: "summer", year: 2018 }
]

// TV Show API (TMDB) - Single entry with season details
{
  name: "Game of Thrones",
  number_of_seasons: 8,
  seasons: [
    { season_number: 1, episode_count: 10, name: "Season 1" },
    { season_number: 2, episode_count: 10, name: "Season 2" },
    // ...
  ]
}

🚀 Benefits

  1. Accurate Progress Tracking - Users see exactly which episode of which season they're on
  2. API Flexibility - Works with different API response formats
  3. User Choice - Manual override for complex cases
  4. Backwards Compatibility - Existing media continues to work
  5. Future-Proof - Extensible for other media types with seasons

📱 UI Components

Season Selection Dialog

  • Displays available seasons with episode counts
  • Allows manual season number input
  • Shows season metadata (year, period)

Media Card Display

  • Season badge with calendar icon
  • Formatted season info (e.g., "Season 2 (2017)")
  • Season-aware progress display

Edit Dialog

  • Shows current season information
  • Option to change season selection

🔮 Future Enhancements

  1. Season Auto-Progression - Automatically suggest next season when current is completed
  2. Season Collections - Group related seasons in UI
  3. Binge Progress - Track watching multiple seasons in sequence
  4. Season Recommendations - Suggest related seasons based on completion
  5. Season Analytics - Show watching patterns across seasons

This implementation provides a robust foundation for season tracking while maintaining simplicity and user control.