Remove conan and bs4
dl / lint (push) Successful in 1m21s Details
dl / docker (push) Successful in 2m19s Details

This commit is contained in:
Michel Roux 2024-02-22 23:26:36 +01:00
parent f234acbeb4
commit 636a09bed4
4 changed files with 2 additions and 200 deletions

View File

@ -4,7 +4,7 @@ RUN apt-get update && \
apt-get install -y \
vim p7zip* git mc rename wget curl procps psmisc \
openssh-client transmission-cli speedtest-cli rclone \
python3-bs4 python3-requests python3-transmissionrpc && \
python3-requests python3-transmissionrpc && \
apt-get install -y --no-install-recommends mame-tools yt-dlp && \
rm -rf /var/lib/apt/lists/* && \
curl -sSL https://raw.githubusercontent.com/MatanZ/tremc/main/tremc -o /usr/local/bin/tremc && \

View File

@ -1,139 +0,0 @@
#!/usr/bin/env python3
import csv
import sys
import bs4
import requests
WIKI_URL = (
"https://fr.wikipedia.org/wiki/Liste_des_%C3%A9pisodes_de_D%C3%A9tective_Conan"
)
GOOD_COLOR = ["#ee8000", "#90bdff"]
CSV_COLUMNS = ["SW", "EW", "Arc", "ST", "ET", "Type", "Titre", "Date"]
EPS_BY_SEASONS = [
28,
26,
28,
24,
28,
28,
31,
26,
35,
31,
30,
38,
36,
37,
39,
25,
33,
42,
40,
40,
35,
43,
39,
41,
83,
40,
38,
28,
40,
35,
99,
]
ARCS = {
1: "Conan",
129: "Haibara",
179: "Vermouth",
345: "Phone",
425: "Kir",
505: "Bourbon",
705: "Train",
783: "Rum",
1029: "Police",
}
def extract_background(style):
for declaration in style.split(";"):
if declaration:
prop, value = declaration.split(":")
if prop.strip() == "background":
return value.strip().lower()
def thetvdb_season(episode):
season = 0
index = 0
for numb in EPS_BY_SEASONS:
index += numb
season += 1
if episode <= index:
return season
def thetvdb_episode(episode):
season = thetvdb_season(episode)
numb = 0
for index in range(0, season - 1):
numb += EPS_BY_SEASONS[index]
return -(numb - episode)
def current_arc(episode):
for numb in sorted(ARCS, reverse=True):
if episode >= numb:
return ARCS[numb]
html = requests.get(WIKI_URL)
soup = bs4.BeautifulSoup(html.text, "html.parser")
tables = soup.select("table.wikitable")
out = csv.DictWriter(sys.stdout, CSV_COLUMNS)
out.writeheader()
sys.stdout.flush()
for season, table in enumerate(tables):
if not season:
continue
trs = table.select("tr")
for row, tr in enumerate(trs):
if row < 1:
continue
tds = tr.select("td")
if len(tds) < 4:
continue
try:
episode = int(tds[0].text.split(" ")[0].split("/")[0])
except ValueError:
continue
color = extract_background(tr["style"])
out.writerow(
{
"SW": season,
"EW": episode,
"Arc": current_arc(episode),
"ST": thetvdb_season(episode),
"ET": thetvdb_episode(episode),
"Type": "C" if not color or color in GOOD_COLOR else "F",
"Titre": tds[1].text.strip(),
"Date": tds[4].text.strip(),
}
)
sys.stdout.flush()

59
poetry.lock generated
View File

@ -1,26 +1,5 @@
# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand.
[[package]]
name = "beautifulsoup4"
version = "4.12.3"
description = "Screen-scraping library"
optional = false
python-versions = ">=3.6.0"
files = [
{file = "beautifulsoup4-4.12.3-py3-none-any.whl", hash = "sha256:b80878c9f40111313e55da8ba20bdba06d8fa3969fc68304167741bbf9e082ed"},
{file = "beautifulsoup4-4.12.3.tar.gz", hash = "sha256:74e3d1928edc070d21748185c46e3fb33490f22f52a3addee9aee0f4f7781051"},
]
[package.dependencies]
soupsieve = ">1.2"
[package.extras]
cchardet = ["cchardet"]
chardet = ["chardet"]
charset-normalizer = ["charset-normalizer"]
html5lib = ["html5lib"]
lxml = ["lxml"]
[[package]]
name = "black"
version = "24.2.0"
@ -429,17 +408,6 @@ urllib3 = ">=1.21.1,<3"
socks = ["PySocks (>=1.5.6,!=1.5.7)"]
use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"]
[[package]]
name = "soupsieve"
version = "2.5"
description = "A modern CSS selector implementation for Beautiful Soup."
optional = false
python-versions = ">=3.8"
files = [
{file = "soupsieve-2.5-py3-none-any.whl", hash = "sha256:eaa337ff55a1579b6549dc679565eac1e3d000563bcb1c8ab0d0fefbc0c2cdc7"},
{file = "soupsieve-2.5.tar.gz", hash = "sha256:5663d5a7b3bfaeee0bc4372e7fc48f9cff4940b3eec54a6451cc5299f1097690"},
]
[[package]]
name = "stdlib-list"
version = "0.8.0"
@ -480,31 +448,6 @@ files = [
requests = ">=2.23.0,<3.0.0"
typing-extensions = "*"
[[package]]
name = "types-beautifulsoup4"
version = "4.12.0.20240106"
description = "Typing stubs for beautifulsoup4"
optional = false
python-versions = ">=3.8"
files = [
{file = "types-beautifulsoup4-4.12.0.20240106.tar.gz", hash = "sha256:98d628985b71b140bd3bc22a8cb0ab603c2f2d08f20d37925965eb4a21739be8"},
{file = "types_beautifulsoup4-4.12.0.20240106-py3-none-any.whl", hash = "sha256:cbdd60ab8aeac737ac014431b6e921b43e84279c0405fdd25a6900bb0e71da5b"},
]
[package.dependencies]
types-html5lib = "*"
[[package]]
name = "types-html5lib"
version = "1.1.11.20240222"
description = "Typing stubs for html5lib"
optional = false
python-versions = ">=3.8"
files = [
{file = "types-html5lib-1.1.11.20240222.tar.gz", hash = "sha256:d9517ec6ba2fa1f63113e2930a59b60722a976cc983b94d7fd772f14865e1152"},
{file = "types_html5lib-1.1.11.20240222-py3-none-any.whl", hash = "sha256:86b2dcbbebca846e68d2eac46b2717980e632de4b5d8f62ccd23d8333d2e7647"},
]
[[package]]
name = "types-requests"
version = "2.31.0.20240218"
@ -550,4 +493,4 @@ zstd = ["zstandard (>=0.18.0)"]
[metadata]
lock-version = "2.0"
python-versions = "^3.8.1"
content-hash = "8c608a41953a90b136c1ca4464fd019999403424ee90c43c69309137a64bc2e4"
content-hash = "739c87123ed492ffc0355a3356e823fbb74d3b6ea8a9c21254e959fccd064c05"

View File

@ -6,7 +6,6 @@ authors = ["Michel Roux <xefir@crystalyx.net>"]
[tool.poetry.dependencies]
python = "^3.8.1"
beautifulsoup4 = "^4.12.3"
requests = "^2.31.0"
transmission-rpc = "^7.0.3"
@ -17,7 +16,6 @@ flake8-alphabetize = "^0.0.21"
flake8-black = "^0.3.6"
flake8-pyproject = "^1.2.3"
mypy = "^1.8.0"
types-beautifulsoup4 = "^4.12.0"
types-requests = "^2.31.0"
[tool.flake8]