mirror of
https://github.com/Xevion/the-office.git
synced 2025-12-10 02:08:48 -06:00
start building Section builder, Episode builder
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
from app import db, login
|
from app import db, login
|
||||||
|
|
||||||
episodes = [5, 6, 22, 23, 14, 26, 24, 24, 24, 23]
|
episodes = [5, 6, 22, 23, 14, 26, 24, 24, 24, 23]
|
||||||
@@ -43,16 +45,25 @@ class Episode(db.Model):
|
|||||||
season_id = db.Column(db.Integer, db.ForeignKey('season.id')) # correlating season number
|
season_id = db.Column(db.Integer, db.ForeignKey('season.id')) # correlating season number
|
||||||
sections = db.relationship('Section', backref='episode', lazy='dynamic') # sections of quotes under this episode
|
sections = db.relationship('Section', backref='episode', lazy='dynamic') # sections of quotes under this episode
|
||||||
|
|
||||||
|
def build(self):
|
||||||
|
"""Downloads, processes, and automatically creates Sections and Quotes"""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def scrapeURL(self):
|
def scrapeURL(self):
|
||||||
return f'http://officequotes.net/no{self.season_id}-{str(self.number).zfill(2)}.php'
|
return f'http://officequotes.net/no{self.season_id}-{str(self.number).zfill(2)}.php'
|
||||||
|
|
||||||
class Section(db.Model):
|
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'))
|
||||||
quotes = db.relationship('Quote', backref='section', lazy='dynamic')
|
quotes = db.relationship('Quote', backref='section', lazy='dynamic')
|
||||||
|
|
||||||
|
def build(self, quotes):
|
||||||
|
"""given an List of unformatted script quotes, automatically creates Quotes"""
|
||||||
|
for quote in quotes:
|
||||||
|
match = re.match(r'()')
|
||||||
|
assert match != None, "Quote '{}' could not be processed.".format(quote)
|
||||||
|
|
||||||
class Quote(db.Model):
|
class Quote(db.Model):
|
||||||
"""represents a specific quote by a specific speaker"""
|
"""represents a specific quote by a specific speaker"""
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user