mirror of
https://github.com/Xevion/the-office.git
synced 2025-12-14 16:13:19 -06:00
undo column sizing, fix linearly expanding datasets (lag), fix episode ranges being incorrect, more print statements
This commit is contained in:
@@ -18,7 +18,7 @@ episodes = [
|
|||||||
23,
|
23,
|
||||||
] # Episode counts. Index 0 is for Webisodes.
|
] # Episode counts. Index 0 is for Webisodes.
|
||||||
quotePattern = r"([\w\s\.\',-\[\]\d&\"#]+):(.+)"
|
quotePattern = r"([\w\s\.\',-\[\]\d&\"#]+):(.+)"
|
||||||
with open(os.path.join('app', 'static', 'titles.json')) as file:
|
with open(os.path.join('app', 'static', 'titles.json'), 'r', encoding="utf-8") as file:
|
||||||
titles = json.load(file)
|
titles = json.load(file)
|
||||||
|
|
||||||
class Season(db.Model):
|
class Season(db.Model):
|
||||||
@@ -32,7 +32,7 @@ class Season(db.Model):
|
|||||||
def build(self, rebuild=False):
|
def build(self, rebuild=False):
|
||||||
"""runs build operations on every Episode under this season"""
|
"""runs build operations on every Episode under this season"""
|
||||||
print(f"Running build() on Season {self.id}")
|
print(f"Running build() on Season {self.id}")
|
||||||
for episode in range(1, episodes[self.id - 1] + 1):
|
for episode in range(1, episodes[self.id] + 1):
|
||||||
ep = Episode.query.filter_by(season_id=self.id, number=episode).first()
|
ep = Episode.query.filter_by(season_id=self.id, number=episode).first()
|
||||||
if ep is None:
|
if ep is None:
|
||||||
# Add the episode, then build
|
# Add the episode, then build
|
||||||
@@ -51,7 +51,7 @@ class Season(db.Model):
|
|||||||
def download(self, force=False):
|
def download(self, force=False):
|
||||||
episodes = Episode.query.filter_by(season_id=self.id).all()
|
episodes = Episode.query.filter_by(season_id=self.id).all()
|
||||||
for ep in episodes:
|
for ep in episodes:
|
||||||
ep.build(force=force)
|
ep.rebuild()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_all(build=True):
|
def create_all(build=True):
|
||||||
@@ -68,7 +68,7 @@ class Season(db.Model):
|
|||||||
def rebuild_all():
|
def rebuild_all():
|
||||||
"""runs build() on all Season objects in database"""
|
"""runs build() on all Season objects in database"""
|
||||||
for season in Season.query.all():
|
for season in Season.query.all():
|
||||||
season.build(rebuild=True)
|
season.rebuild()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def episodes(self):
|
def episodes(self):
|
||||||
@@ -122,6 +122,7 @@ class Episode(db.Model):
|
|||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
"""downloads, processes, and automatically creates Sections and Quotes"""
|
"""downloads, processes, and automatically creates Sections and Quotes"""
|
||||||
|
print(f'Rebuilding s{self.season_id} e{self.number}')
|
||||||
self.download()
|
self.download()
|
||||||
soup = BeautifulSoup(self.data, "html.parser")
|
soup = BeautifulSoup(self.data, "html.parser")
|
||||||
|
|
||||||
@@ -153,11 +154,13 @@ class Episode(db.Model):
|
|||||||
s.build(quotes[1:] if isDeletedScene else quotes)
|
s.build(quotes[1:] if isDeletedScene else quotes)
|
||||||
db.session.add(s)
|
db.session.add(s)
|
||||||
self.built = True
|
self.built = True
|
||||||
self.title = titles[self.season_id - 1][self.number - 1]
|
self.title = titles[self.season_id][self.number - 1]
|
||||||
|
print(self.title)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
def rebuild(self):
|
def rebuild(self):
|
||||||
"""functions that clears relevant sections from this Episode"""
|
"""functions that clears relevant sections from this Episode"""
|
||||||
|
print(f'Rebuilding s{self.season_id} e{self.number}')
|
||||||
self.clear()
|
self.clear()
|
||||||
self.build()
|
self.build()
|
||||||
|
|
||||||
@@ -175,6 +178,7 @@ class Episode(db.Model):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def clear_all():
|
def clear_all():
|
||||||
"""runs clear() on every episode in the database"""
|
"""runs clear() on every episode in the database"""
|
||||||
|
print('Clearing all episodes in database.')
|
||||||
for episode in Episode.query.all():
|
for episode in Episode.query.all():
|
||||||
episode.clear()
|
episode.clear()
|
||||||
|
|
||||||
@@ -213,7 +217,7 @@ class Section(db.Model):
|
|||||||
if commit:
|
if commit:
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
def clear(self, doprint=True, commit=True, delete=False):
|
def clear(self, doprint=False, commit=True, delete=False):
|
||||||
"""delete all quotes relevant to this section"""
|
"""delete all quotes relevant to this section"""
|
||||||
quotes = Quote.query.filter_by(section_id=self.id).all()
|
quotes = Quote.query.filter_by(section_id=self.id).all()
|
||||||
if doprint:
|
if doprint:
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ def viewSeason(season):
|
|||||||
def viewEpisode(season, episode):
|
def viewEpisode(season, episode):
|
||||||
e = Episode.query.filter_by(season_id=season, number=episode).first_or_404()
|
e = Episode.query.filter_by(season_id=season, number=episode).first_or_404()
|
||||||
if not e.built:
|
if not e.built:
|
||||||
print("Rebuilding")
|
print(f"Rebuilding s{season} e{episode}")
|
||||||
e.build()
|
e.build()
|
||||||
return render_template("episode.html", episode=e, seasons=Season.query.all())
|
return render_template("episode.html", episode=e, seasons=Season.query.all())
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<div class="columns is-centered">
|
<div class="columns is-centered">
|
||||||
<div class="column is-4"></div>
|
<div class="column is-4"></div>
|
||||||
{# Site Directory #}
|
{# Site Directory #}
|
||||||
<div class="column is-2 is-narrow">
|
<div class="column is-narrow">
|
||||||
<div class="box">
|
<div class="box">
|
||||||
{# List of Seasons/Episodes #}
|
{# List of Seasons/Episodes #}
|
||||||
{% for season in seasons %}
|
{% for season in seasons %}
|
||||||
|
|||||||
Reference in New Issue
Block a user