mirror of
https://github.com/Findus23/cr-search.git
synced 2024-09-19 15:23:44 +02:00
some minor updates
This commit is contained in:
parent
c6e767de14
commit
d4a0dcada1
7 changed files with 66 additions and 25 deletions
9
data.py
9
data.py
|
@ -103,4 +103,13 @@ series_data = [
|
||||||
playlist_id="PL1tiwbzkOjQz9kKDaPRPrX2E7RPTaxEZd",
|
playlist_id="PL1tiwbzkOjQz9kKDaPRPrX2E7RPTaxEZd",
|
||||||
initial_speaker="Will"
|
initial_speaker="Will"
|
||||||
),
|
),
|
||||||
|
SeriesData(
|
||||||
|
name="The Legend of The Legend of Vox Machina",
|
||||||
|
playlist_id="PL1tiwbzkOjQwJdoNetaNJE1zZVOE7xi8u"
|
||||||
|
),
|
||||||
|
SeriesData(
|
||||||
|
name="Crit Recap Animated",
|
||||||
|
playlist_id="PL1tiwbzkOjQy8yF8esjgVomDXKD-XmG20",
|
||||||
|
initial_speaker="?"
|
||||||
|
)
|
||||||
]
|
]
|
||||||
|
|
17
fetch.py
17
fetch.py
|
@ -1,6 +1,5 @@
|
||||||
import hashlib
|
import hashlib
|
||||||
import os
|
import os
|
||||||
import re
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from shutil import move
|
from shutil import move
|
||||||
from subprocess import run
|
from subprocess import run
|
||||||
|
@ -10,7 +9,7 @@ from peewee import DoesNotExist
|
||||||
|
|
||||||
from data import series_data
|
from data import series_data
|
||||||
from models import Episode, Series, Line, Phrase
|
from models import Episode, Series, Line, Phrase
|
||||||
from utils import srtdir, pretty_title
|
from utils import srtdir, pretty_title, title_to_episodenumber
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
|
@ -42,11 +41,12 @@ def main() -> None:
|
||||||
"subtitleslangs": ["en", "en-US"],
|
"subtitleslangs": ["en", "en-US"],
|
||||||
"skip_download": True,
|
"skip_download": True,
|
||||||
}
|
}
|
||||||
regex = re.compile(r"Ep(?:is|si)ode (\d+)")
|
|
||||||
|
|
||||||
for nr, video in enumerate(videos, 1):
|
for nr, video in enumerate(videos, 1):
|
||||||
try:
|
try:
|
||||||
e = Episode.select().where((Episode.series == s) & (Episode.video_number == nr)).get()
|
e = Episode.select().where((Episode.series == s) & (Episode.video_number == nr)).get()
|
||||||
|
if (e.series.id == 1) or (e.series.id == 2 and e.video_number < 90):
|
||||||
|
continue
|
||||||
# if e.downloaded:
|
# if e.downloaded:
|
||||||
# continue
|
# continue
|
||||||
except DoesNotExist:
|
except DoesNotExist:
|
||||||
|
@ -56,16 +56,7 @@ def main() -> None:
|
||||||
e.title = video["title"]
|
e.title = video["title"]
|
||||||
e.pretty_title = pretty_title(video["title"])
|
e.pretty_title = pretty_title(video["title"])
|
||||||
if s.is_campaign:
|
if s.is_campaign:
|
||||||
try:
|
e.episode_number = title_to_episodenumber(e.title, e.video_number)
|
||||||
match = regex.search(video["title"])
|
|
||||||
if not match:
|
|
||||||
raise ValueError("No episode number found in title")
|
|
||||||
e.episode_number = int(match.group(1))
|
|
||||||
except ValueError:
|
|
||||||
if s.title == "Campaign 1": # one-shots at the end of campaign 1
|
|
||||||
e.episode_number = e.video_number - 3
|
|
||||||
else:
|
|
||||||
raise
|
|
||||||
else:
|
else:
|
||||||
e.episode_number = e.video_number
|
e.episode_number = e.video_number
|
||||||
e.youtube_id = video["url"]
|
e.youtube_id = video["url"]
|
||||||
|
|
20
poetry.lock
generated
20
poetry.lock
generated
|
@ -81,7 +81,7 @@ type = "url"
|
||||||
url = "https://github.com/explosion/spacy-models/releases/download/en_core_web_md-3.0.0/en_core_web_md-3.0.0.tar.gz"
|
url = "https://github.com/explosion/spacy-models/releases/download/en_core_web_md-3.0.0/en_core_web_md-3.0.0.tar.gz"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flask"
|
name = "flask"
|
||||||
version = "2.0.0"
|
version = "2.0.1"
|
||||||
description = "A simple framework for building complex web applications."
|
description = "A simple framework for building complex web applications."
|
||||||
category = "main"
|
category = "main"
|
||||||
optional = false
|
optional = false
|
||||||
|
@ -129,14 +129,14 @@ python-versions = ">=3.6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jinja2"
|
name = "jinja2"
|
||||||
version = "3.0.0"
|
version = "3.0.1"
|
||||||
description = "A very fast and expressive template engine."
|
description = "A very fast and expressive template engine."
|
||||||
category = "main"
|
category = "main"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.6"
|
python-versions = ">=3.6"
|
||||||
|
|
||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
MarkupSafe = ">=2.0.0rc2"
|
MarkupSafe = ">=2.0"
|
||||||
|
|
||||||
[package.extras]
|
[package.extras]
|
||||||
i18n = ["Babel (>=2.7)"]
|
i18n = ["Babel (>=2.7)"]
|
||||||
|
@ -430,7 +430,7 @@ torch = ["torch (>=1.5.0)"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tqdm"
|
name = "tqdm"
|
||||||
version = "4.60.0"
|
version = "4.61.0"
|
||||||
description = "Fast, Extensible Progress Meter"
|
description = "Fast, Extensible Progress Meter"
|
||||||
category = "main"
|
category = "main"
|
||||||
optional = false
|
optional = false
|
||||||
|
@ -559,8 +559,8 @@ cymem = [
|
||||||
]
|
]
|
||||||
en-core-web-md = []
|
en-core-web-md = []
|
||||||
flask = [
|
flask = [
|
||||||
{file = "Flask-2.0.0-py3-none-any.whl", hash = "sha256:1833a4b36ace08dfa1510d86f1bb6fc595d990ec1b838e03ac8dd80ac0705954"},
|
{file = "Flask-2.0.1-py3-none-any.whl", hash = "sha256:a6209ca15eb63fc9385f38e452704113d679511d9574d09b2cf9183ae7d20dc9"},
|
||||||
{file = "Flask-2.0.0.tar.gz", hash = "sha256:168e8507792cb8a3aa06afbe5d4d431d3e07c6318bc3893ceecb81aff09f848d"},
|
{file = "Flask-2.0.1.tar.gz", hash = "sha256:1c4c257b1892aec1398784c63791cbaa43062f1f7aeb555c4da961b20ee68f55"},
|
||||||
]
|
]
|
||||||
gunicorn = [
|
gunicorn = [
|
||||||
{file = "gunicorn-20.1.0.tar.gz", hash = "sha256:e0a968b5ba15f8a328fdfd7ab1fcb5af4470c28aaf7e55df02a99bc13138e6e8"},
|
{file = "gunicorn-20.1.0.tar.gz", hash = "sha256:e0a968b5ba15f8a328fdfd7ab1fcb5af4470c28aaf7e55df02a99bc13138e6e8"},
|
||||||
|
@ -574,8 +574,8 @@ itsdangerous = [
|
||||||
{file = "itsdangerous-2.0.1.tar.gz", hash = "sha256:9e724d68fc22902a1435351f84c3fb8623f303fffcc566a4cb952df8c572cff0"},
|
{file = "itsdangerous-2.0.1.tar.gz", hash = "sha256:9e724d68fc22902a1435351f84c3fb8623f303fffcc566a4cb952df8c572cff0"},
|
||||||
]
|
]
|
||||||
jinja2 = [
|
jinja2 = [
|
||||||
{file = "Jinja2-3.0.0-py3-none-any.whl", hash = "sha256:2f2de5285cf37f33d33ecd4a9080b75c87cd0c1994d5a9c6df17131ea1f049c6"},
|
{file = "Jinja2-3.0.1-py3-none-any.whl", hash = "sha256:1f06f2da51e7b56b8f238affdd6b4e2c61e39598a378cc49345bc1bd42a978a4"},
|
||||||
{file = "Jinja2-3.0.0.tar.gz", hash = "sha256:ea8d7dd814ce9df6de6a761ec7f1cac98afe305b8cdc4aaae4e114b8d8ce24c5"},
|
{file = "Jinja2-3.0.1.tar.gz", hash = "sha256:703f484b47a6af502e743c9122595cc812b0271f661722403114f71a79d0f5a4"},
|
||||||
]
|
]
|
||||||
markupsafe = [
|
markupsafe = [
|
||||||
{file = "MarkupSafe-2.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:f9081981fe268bd86831e5c75f7de206ef275defcb82bc70740ae6dc507aee51"},
|
{file = "MarkupSafe-2.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:f9081981fe268bd86831e5c75f7de206ef275defcb82bc70740ae6dc507aee51"},
|
||||||
|
@ -820,8 +820,8 @@ thinc = [
|
||||||
{file = "thinc-8.0.3.tar.gz", hash = "sha256:c370a7a46d01b588d8d5f99d8d5e36b3cbac4512638356fa430f7f52bb3a8897"},
|
{file = "thinc-8.0.3.tar.gz", hash = "sha256:c370a7a46d01b588d8d5f99d8d5e36b3cbac4512638356fa430f7f52bb3a8897"},
|
||||||
]
|
]
|
||||||
tqdm = [
|
tqdm = [
|
||||||
{file = "tqdm-4.60.0-py2.py3-none-any.whl", hash = "sha256:daec693491c52e9498632dfbe9ccfc4882a557f5fa08982db1b4d3adbe0887c3"},
|
{file = "tqdm-4.61.0-py2.py3-none-any.whl", hash = "sha256:736524215c690621b06fc89d0310a49822d75e599fcd0feb7cc742b98d692493"},
|
||||||
{file = "tqdm-4.60.0.tar.gz", hash = "sha256:ebdebdb95e3477ceea267decfc0784859aa3df3e27e22d23b83e9b272bf157ae"},
|
{file = "tqdm-4.61.0.tar.gz", hash = "sha256:cd5791b5d7c3f2f1819efc81d36eb719a38e0906a7380365c556779f585ea042"},
|
||||||
]
|
]
|
||||||
typer = [
|
typer = [
|
||||||
{file = "typer-0.3.2-py3-none-any.whl", hash = "sha256:ba58b920ce851b12a2d790143009fa00ac1d05b3ff3257061ff69dbdfc3d161b"},
|
{file = "typer-0.3.2-py3-none-any.whl", hash = "sha256:ba58b920ce851b12a2d790143009fa00ac1d05b3ff3257061ff69dbdfc3d161b"},
|
||||||
|
|
13
server.py
13
server.py
|
@ -89,7 +89,7 @@ def api_search():
|
||||||
d: Line
|
d: Line
|
||||||
ri = 0
|
ri = 0
|
||||||
for d in results:
|
for d in results:
|
||||||
entry = model_to_dict(d, extra_attrs=["rank"], exclude=global_excludes)
|
entry = model_to_dict(d, extra_attrs=["rank"], exclude=global_excludes + [Episode.subtitle_hash])
|
||||||
entry["rank"] = float(entry["rank"])
|
entry["rank"] = float(entry["rank"])
|
||||||
data.append({"centerID": d.id, "resultID": ri, "offset": 1, "lines": [entry]})
|
data.append({"centerID": d.id, "resultID": ri, "offset": 1, "lines": [entry]})
|
||||||
ri += 1
|
ri += 1
|
||||||
|
@ -122,6 +122,17 @@ def api_expand():
|
||||||
return jsonify(data)
|
return jsonify(data)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/api/series")
|
||||||
|
def series():
|
||||||
|
series_list = []
|
||||||
|
|
||||||
|
for series in Series.select():
|
||||||
|
series_list.append({"title": series.title, "id": series.id})
|
||||||
|
return jsonify({
|
||||||
|
"series": series_list
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
@app.route("/api/episodes")
|
@app.route("/api/episodes")
|
||||||
def api_episodes():
|
def api_episodes():
|
||||||
all_series: List[Series] = Series.select().order_by(Series.id)
|
all_series: List[Series] = Series.select().order_by(Series.id)
|
||||||
|
|
23
utils.py
23
utils.py
|
@ -1,3 +1,4 @@
|
||||||
|
import re
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
@ -22,6 +23,28 @@ def episode_speaker(series_title: str, episode: int) -> Optional[str]:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
title_regex = re.compile(r"Ep(?:is|si)ode (\d+)")
|
||||||
|
|
||||||
|
|
||||||
|
def title_to_episodenumber(title: str, video_number: int) -> int:
|
||||||
|
print(title)
|
||||||
|
try:
|
||||||
|
match = title_regex.search(title)
|
||||||
|
if not match:
|
||||||
|
if "Hit Points for Level 12" in title:
|
||||||
|
return 99
|
||||||
|
elif "Hit Points for Level 15" in title:
|
||||||
|
return 136
|
||||||
|
else:
|
||||||
|
raise ValueError("No episode number found in title")
|
||||||
|
return int(match.group(1))
|
||||||
|
except ValueError:
|
||||||
|
if title == "Campaign 1": # one-shots at the end of campaign 1
|
||||||
|
return video_number - 3
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
def pretty_title(title: str) -> str:
|
def pretty_title(title: str) -> str:
|
||||||
if "|" in title:
|
if "|" in title:
|
||||||
return title.split("|")[0].strip()
|
return title.split("|")[0].strip()
|
||||||
|
|
|
@ -56,6 +56,7 @@ body {
|
||||||
|
|
||||||
select {
|
select {
|
||||||
width: auto;
|
width: auto;
|
||||||
|
max-width: 300px;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,7 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
serverData: require("../../data.json") as ServerData,
|
serverData: {"series": []} as ServerData,
|
||||||
searchResult: [] as Result[],
|
searchResult: [] as Result[],
|
||||||
keyword: this.$route.params.keyword,
|
keyword: this.$route.params.keyword,
|
||||||
series: this.$route.params.series,
|
series: this.$route.params.series,
|
||||||
|
@ -177,6 +177,12 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
const max = 640;
|
const max = 640;
|
||||||
this.ytWidth = (window.innerWidth < max ? window.innerWidth : max) - 2 * 2;
|
this.ytWidth = (window.innerWidth < max ? window.innerWidth : max) - 2 * 2;
|
||||||
|
fetch(baseURL + "series")
|
||||||
|
.then((response) => response.json())
|
||||||
|
.then((data: ServerData) => {
|
||||||
|
this.serverData = data;
|
||||||
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
suggest(input: string) {
|
suggest(input: string) {
|
||||||
|
|
Loading…
Reference in a new issue