mirror of
https://github.com/Xevion/the-office.git
synced 2025-12-10 14:08:56 -06:00
finish episode builder, change deleted scene handler to use -1 for false and track nth Deleted Scene
This commit is contained in:
@@ -34,7 +34,7 @@ class Season(db.Model):
|
|||||||
@property
|
@property
|
||||||
def episodes(self):
|
def episodes(self):
|
||||||
"""returns a List of Episodes under this Season"""
|
"""returns a List of Episodes under this Season"""
|
||||||
return Episode.query.filter_by(season=self).all()
|
return Episode.query.filter_by(season=self).all().sort(key=lambda ep : ep.number)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def characters(self, sort):
|
def characters(self, sort):
|
||||||
@@ -55,11 +55,12 @@ class Episode(db.Model):
|
|||||||
soup = BeautifulSoup(data, 'html.parser')
|
soup = BeautifulSoup(data, 'html.parser')
|
||||||
|
|
||||||
sections = soup.find_all(attrs={'class' : 'quote'})
|
sections = soup.find_all(attrs={'class' : 'quote'})
|
||||||
|
deleted = 0
|
||||||
for section in sections:
|
for section in sections:
|
||||||
quotes = []
|
quotes = [quote.string + quote.next_sibling.string for quote in section.find_all('b')]
|
||||||
for quote in section.find_all("b"):
|
isDeletedScene = quotes[0].lower().startswith('deleted scene')
|
||||||
quotes.append(quote.string + quote.next_sibling.string)
|
if isDeletedScene: deleted += 1
|
||||||
deleted = quotes[0].startswith('Deleted Scene'):
|
s = Section(episode=self, deleted=deleted if isDeletedScene else -1, quotes=)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def scrapeURL(self):
|
def scrapeURL(self):
|
||||||
@@ -69,7 +70,7 @@ class Section(db.Model):
|
|||||||
"""represents a Section of Quotes, a specific scene with relevant dialog"""
|
"""represents a Section of Quotes, a specific scene with relevant dialog"""
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
episode_id = db.Column(db.Integer, db.ForeignKey('episode.id'))
|
episode_id = db.Column(db.Integer, db.ForeignKey('episode.id'))
|
||||||
deleted = db.Column(db.Boolean)
|
deleted = db.Column(db.Integer, default=-1)
|
||||||
quotes = db.relationship('Quote', backref='section', lazy='dynamic')
|
quotes = db.relationship('Quote', backref='section', lazy='dynamic')
|
||||||
|
|
||||||
def build(self, quotes, commit=False):
|
def build(self, quotes, commit=False):
|
||||||
|
|||||||
Reference in New Issue
Block a user