mirror of
https://github.com/Xevion/the-office.git
synced 2025-12-17 12:13:38 -06:00
path/data properties split into HTML and XML, begin making preprocessing functions
This commit is contained in:
@@ -70,11 +70,6 @@ class Season(db.Model):
|
|||||||
for season in Season.query.all():
|
for season in Season.query.all():
|
||||||
season.rebuild()
|
season.rebuild()
|
||||||
|
|
||||||
@property
|
|
||||||
def episodes(self):
|
|
||||||
"""returns a List of Episodes under this Season"""
|
|
||||||
return Episode.query.filter_by(season_id=self.id).all()
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def characters(self, sort):
|
def characters(self, sort):
|
||||||
"""returns a List of Characters under this Season, sorted by number of spoken lines"""
|
"""returns a List of Characters under this Season, sorted by number of spoken lines"""
|
||||||
@@ -102,8 +97,20 @@ class Episode(db.Model):
|
|||||||
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"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def path(self):
|
def HTMLpath(self):
|
||||||
return os.path.join("app", "data", f"{self.season_id}-{self.number}.html")
|
return os.path.join("app", "data", "raw", f"{self.season_id}-{self.number}.html")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def HTMLdata(self):
|
||||||
|
return open(self.HTMLpath, "r", encoding="utf-8").read()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def XMLpath(self):
|
||||||
|
return os.path.join("app", "data", "preprocess", f"{self.season_id}-{self.number}.xml")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def XMLdata(self):
|
||||||
|
return open(self.XMLpath, "r", encoding="utf-8").read()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def downloaded(self):
|
def downloaded(self):
|
||||||
@@ -116,9 +123,16 @@ class Episode(db.Model):
|
|||||||
data = requests.get(self.link).text
|
data = requests.get(self.link).text
|
||||||
open(self.path, "w+", encoding="utf-8").write(data)
|
open(self.path, "w+", encoding="utf-8").write(data)
|
||||||
|
|
||||||
@property
|
def preprocess(self):
|
||||||
def data(self):
|
"""
|
||||||
return open(self.path, "r", encoding="utf-8").read()
|
Runs pre-processing on this Episode, which creates and automatically formats a XML file full of the data
|
||||||
|
required to create a Episode properly, right before the Developer edits a episode and then enters it into the
|
||||||
|
database as a full fledged 'processed' episode.
|
||||||
|
"""
|
||||||
|
print(f'Pre-processing data for {self}')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
"""downloads, processes, and automatically creates Sections and Quotes"""
|
"""downloads, processes, and automatically creates Sections and Quotes"""
|
||||||
|
|||||||
Reference in New Issue
Block a user