RuudBurger/CouchPotatoServer — pull request #2057 by nrgaway (2013-08-23 05:56:55+00:00)
Title: Completed tvshow model

The database model is complete now. Have a peek in models.py I decided it was better to use Inheritance on the Library model because some things will need to be indexed to provide quick fucntions.

Once you have loaded the ShowLibrary object from the database you can access seasons like this:
library[1] # Season 1
library.get(1) # Season 1
library.children # list of season objects
library.getSeasons() # Ordered dictionary of seasons where the key is the season_number
library.getEpisodesSeasons(season_number) # Ordered dictionary of episodes where the key is the episode_number

library.[1][4] # Season 1, episode 4 object
library.get(1).get(4) # same
library.children[1].children # you cant be guaranteed this is season 1 here

an episode can find its season object like
library.parent
and show object like:
library.parent.parent

I am submitting another pull request right after this one that does contain all the patches this one does plus the refactoring.

PULL THIS ONE FIRST :)