smfetch 1.1.0__tar.gz → 1.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,9 @@
1
1
  UV ?= uv
2
2
  PROJECT_DIR ?= .
3
3
 
4
- .PHONY: run check format install clean publish
4
+ .PHONY: run check format install clean publish sync-version
5
+
6
+ VERSION_FILES = smfetch/app.py smfetch/static/index.html
5
7
 
6
8
  run:
7
9
  $(UV) run smfetch
@@ -23,16 +25,35 @@ clean:
23
25
  rm -rf $(PROJECT_DIR)/dist $(PROJECT_DIR)/build $(PROJECT_DIR)/*.egg-info 2>/dev/null || true
24
26
  rm -rf $(PROJECT_DIR)/.pytest_cache $(PROJECT_DIR)/.coverage* $(PROJECT_DIR)/htmlcov 2>/dev/null || true
25
27
 
28
+ sync-version:
29
+ @VERSION=$$($(UV) version --short); \
30
+ echo "Syncing version $$VERSION across source files..."; \
31
+ sed -i -E 's/(FastAPI\([^)]*version=")[^"]*(")/\1'"$$VERSION"'\2/' smfetch/app.py; \
32
+ sed -i -E 's|(<div class="logo">smfetch<span> v)[^<]*(</span>)|\1'"$$VERSION"'\2|' smfetch/static/index.html
33
+
26
34
  publish:
27
35
  @CURRENT_VERSION=$$($(UV) version --short); \
28
36
  echo "Current version: $$CURRENT_VERSION"; \
29
37
  read -p "Enter new version (or press Enter to keep current): " NEW_VERSION; \
30
- if [ -n "$$NEW_VERSION" ]; then \
38
+ if [ -n "$$NEW_VERSION" ] && [ "$$NEW_VERSION" != "$$CURRENT_VERSION" ]; then \
31
39
  echo "Updating version to $$NEW_VERSION..."; \
32
40
  $(UV) version "$$NEW_VERSION"; \
41
+ elif [ -n "$$NEW_VERSION" ] && [ "$$NEW_VERSION" = "$$CURRENT_VERSION" ]; then \
42
+ echo "Version unchanged (same as current)."; \
33
43
  else \
34
44
  echo "Using current version: $$CURRENT_VERSION"; \
35
45
  fi; \
46
+ FINAL_VERSION=$$($(UV) version --short); \
47
+ $(MAKE) sync-version; \
36
48
  $(MAKE) install; \
37
49
  $(UV) build; \
38
- $(UV) publish
50
+ $(UV) publish; \
51
+ if [ -n "$$(git status --porcelain -- pyproject.toml uv.lock $(VERSION_FILES))" ]; then \
52
+ echo "Committing version changes..."; \
53
+ git add pyproject.toml uv.lock $(VERSION_FILES); \
54
+ git commit -m "Release $$FINAL_VERSION"; \
55
+ echo "Pushing to remote..."; \
56
+ git push origin HEAD; \
57
+ else \
58
+ echo "No version-related changes; skipping commit and push."; \
59
+ fi
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: smfetch
3
- Version: 1.1.0
3
+ Version: 1.2.0
4
4
  Summary: Web interface for downloading simfiles from Zenius and StepManiaOnline
5
5
  Author-email: Raeed Ahmed <code@raeed.me>
6
6
  Requires-Python: <4,>=3.10
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "smfetch"
3
- version = "1.1.0"
3
+ version = "1.2.0"
4
4
  description = "Web interface for downloading simfiles from Zenius and StepManiaOnline"
5
5
  authors = [{ name = "Raeed Ahmed", email = "code@raeed.me" }]
6
6
  requires-python = ">=3.10,<4"
@@ -70,7 +70,7 @@ async def lifespan(app: FastAPI) -> AsyncIterator[None]:
70
70
  logger.info("smfetch shutting down")
71
71
 
72
72
 
73
- app = FastAPI(title="smfetch", version="1.0.0", lifespan=lifespan)
73
+ app = FastAPI(title="smfetch", version="1.2.0", lifespan=lifespan)
74
74
  app.mount("/static", StaticFiles(directory=str(STATIC_DIR)), name="static")
75
75
 
76
76
 
@@ -56,13 +56,13 @@ class SongEntry(NamedTuple):
56
56
  }
57
57
 
58
58
 
59
- def _parse_pack_row(row: Tag) -> PackEntry:
60
- tags = row.select("td")
61
- title = tags[1].find("a").text # type: ignore[union-attr]
62
- size = tags[2].text.replace("\xa0", " ")
63
- songs = int(tags[3].text)
64
- created = datetime.strptime(tags[5].text.strip(), "%Y-%m-%d").date()
65
- download = f"{BASE}{tags[6].find('a').get('href')}" # type: ignore[union-attr]
59
+ def _parse_pack_row(cells: list[str]) -> PackEntry:
60
+ title = bs(cells[1], "html.parser").find("a").text # type: ignore[union-attr]
61
+ size = bs(cells[2], "html.parser").get_text(strip=True).replace("\xa0", " ")
62
+ songs = int(bs(cells[3], "html.parser").get_text(strip=True))
63
+ created = datetime.strptime(bs(cells[5], "html.parser").get_text(strip=True), "%Y-%m-%d").date()
64
+ href = bs(cells[6], "html.parser").find("a").get("href") # type: ignore[union-attr]
65
+ download = f"{BASE}{href}"
66
66
  idx = int(download.split("/")[-2])
67
67
  return PackEntry(title, size, songs, created, download, idx)
68
68
 
@@ -96,9 +96,25 @@ class PackCache:
96
96
 
97
97
  try:
98
98
  logger.info("Building SMOnline pack cache...")
99
- response = requests.get(f"{BASE}/packs").text
100
- soup = bs(response, "html.parser")
101
- entries = [_parse_pack_row(row) for row in soup.select("tbody tr")]
99
+ entries: list[PackEntry] = []
100
+ page_size = 500
101
+ start = 0
102
+ while True:
103
+ params = {
104
+ "draw": 1,
105
+ "start": start,
106
+ "length": page_size,
107
+ "order[0][column]": 1,
108
+ "order[0][dir]": "asc",
109
+ }
110
+ data = requests.get(f"{BASE}/api/packs/datatables", params=params).json()
111
+ rows = data.get("data") or []
112
+ if not rows:
113
+ break
114
+ entries.extend(_parse_pack_row(row) for row in rows)
115
+ start += page_size
116
+ if start >= data.get("recordsTotal", 0):
117
+ break
102
118
  with self._lock:
103
119
  self._entries = entries
104
120
  self._built = True
@@ -581,7 +581,7 @@
581
581
 
582
582
  <!-- Header -->
583
583
  <header>
584
- <div class="logo">smfetch<span> v1.0</span></div>
584
+ <div class="logo">smfetch<span> v1.2.0</span></div>
585
585
  <div class="header-right">
586
586
  <button class="job-badge" id="jobBadge" onclick="toggleJobs()">0 jobs</button>
587
587
  <button class="icon-btn" onclick="openSettings()" title="Settings">⚙</button>
@@ -516,7 +516,7 @@ wheels = [
516
516
 
517
517
  [[package]]
518
518
  name = "smfetch"
519
- version = "1.1.0"
519
+ version = "1.2.0"
520
520
  source = { editable = "." }
521
521
  dependencies = [
522
522
  { name = "beautifulsoup4" },
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes