Exemplo n.º 1
0
class File(Entity):
    """File that belongs to a release."""

    path = Field(Unicode(255), nullable = False, unique = True)
    part = Field(Integer, default = 1)
    available = Field(Boolean, default = True)

    type = ManyToOne('FileType')
    properties = OneToMany('FileProperty')

    history = OneToMany('RenameHistory')
    movie = ManyToMany('Movie')
    release = ManyToMany('Release')
    library = ManyToMany('Library')
Exemplo n.º 2
0
class Release(Entity):
    """Logically groups all files that belong to a certain release, such as
    parts of a movie, subtitles."""

    identifier = Field(String(100), index=True)

    movie = ManyToOne('Movie')
    status = ManyToOne('Status')
    quality = ManyToOne('Quality')
    files = ManyToMany('File',
                       cascade='all, delete-orphan',
                       single_parent=True)
    info = OneToMany('ReleaseInfo', cascade='all, delete-orphan')

    def to_dict(self, deep={}, exclude=[]):
        orig_dict = super(Release, self).to_dict(deep=deep, exclude=exclude)

        new_info = {}
        for info in orig_dict.get('info', []):

            value = info['value']
            try:
                value = int(info['value'])
            except:
                pass

            new_info[info['identifier']] = value

        orig_dict['info'] = new_info

        return orig_dict
Exemplo n.º 3
0
class Release(Entity):
    """Logically groups all files that belong to a certain release, such as
    parts of a movie, subtitles."""

    last_edit = Field(Integer, default = lambda: int(time.time()), index = True)
    identifier = Field(String(100), index = True)

    movie = ManyToOne('Movie')
    status = ManyToOne('Status')
    quality = ManyToOne('Quality')
    files = ManyToMany('File')
    info = OneToMany('ReleaseInfo', cascade = 'all, delete-orphan')

    def to_dict(self, deep = None, exclude = None):
        if not exclude: exclude = []
        if not deep: deep = {}

        orig_dict = super(Release, self).to_dict(deep = deep, exclude = exclude)

        new_info = {}
        for info in orig_dict.get('info', []):

            value = info['value']
            try: value = int(info['value'])
            except: pass

            new_info[info['identifier']] = value

        orig_dict['info'] = new_info

        return orig_dict
Exemplo n.º 4
0
class Release(Entity):
    """Logically groups all files that belong to a certain release, such as
    parts of a movie, subtitles."""

    identifier = Field(String(100))

    movie = ManyToOne('Movie')
    status = ManyToOne('Status')
    quality = ManyToOne('Quality')
    files = ManyToMany('File')
    history = OneToMany('History')
    info = OneToMany('ReleaseInfo')
Exemplo n.º 5
0
class Movie(Entity):
    """Movie Resource a movie could have multiple releases
    The files belonging to the movie object are global for the whole movie
    such as trailers, nfo, thumbnails"""

    last_edit = Field(Integer)

    library = ManyToOne('Library')
    status = ManyToOne('Status')
    profile = ManyToOne('Profile')
    releases = OneToMany('Release')
    files = ManyToMany('File')
Exemplo n.º 6
0
class Library(Entity):
    """"""

    year = Field(Integer)
    identifier = Field(String(20), index = True)

    plot = Field(UnicodeText)
    tagline = Field(UnicodeText(255))
    info = Field(JsonType)

    status = ManyToOne('Status')
    movies = OneToMany('Movie', cascade = 'all, delete-orphan')
    titles = OneToMany('LibraryTitle', cascade = 'all, delete-orphan')
    files = ManyToMany('File', cascade = 'all, delete-orphan', single_parent = True)
Exemplo n.º 7
0
class Movie(Entity):
    """Movie Resource a movie could have multiple releases
    The files belonging to the movie object are global for the whole movie
    such as trailers, nfo, thumbnails"""

    last_edit = Field(Integer, default = lambda: int(time.time()), index = True)
    type = 'movie'  # Compat tv branch

    library = ManyToOne('Library', cascade = 'delete, delete-orphan', single_parent = True)
    status = ManyToOne('Status')
    profile = ManyToOne('Profile')
    category = ManyToOne('Category')
    releases = OneToMany('Release', cascade = 'all, delete-orphan')
    files = ManyToMany('File', cascade = 'all, delete-orphan', single_parent = True)
Exemplo n.º 8
0
class Media(Entity):
    """Media Resource could have multiple releases
    The files belonging to the media object are global for the whole media
    such as trailers, nfo, thumbnails"""

    type = Field(String(10), default="movie", index=True)
    last_edit = Field(Integer, default=lambda: int(time.time()), index=True)

    library = ManyToOne('Library',
                        cascade='delete, delete-orphan',
                        single_parent=True)
    status = ManyToOne('Status')
    profile = ManyToOne('Profile')
    category = ManyToOne('Category')
    releases = OneToMany('Release', cascade='all, delete-orphan')
    files = ManyToMany('File',
                       cascade='all, delete-orphan',
                       single_parent=True)
Exemplo n.º 9
0
class Library(Entity):
    """"""

    year = Field(Integer)
    identifier = Field(String(20))
    rating = Field(Float)

    plot = Field(UnicodeText)
    tagline = Field(UnicodeText(255))

    status = ManyToOne('Status')
    movies = OneToMany('Movie')
    titles = OneToMany('LibraryTitle')
    files = ManyToMany('File')
    info = OneToMany('LibraryInfo')

    def title(self):
        return self.titles[0]['title']
Exemplo n.º 10
0
class Library(Entity):
    """"""
    using_options(inheritance='multi')

    # For Movies, CPS uses three: omdbapi (no prio !?), tmdb (prio 2) and couchpotatoapi (prio 1)
    type = Field(String(10), default="movie", index=True)
    primary_provider = Field(String(10), default="imdb", index=True)
    year = Field(Integer)
    identifier = Field(String(40), index=True)

    plot = Field(UnicodeText)
    tagline = Field(UnicodeText(255))
    info = Field(JsonType)

    status = ManyToOne('Status')
    media = OneToMany('Media', cascade='all, delete-orphan')
    titles = OneToMany('LibraryTitle', cascade='all, delete-orphan')
    files = ManyToMany('File',
                       cascade='all, delete-orphan',
                       single_parent=True)

    parent = ManyToOne('Library')
    children = OneToMany('Library')