diff --git a/couchpotato/core/settings/model.py b/couchpotato/core/settings/model.py index 860c2e1..8615c87 100644 --- a/couchpotato/core/settings/model.py +++ b/couchpotato/core/settings/model.py @@ -5,7 +5,7 @@ from elixir.options import options_defaults, using_options from elixir.relationships import ManyToMany, OneToMany, ManyToOne from sqlalchemy.ext.mutable import Mutable from sqlalchemy.types import Integer, Unicode, UnicodeText, Boolean, String, \ - TypeDecorator + TypeDecorator, Float, BLOB import json import time @@ -114,7 +114,143 @@ class LibraryTitle(Entity): language = OneToMany('Language') libraries = ManyToOne('Library') + +class Show(Entity): + """Combined Show and Library""" + + using_options(order_by = '-default') # ??? + + last_edit = Field(Integer, default = lambda: int(time.time()), index = True) + #identifier = Field(String(20), index = True) + + title = Field(Unicode) # Show title + simple_title = Field(Unicode, index = True) # Simple show title + default = Field(Boolean, default = False, index = True) # ??? + + ## Wont need the following commented out vars since a show can not be downloaded, + ## only episodes can be + ##status = ManyToOne('Status') # Download, watched, etc + ##releases = OneToMany('Release', cascade = 'all, delete-orphan') # List all available releases that can be downloaded? + ##files = ManyToMany('File', cascade = 'all, delete-orphan', single_parent = True) # File on hard drive + profile = ManyToOne('Profile') # ??? Quality ??? + category = ManyToOne('Category') # ??? + language = OneToMany('Language') # Language ??? (en) ??? + + # New fields + air_by_date = Field(Boolean, default=False) # True if no season or episode number + original_air_date = Field(Integer) # First date ever released + year = Field(Integer) # 1983 + air_day = Field(Integer) # Monday, Tuesday... + air_time = Field(Integer) # 8PM EST + series_id = Field(Integer) # Series id + show_stauts = Field(Integer) # Continuing, Ended + + duration = Field(Integer) # Length of show in seconds + summary = Field(Unicode) # Description of show + network = Field(Unicode) # ABC, Fox + rating = Field(Float) # 0.000-10.000 (star rating) + content_rating = Field(Unicode) # "TV-PG" + + default_provider = Field(Integer, default=0)# thetvdb for example; allows per show providers + + genre = ManyToMany('Genre') # Genre (comedy, etc) + episodes = OneToMany('Episode') # All the episodes that belong to this show + seasons = ManyToOne('Season') # Seasons artwork + banners = ManyToOne('Banner') # Banner artwork + posters = ManyToOne('Poster') # Poster artwork + fanart = ManyToOne('Fanart') # Fanart artwork + actors = ManyToMany('Actor') # Actor info and artwork + provider_ids = ManyToMany('ProviderIds') # 'imdb_id', 'zap2it_id', 'tvrage' + titles = OneToMany('ShowTitle', cascade = 'all, delete-orphan') + + +class ShowTitle(Entity): + """""" + using_options(order_by = '-default') + title = Field(Unicode) + simple_title = Field(Unicode, index = True) + default = Field(Boolean, default = False, index = True) + + language = OneToMany('Language') + shows = ManyToOne('Show') + + +class Episode(Entity): + """Combined Show and Library""" + + #using_options(order_by = '-default') # ??? + #identifier = Field(String(20), index = True) + + last_edit = Field(Integer, default = lambda: int(time.time()), index = True) + title = Field(Unicode) # Show title + simple_title = Field(Unicode, index = True) # Simple show title + default = Field(Boolean, default = False, index = True) # ??? + + status = ManyToOne('Status') # Download, watched, etc + profile = ManyToOne('Profile') # ??? Quality ??? + category = ManyToOne('Category') # ??? + releases = OneToMany('Release', cascade = 'all, delete-orphan') # List all available releases that can be downloaded? + files = ManyToMany('File', cascade = 'all, delete-orphan', single_parent = True) # File on hard drive + language = OneToMany('Language') # Language ??? (en) ??? + + # New fields + season = Field(Integer) # Season number + number = Field(Integer) # Episode number + image = Field(BLOB) # Episode Image (XXX: What to do with images?) + air_date = Field(Integer) # Origianl air date + duration = Field(Integer) # Length of show (24:34) in seconds + summary = Field(Unicode) # Description of show + rating = Field(Float) # 0.000-10.000 (star rating) + content_rating = Field(Unicode) # "TV-PG" + production_code = Field(Unicode) # Production code (should this be an Integer) + + show = ManyToOne('Show') # Parent show + actors = ManyToMany('Actor') # Guest Actor info and artwork + directors = ManyToMany('Director') # Directors of episode + writers = ManyToMany('Writer') # Writers of episode + provider_ids = ManyToMany('ProviderIds') # 'imdb_id', 'zap2it_id', 'tvrage' + + +class Fanart(Entity): + """Stub for Now""" + show = OneToMany('Show') + +class Actor(Entity): + """Stub for Now""" + shows = ManyToMany('Show') + episodes = ManyToMany('Episode') + +class Director(Entity): + """Stub for Now""" + episodes = ManyToMany('Episode') + +class Writer(Entity): + """Stub for Now""" + episodes = ManyToMany('Episode') + +class Genre(Entity): + """Stub for Now""" + shows = ManyToMany('Show') + +class Season(Entity): + """Stub for Now""" + show = OneToMany('Show') + +class Banner(Entity): + """Stub for Now""" + show = OneToMany('Show') + +class Poster(Entity): + """Stub for Now""" + show = OneToMany('Show') + +class ProviderIds(Entity): + """Stub for Now""" + shows = ManyToMany('Show') + episodes = ManyToMany('Episode') + + class Language(Entity): """""" @@ -122,6 +258,9 @@ class Language(Entity): label = Field(Unicode) titles = ManyToOne('LibraryTitle') + show_titles = ManyToOne('ShowTitle') + show = ManyToOne('Show') + episode = ManyToOne('Episode') class Release(Entity): @@ -132,6 +271,7 @@ class Release(Entity): identifier = Field(String(100), index = True) movie = ManyToOne('Movie') + episode = ManyToOne('Episode') status = ManyToOne('Status') quality = ManyToOne('Quality') files = ManyToMany('File') @@ -171,6 +311,7 @@ class Status(Entity): releases = OneToMany('Release') movies = OneToMany('Movie') + episodes = OneToMany('Episode') class Quality(Entity): @@ -198,6 +339,8 @@ class Profile(Entity): hide = Field(Boolean, default = False) movie = OneToMany('Movie') + show = OneToMany('Show') + episode = OneToMany('Episode') types = OneToMany('ProfileType', cascade = 'all, delete-orphan') def to_dict(self, deep = {}, exclude = []): @@ -218,6 +361,8 @@ class Category(Entity): ignored = Field(Unicode(255)) movie = OneToMany('Movie') + show = OneToMany('Show') + episode = OneToMany('Episode') destination = ManyToOne('Destination') @@ -253,6 +398,7 @@ class File(Entity): history = OneToMany('RenameHistory') movie = ManyToMany('Movie') + episodes = ManyToMany('Episode') release = ManyToMany('Release') library = ManyToMany('Library')