Skip to content

Commit e92d136

Browse files
committed
migrate: use uv to manage project
1 parent 6f4bc65 commit e92d136

17 files changed

+1384
-91
lines changed

.gitignore

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1-
.vercel
2-
venv
3-
__pycache__/
4-
test.py
1+
# .env
52
.env
3+
.env.local
4+
.env.production
5+
6+
# rope
67
.ropeproject
8+
9+
# cache
710
.mypy_cache
8-
.pytest_cache
11+
.pytest_cache
12+
__pycache__/
13+
14+
# vercel
15+
.vercel
16+
17+
# virtual environments
18+
.venv
19+
venv

.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.9
1+
3.12

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
"python.analysis.extraPaths": ["venv/lib"],
1010
"python.linting.mypyEnabled": true,
1111
"[python]": {
12-
"editor.defaultFormatter": "ms-python.black-formatter"
12+
"editor.defaultFormatter": "charliermarsh.ruff"
1313
}
1414
}

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66

77
<h4>THIS SERVICE IS ONLY CREATED TO SATISFY THE NEED FOR AN API FOR [MYDRAMALIST.COM](https://mydramalist.com). THIS WILL BE STOPPED ONCE AN OFFICIAL API WILL BE RELEASED.</h4>
88

9-
### Deploy Your Own
10-
11-
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https%3A%2F%2Fgithub.com%2FTheBoringDude%2Fkuryana)
12-
139
</div>
1410

1511
## API Use
File renamed without changes.

app/handlers/__init__.py

Whitespace-only changes.

api/fetch.py renamed to app/handlers/fetch.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
from typing import Dict, Any, List
2-
3-
from api import MYDRAMALIST_WEBSITE
4-
from api.parser import BaseFetch
1+
import re
2+
from typing import Any, Dict, List
3+
from urllib.parse import urljoin
54

65
from bs4 import BeautifulSoup
7-
from urllib.parse import urljoin
8-
import re
6+
7+
from app import MYDRAMALIST_WEBSITE
8+
from app.handlers.parser import BaseFetch
99

1010

1111
class FetchDrama(BaseFetch):
@@ -381,9 +381,9 @@ def _parse_total_stats(self, item: BeautifulSoup) -> Dict[str, str]:
381381
movies_stats = item.find("label", class_="mdl-style-movies")
382382
days_stats = item.find("label", class_="mdl-style-days")
383383
return {
384-
label.find("span", class_="name")
385-
.get_text(strip=True): label.find("span", class_="cnt")
386-
.get_text(strip=True)
384+
label.find("span", class_="name").get_text(strip=True): label.find(
385+
"span", class_="cnt"
386+
).get_text(strip=True)
387387
for label in [
388388
drama_stats,
389389
tvshows_stats,

api/parser.py renamed to app/handlers/parser.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from datetime import datetime
1+
from datetime import datetime, timezone
22
from typing import Any, Dict, List, Type, TypeVar, Union
33
from urllib.parse import urljoin
44

@@ -7,7 +7,7 @@
77
from bs4 import BeautifulSoup
88
from bs4.element import NavigableString, Tag
99

10-
from api import MYDRAMALIST_WEBSITE
10+
from app import MYDRAMALIST_WEBSITE
1111

1212
T = TypeVar("T", bound="Parser")
1313

@@ -102,7 +102,7 @@ def search(self) -> Dict[str, Any]:
102102
return {
103103
"query": self.query,
104104
"results": self.search_results,
105-
"scrape_date": datetime.utcnow(),
105+
"scrape_date": datetime.now(timezone.utc),
106106
}
107107

108108

@@ -120,7 +120,7 @@ def fetch(self) -> Dict[str, Any]:
120120
return {
121121
"slug_query": self.query,
122122
"data": self.info,
123-
"scrape_date": datetime.utcnow(),
123+
"scrape_date": datetime.now(timezone.utc),
124124
}
125125

126126
def _get(self) -> None:

api/search.py renamed to app/handlers/search.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
from typing import Any, Tuple, Union, Optional
2-
3-
from api import MYDRAMALIST_WEBSITE
4-
from api.parser import BaseSearch
1+
from typing import Any, Optional, Tuple, Union
2+
from urllib.parse import urljoin
53

64
from bs4 import BeautifulSoup
7-
from bs4.element import Tag, NavigableString, ResultSet
8-
from urllib.parse import urljoin
5+
from bs4.element import NavigableString, ResultSet, Tag
6+
7+
from app import MYDRAMALIST_WEBSITE
8+
from app.handlers.parser import BaseSearch
99

1010

1111
class Search(BaseSearch):
@@ -108,7 +108,7 @@ def _get_search_results(self) -> None:
108108

109109
# extract drama title
110110
r["title"] = title.strip()
111-
111+
112112
# drama ranking
113113
r["ranking"] = self._res_get_ranking(result)
114114

api/main.py renamed to app/main.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
from typing import Dict, Any
2-
3-
from fastapi import FastAPI, Response
4-
from fastapi.middleware.cors import CORSMiddleware
1+
from typing import Any, Dict
52

63
# bypassing cloudflare anti-bot
74
import cloudscraper
5+
from fastapi import FastAPI, Response
6+
from fastapi.middleware.cors import CORSMiddleware
87

9-
from api.utils import search_func, fetch_func
10-
8+
from app.utils import fetch_func, search_func
119

1210
app = FastAPI()
1311

api/utils.py renamed to app/utils.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
from typing import Dict, Any, Tuple
1+
from typing import Any, Dict, Tuple
22

3-
from api.search import Search
4-
from api.fetch import (
3+
from app.handlers.fetch import (
4+
FetchCast,
55
FetchDrama,
6+
FetchDramaList,
67
FetchList,
78
FetchPerson,
8-
FetchCast,
99
FetchReviews,
10-
FetchDramaList,
1110
)
11+
from app.handlers.search import Search
1212

1313

1414
def error(code: int, description: str) -> Dict[str, Any]:
1515
return {
1616
"error": True,
1717
"code": code,
18-
"description": "404 Not Found"
19-
if code == 404
20-
else description, # prioritize error 404
18+
"description": (
19+
"404 Not Found" if code == 404 else description
20+
), # prioritize error 404
2121
}
2222

2323

pyproject.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[project]
2+
name = "kuryana"
3+
version = "0.1.0"
4+
description = "Add your description here"
5+
readme = "README.md"
6+
requires-python = ">=3.9"
7+
dependencies = [
8+
"beautifulsoup4>=4.12.3",
9+
"cloudscraper>=1.2.71",
10+
"fastapi[standard]>=0.115.6",
11+
"lxml>=5.3.0",
12+
]
13+
14+
[dependency-groups]
15+
dev = [
16+
"flake8>=7.1.1",
17+
"mypy>=1.14.1",
18+
"pytest>=8.3.4",
19+
"ruff>=0.8.5",
20+
]

requirements.txt

Lines changed: 0 additions & 36 deletions
This file was deleted.

tests/test_fetch_dramalist.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
from api.fetch import FetchDramaList
21
from pathlib import Path
2+
33
import pytest
44
from bs4 import BeautifulSoup
55

6+
from app.handlers.fetch import FetchDramaList
7+
68

79
@pytest.fixture
810
def sample_obj():

tests/test_main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from fastapi.testclient import TestClient
22

3-
from api.main import app
3+
from app.main import app
44

55
client = TestClient(app)
66

0 commit comments

Comments
 (0)