mirror of
https://github.com/Xevion/the-office.git
synced 2025-12-16 10:13:35 -06:00
start working towards better GUI, implementing "download once" protocol
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import requests
|
import requests
|
||||||
import re
|
import os
|
||||||
|
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from app import db, login
|
from app import db, login
|
||||||
@@ -89,11 +89,25 @@ class Episode(db.Model):
|
|||||||
"Section", backref="episode", lazy="dynamic"
|
"Section", backref="episode", lazy="dynamic"
|
||||||
) # sections of quotes under this episode
|
) # sections of quotes under this episode
|
||||||
|
|
||||||
|
@property
|
||||||
|
def links(self):
|
||||||
|
return f"http://officequotes.net/no{self.season_id}-{str(self.number).zfill(2)}.php"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path(self):
|
||||||
|
return os.path.join('app', 'data', f'{self.season_id}-{self.number}')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def downloaded(self):
|
||||||
|
return os.path.exists(self.path)
|
||||||
|
|
||||||
|
def download(self):
|
||||||
|
"""downloads data"""
|
||||||
|
data = requests.get(link).text
|
||||||
|
open(self.path, "w+", encoding="utf-8").write(data)
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
"""downloads, processes, and automatically creates Sections and Quotes"""
|
"""downloads, processes, and automatically creates Sections and Quotes"""
|
||||||
link = f"http://officequotes.net/no{self.season_id}-{str(self.number).zfill(2)}.php"
|
|
||||||
data = requests.get(link).text
|
|
||||||
open("test.html", "w+", encoding="utf-8").write(data)
|
|
||||||
soup = BeautifulSoup(data, "html.parser")
|
soup = BeautifulSoup(data, "html.parser")
|
||||||
|
|
||||||
sections = soup.find_all(attrs={"class": "quote"})
|
sections = soup.find_all(attrs={"class": "quote"})
|
||||||
|
|||||||
@@ -25,14 +25,18 @@
|
|||||||
{{ super() }}
|
{{ super() }}
|
||||||
<div class="container" style="text-align: center; margin-top: 30rem;">
|
<div class="container" style="text-align: center; margin-top: 30rem;">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="column column-20"></div>
|
<div class="column column-25">
|
||||||
<div class="column column-60">
|
<div class="card">
|
||||||
|
Test
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="column column-40">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="column column-20"></div>
|
{# <div class="column column-20"></div>#}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock body %}
|
{% endblock body %}
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
<style>
|
<style>
|
||||||
.quote {
|
.quote {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
|
color: black;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
{% endblock head %}
|
{% endblock head %}
|
||||||
@@ -15,7 +16,7 @@
|
|||||||
<br>
|
<br>
|
||||||
{% for section in episode.sections %}
|
{% for section in episode.sections %}
|
||||||
<div style="padding: 2rem 1rem 1rem 2rem;">
|
<div style="padding: 2rem 1rem 1rem 2rem;">
|
||||||
<p>
|
<p class="quote">
|
||||||
{% for quote in section.quotes %}
|
{% for quote in section.quotes %}
|
||||||
<span class="quote"><b>{{ quote.speaker }}:</b> {{ quote.text }}</span>
|
<span class="quote"><b>{{ quote.speaker }}:</b> {{ quote.text }}</span>
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
Reference in New Issue
Block a user