# Path: narwhal/core/torrent/models.py
# class Category(MP_Node):
#     """Categories for Torrents"""
#     #parent = ForeignKey('self', null=True, blank=True, related_name='children', verbose_name=_('Parent'))
#     title = CharField(_('Title'), max_length=80)
#     image = ImageField(_('Image'), upload_to='img/category', blank=True, null=True)
#     plugin = CharField(_('Plugin'), max_length=255, null=True, blank=True)
#     
#     def count(self):
#         count = cache.get('torrent-category-%s-count'%self.id)
#         if not count:
#             count = self.torrents.count()
#             cache.set('torrent-category-%s-count'%self.id, count, 10)
#         return count
#     
#     def __unicode__(self):
#         return smart_unicode(self.title)
#     
#     class Meta:
#         verbose_name = _('category')
#         verbose_name_plural = _('categories')
# 
# Path: narwhal/plugins/video/models.py
# class Video(Torrent):
#     """ ``Video`` Provides a base class for all video plugins to subclass. """
#     
#     def formats(self):
#         return (name.rsplit(".") for name in self.files())
#     formats.verbose_name = _('Formats')
#     
#     def validate(self):
#         super(Video, self).validate() #call default Torrent validator
#         #add validators here
#     
#     class Meta:
#         abstract = True #we add no fields here


from django.db.models import *
from django.utils.translation import ugettext_lazy as _
from narwhal.core.torrent.models import Category
from narwhal.plugins.video.models import Video
from annoying.functions import get_object_or_None
import conf





class Series(Video):
    """ Keeps track of series """
    
    PENDING = 1; RUNNING = 2; ENDED = 3; HIATUS = 4
    STATUS_CHOICES = ((PENDING,_('Pending')), (RUNNING,_('Running')), (ENDED,_('Ended')), (HIATUS,_('Hiatus')))
    
    category     = ForeignKey(Category, verbose_name=_('Category'), default=lambda: get_object_or_None(Category, title=conf.CATEGORY_NAME))
    description  = TextField(_('Description'), blank=True)
    
    status       = SmallIntegerField(_('Status'), max_length=1, choices=STATUS_CHOICES, default=RUNNING)
    first_aired  = DateField(_('First Aired'), null=True)
    next_aired   = DateField(_('Next Aired'), null=True, blank=True)
    metadata_url = CharField(_('IMDB URL'), max_length=255, null=True, blank=True)


# Path: narwhal/core/torrent/models.py
# class Category(MP_Node):
#     """Categories for Torrents"""
#     #parent = ForeignKey('self', null=True, blank=True, related_name='children', verbose_name=_('Parent'))
#     title = CharField(_('Title'), max_length=80)
#     image = ImageField(_('Image'), upload_to='img/category', blank=True, null=True)
#     plugin = CharField(_('Plugin'), max_length=255, null=True, blank=True)
#     
#     def count(self):
#         count = cache.get('torrent-category-%s-count'%self.id)
#         if not count:
#             count = self.torrents.count()
#             cache.set('torrent-category-%s-count'%self.id, count, 10)
#         return count
#     
#     def __unicode__(self):
#         return smart_unicode(self.title)
#     
#     class Meta:
#         verbose_name = _('category')
#         verbose_name_plural = _('categories')
# 
# Path: narwhal/plugins/video/models.py
# class Video(Torrent):
#     """ ``Video`` Provides a base class for all video plugins to subclass. """
#     
#     def formats(self):
#         return (name.rsplit(".") for name in self.files())
#     formats.verbose_name = _('Formats')
#     
#     def validate(self):
#         super(Video, self).validate() #call default Torrent validator
#         #add validators here
#     
#     class Meta:
#         abstract = True #we add no fields here


# Path: narwhal/plugins/video/tv/models.py
from django.db.models import *
from django.utils.translation import ugettext_lazy as _
from narwhal.core.torrent.models import Category
from narwhal.plugins.video.models import Video
from annoying.functions import get_object_or_None
import conf





class Series(Video):
    """ Keeps track of series """
    
    PENDING = 1; RUNNING = 2; ENDED = 3; HIATUS = 4
    STATUS_CHOICES = ((PENDING,_('Pending')), (RUNNING,_('Running')), (ENDED,_('Ended')), (HIATUS,_('Hiatus')))
    
    category     = ForeignKey(Category, verbose_name=_('Category'), default=lambda: get_object_or_None(Category, title=conf.CATEGORY_NAME))
    description  = TextField(_('Description'), blank=True)
    
    status       = SmallIntegerField(_('Status'), max_length=1, choices=STATUS_CHOICES, default=RUNNING)
    first_aired  = DateField(_('First Aired'), null=True)
    next_aired   = DateField(_('Next Aired'), null=True, blank=True)
    metadata_url = CharField(_('IMDB URL'), max_length=255, null=True, blank=True)


class TVShow(Video):
