mirror of
https://github.com/Findus23/cr-search.git
synced 2024-09-11 06:03:45 +02:00
add more series
This commit is contained in:
parent
9e9348fa69
commit
06a436684a
8 changed files with 33 additions and 16 deletions
5
app.py
5
app.py
|
@ -16,10 +16,11 @@ if config.sentryDSN:
|
|||
integrations=[FlaskIntegration()]
|
||||
)
|
||||
|
||||
CACHE_TYPE = "RedisCache"
|
||||
|
||||
if config.production:
|
||||
CACHE_TYPE = "RedisCache"
|
||||
CACHE_REDIS_URL = "unix:///run/redis-crsearch/redis-server.sock"
|
||||
else:
|
||||
CACHE_TYPE = "NullCache"
|
||||
|
||||
# Create a Flask WSGI app and configure it using values from the module.
|
||||
app = Flask(__name__)
|
||||
|
|
22
data.py
22
data.py
|
@ -12,7 +12,7 @@ colors = {
|
|||
"Laura": "#28607d",
|
||||
"Orion": "#933326"
|
||||
},
|
||||
"campaign2":{
|
||||
"campaign2": {
|
||||
"Laura": "#59c3f9",
|
||||
"Marisha": "#00146e",
|
||||
"Liam": "#fe8413",
|
||||
|
@ -99,6 +99,21 @@ series_data = [
|
|||
slug="campaign2",
|
||||
playlist_id="PL1tiwbzkOjQxD0jjAE7PsWoaCrs0EkBH2"
|
||||
),
|
||||
SeriesData(
|
||||
name="Campaign 3",
|
||||
slug="campaign3",
|
||||
playlist_id="PL1tiwbzkOjQydg3QOkBLG9OYqWJ0dwlxF"
|
||||
),
|
||||
SeriesData(
|
||||
name="Exandria Unlimited",
|
||||
slug="ExandriaUnlimited",
|
||||
playlist_id="PL1tiwbzkOjQzSnYHVT8X4pyMIbSX3i4gz"
|
||||
),
|
||||
SeriesData(
|
||||
name="The Nautilus Ark",
|
||||
slug="TheNautilusArk",
|
||||
videos=["LaKl58BUASo"]
|
||||
),
|
||||
SeriesData(
|
||||
name="Handbooker Helper",
|
||||
slug="HandbookerHelper",
|
||||
|
@ -122,11 +137,6 @@ series_data = [
|
|||
playlist_id="PL1tiwbzkOjQy8yF8esjgVomDXKD-XmG20",
|
||||
initial_speaker="?"
|
||||
),
|
||||
SeriesData(
|
||||
name="Exandria Unlimited",
|
||||
slug="ExandriaUnlimited",
|
||||
playlist_id="PL1tiwbzkOjQzSnYHVT8X4pyMIbSX3i4gz"
|
||||
),
|
||||
SeriesData(
|
||||
name="Critter Hug",
|
||||
slug="CritterHug",
|
||||
|
|
5
fetch.py
5
fetch.py
|
@ -19,7 +19,7 @@ static_path = Path("static")
|
|||
|
||||
def main(args: argparse.Namespace) -> None:
|
||||
os.nice(15)
|
||||
for series in series_data:
|
||||
for order, series in enumerate(series_data):
|
||||
name = series.name
|
||||
playlist_id = series.playlist_id
|
||||
is_campaign = "Campaign" in name
|
||||
|
@ -32,6 +32,7 @@ def main(args: argparse.Namespace) -> None:
|
|||
s.is_campaign = is_campaign
|
||||
s.single_speaker = series.single_speaker
|
||||
s.slug = series.slug
|
||||
s.order = order
|
||||
s.save()
|
||||
ydl_opts = {
|
||||
'extract_flat': True
|
||||
|
@ -58,7 +59,7 @@ def main(args: argparse.Namespace) -> None:
|
|||
if not file.exists():
|
||||
r = requests.get(f"https://i.ytimg.com/vi_webp/{url}/maxresdefault.webp")
|
||||
r.raise_for_status()
|
||||
with file.open("wb")as f:
|
||||
with file.open("wb") as f:
|
||||
f.write(r.content)
|
||||
changed = False
|
||||
try:
|
||||
|
|
|
@ -14,6 +14,7 @@ class BaseModel(flask_db.Model):
|
|||
class Series(BaseModel):
|
||||
title = CharField(max_length=100)
|
||||
slug = CharField(max_length=100)
|
||||
order = IntegerField()
|
||||
is_campaign = BooleanField()
|
||||
single_speaker = BooleanField()
|
||||
|
||||
|
@ -49,7 +50,7 @@ class Episode(BaseModel):
|
|||
class Person(BaseModel):
|
||||
name = CharField()
|
||||
color = CharField(null=True)
|
||||
series = ForeignKeyField(Series)
|
||||
series = ForeignKeyField(Series, on_delete="CASCADE")
|
||||
|
||||
class Meta:
|
||||
indexes = ((("name", "series"), True),)
|
||||
|
|
10
server.py
10
server.py
|
@ -39,7 +39,7 @@ def search(query: str, until: int, series: str, limit: int = 50) -> ModelSelect:
|
|||
&
|
||||
(Episode.series.slug == series)
|
||||
).order_by(SQL("rank DESC")) \
|
||||
.join(Person,join_type=JOIN.FULL).switch(Line) \
|
||||
.join(Person, join_type=JOIN.FULL).switch(Line) \
|
||||
.join(Episode).join(Series) \
|
||||
.limit(limit)
|
||||
|
||||
|
@ -158,12 +158,11 @@ def api_expand():
|
|||
@cache.cached(timeout=60 * 60 * 24)
|
||||
def series():
|
||||
series_list = []
|
||||
|
||||
for series in Series.select():
|
||||
for series in Series.select().order_by(Series.order):
|
||||
last_episode: Episode = Episode.select().where(Episode.series == series).order_by(
|
||||
Episode.upload_date.desc()).limit(
|
||||
1).get()
|
||||
series_data = model_to_dict(series)
|
||||
series_data = model_to_dict(series, exclude=[Series.order])
|
||||
series_data["last_upload"] = last_episode.upload_date.strftime("%Y-%m-%d")
|
||||
series_data["length"] = Episode.select().where(Episode.series == series).count()
|
||||
series_list.append(series_data)
|
||||
|
@ -175,7 +174,7 @@ def series():
|
|||
@app.route("/api/episodes")
|
||||
@cache.cached(timeout=60 * 60 * 24)
|
||||
def api_episodes():
|
||||
all_series: List[Series] = Series.select().order_by(Series.id)
|
||||
all_series: List[Series] = Series.select().order_by(Series.order)
|
||||
data = []
|
||||
for series in all_series:
|
||||
|
||||
|
@ -212,6 +211,7 @@ def api_suggestion():
|
|||
|
||||
if __name__ == "__main__":
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger('peewee')
|
||||
logger.addHandler(logging.StreamHandler())
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
|
BIN
static/TheNautilusArk.webp
Normal file
BIN
static/TheNautilusArk.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 108 KiB |
BIN
static/campaign3.webp
Normal file
BIN
static/campaign3.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 96 KiB |
|
@ -237,5 +237,9 @@ suggestions = {
|
|||
],
|
||||
"ClubOfMisfits": [
|
||||
Suggestion("I'm going to try something weird.")
|
||||
],
|
||||
"TheNautilusArk": [
|
||||
Suggestion("Rifle with a PhD"),
|
||||
Suggestion("It's got a trigger and a little thing")
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue