ChessPenguin 0.8.0: games from Lichess and Chess.com
Pending Lichess games are asked about by id; broken connections are retried with waits; a file lock keeps two running ChessPenguins from writing one database. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e0c99074e2
commit
d0846daf9b
8 changed files with 207 additions and 108 deletions
18
CHANGELOG.md
18
CHANGELOG.md
|
|
@ -2,14 +2,18 @@
|
|||
|
||||
All notable changes are listed here. Versions follow [Semantic Versioning](https://semver.org/).
|
||||
|
||||
## [Unreleased]
|
||||
## [0.8.0] — 2026-10-20
|
||||
|
||||
- Your games from Lichess and Chess.com: enter the nickname (another one for Chess.com if it
|
||||
differs), see what was found and download the games into a database — one for both sites
|
||||
by default ("Put the games of both sites into one database"), or one per site — and update
|
||||
it later with one click; an interrupted download continues where it stopped. Only standard
|
||||
chess is kept. The feature is offered only when the sites answer: ChessPenguin asks each
|
||||
for a public profile at start (no data of yours is sent), so offline it stays hidden.
|
||||
- Games from Lichess and Chess.com: anyone's games by nickname — yours, a pupil's, an
|
||||
opponent's, a champion's (no login; another nickname for Chess.com if it differs). See what
|
||||
was found, download the games into a database — both sites merged into one by default, or
|
||||
one per site — and later fetch the new ones with "⟳ New games" in the database header. The
|
||||
progress shows per site with the time left; the window may be closed meanwhile (the result
|
||||
then shows as a message). An interrupted download — stopped, failed, or the program closed —
|
||||
keeps what it got and continues where it stopped, without duplicates (also after a crash);
|
||||
games still being played (correspondence) are fetched once they end. Only standard chess is
|
||||
kept. The feature is offered only when the sites answer: ChessPenguin asks each for a public
|
||||
profile at start (nothing of yours is sent), so offline it stays hidden.
|
||||
|
||||
## [0.7.1] — 2026-10-20
|
||||
|
||||
|
|
|
|||
8
Cargo.lock
generated
8
Cargo.lock
generated
|
|
@ -661,7 +661,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "chess-core"
|
||||
version = "0.7.1"
|
||||
version = "0.8.0"
|
||||
dependencies = [
|
||||
"encoding_rs",
|
||||
"pgn-reader",
|
||||
|
|
@ -671,7 +671,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "chess-import"
|
||||
version = "0.7.1"
|
||||
version = "0.8.0"
|
||||
dependencies = [
|
||||
"chess-core",
|
||||
"encoding_rs",
|
||||
|
|
@ -684,7 +684,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "chesspenguin"
|
||||
version = "0.7.1"
|
||||
version = "0.8.0"
|
||||
dependencies = [
|
||||
"arboard",
|
||||
"chess-core",
|
||||
|
|
@ -4284,7 +4284,7 @@ checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
|
|||
|
||||
[[package]]
|
||||
name = "uci"
|
||||
version = "0.7.1"
|
||||
version = "0.8.0"
|
||||
dependencies = [
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ resolver = "3"
|
|||
members = ["crates/chess-core", "crates/chess-import", "crates/uci", "apps/desktop"]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.7.1"
|
||||
version = "0.8.0"
|
||||
edition = "2024"
|
||||
rust-version = "1.97"
|
||||
license = "GPL-3.0-or-later"
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
copy PGN/FEN, save a game to a new file.
|
||||
- **Looks** — 17 piece sets, 37 boards (flat colours and textures), 7 sound sets,
|
||||
dark and light themes.
|
||||
- **Your online games** — download your games from Lichess and Chess.com by nickname (no login) into a database and update it with one click.
|
||||
- **Online games** — download anyone's games from Lichess and Chess.com by nickname (yours, a pupil's, an opponent's; no login) into a database, both sites merged or one per site, and fetch the new ones with one click.
|
||||
- **Languages** — English, Русский, Français, Deutsch, Español, Italiano.
|
||||
|
||||
| Game analysis: graph and report | Engine marks and better lines |
|
||||
|
|
|
|||
|
|
@ -705,7 +705,7 @@ impl Library {
|
|||
ui.painter()
|
||||
.rect_stroke(rect, 6.0, visuals.fg_stroke, egui::StrokeKind::Inside);
|
||||
let below = match self.online_running {
|
||||
Some(n) => trf("downloading… {n}", &[("n", &large_db::grouped(n))]),
|
||||
Some(n) => trf("downloading… {n}", &[("n", &crate::i18n::games(n))]),
|
||||
None => "Lichess · Chess.com".to_owned(),
|
||||
};
|
||||
ui.painter().text(
|
||||
|
|
|
|||
|
|
@ -91,27 +91,63 @@ impl std::fmt::Display for Failure {
|
|||
}
|
||||
}
|
||||
|
||||
/// Makes a request again when the connection broke (Lichess drops connections for a
|
||||
/// minute or so after an export was cut short), waiting `waits` seconds in between;
|
||||
/// stops waiting when cancelled.
|
||||
fn retrying<T>(
|
||||
waits: &[u64],
|
||||
cancel: &AtomicBool,
|
||||
mut request: impl FnMut() -> Result<T, ureq::Error>,
|
||||
) -> Result<T, Failure> {
|
||||
let mut waits = waits.iter();
|
||||
loop {
|
||||
match request() {
|
||||
Ok(r) => return Ok(r),
|
||||
Err(e) => {
|
||||
let Some(&secs) = waits.next() else {
|
||||
return Err(Failure::Network(e.to_string()));
|
||||
};
|
||||
for _ in 0..secs * 10 {
|
||||
if cancel.load(Ordering::Relaxed) {
|
||||
return Err(Failure::Network(e.to_string()));
|
||||
}
|
||||
std::thread::sleep(Duration::from_millis(100));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Waits before the attempts of a download request: about a minute in all.
|
||||
const DOWNLOAD_WAITS: &[u64] = &[3, 10, 20, 30];
|
||||
|
||||
/// GET returning (status, body); the body of an error status is not read.
|
||||
fn get(url: &str) -> Result<(u16, String), Failure> {
|
||||
let mut resp = agent(false)
|
||||
.get(url)
|
||||
.header("Accept", "application/json")
|
||||
.call()
|
||||
.map_err(|e| Failure::Network(e.to_string()))?;
|
||||
let status = resp.status().as_u16();
|
||||
if status == 429 {
|
||||
return Err(Failure::RateLimited);
|
||||
}
|
||||
if status != 200 {
|
||||
return Ok((status, String::new()));
|
||||
}
|
||||
let body = resp
|
||||
.body_mut()
|
||||
.with_config()
|
||||
.limit(64 << 20)
|
||||
.read_to_string()
|
||||
.map_err(|e| Failure::Network(e.to_string()))?;
|
||||
Ok((status, body))
|
||||
let never = AtomicBool::new(false);
|
||||
// The whole exchange is repeated: a connection may also break in the body.
|
||||
retrying(&[2, 5], &never, || {
|
||||
let mut resp = agent(false)
|
||||
.get(url)
|
||||
.header("Accept", "application/json")
|
||||
.call()?;
|
||||
let status = resp.status().as_u16();
|
||||
if status != 200 {
|
||||
return Ok((status, String::new()));
|
||||
}
|
||||
let body = resp
|
||||
.body_mut()
|
||||
.with_config()
|
||||
.limit(64 << 20)
|
||||
.read_to_string()?;
|
||||
Ok((status, body))
|
||||
})
|
||||
.and_then(|(status, body)| {
|
||||
if status == 429 {
|
||||
Err(Failure::RateLimited)
|
||||
} else {
|
||||
Ok((status, body))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn json(url: &str) -> Result<Option<Value>, Failure> {
|
||||
|
|
@ -577,6 +613,19 @@ pub fn download(
|
|||
status: &Progress,
|
||||
) -> Result<Done, Failure> {
|
||||
let _claim = Claim::take(path).ok_or(Failure::Busy)?;
|
||||
// Another ChessPenguin running may download into the same database: a file lock
|
||||
// (released when the file closes, also if the process dies).
|
||||
if let Some(d) = path.parent() {
|
||||
std::fs::create_dir_all(d).map_err(|e| Failure::Disk(e.to_string()))?;
|
||||
}
|
||||
let lock = std::fs::File::create(path.with_extension("online.lock"))
|
||||
.map_err(|e| Failure::Disk(e.to_string()))?;
|
||||
if let Err(e) = lock.try_lock() {
|
||||
return Err(match e {
|
||||
std::fs::TryLockError::WouldBlock => Failure::Busy,
|
||||
std::fs::TryLockError::Error(e) => Failure::Disk(e.to_string()),
|
||||
});
|
||||
}
|
||||
let path = path.to_owned();
|
||||
let mut state = State::load(&path)
|
||||
// The games are gone (the file was deleted): fetch them again.
|
||||
|
|
@ -640,25 +689,26 @@ struct LichessGame<'a> {
|
|||
/// Still being played (not exported as a game yet).
|
||||
playing: bool,
|
||||
standard: bool,
|
||||
pgn: &'a str,
|
||||
/// Present for finished games (an unfinished one may come without it).
|
||||
pgn: Option<&'a str>,
|
||||
}
|
||||
|
||||
fn lichess_game(v: &Value) -> Option<LichessGame<'_>> {
|
||||
Some(LichessGame {
|
||||
let g = LichessGame {
|
||||
id: v["id"].as_str()?,
|
||||
created: v["createdAt"].as_i64()?,
|
||||
playing: matches!(v["status"].as_str(), Some("created" | "started")),
|
||||
standard: v["variant"]
|
||||
.as_str()
|
||||
.is_none_or(|x| x == "standard" || x == "fromPosition"),
|
||||
pgn: v["pgn"].as_str()?,
|
||||
})
|
||||
pgn: v["pgn"].as_str(),
|
||||
};
|
||||
(g.playing || g.pgn.is_some()).then_some(g)
|
||||
}
|
||||
|
||||
/// What to do with a game of the Lichess export: `Some(write?)`, given the newest game
|
||||
/// fetched before this run and the games pending then (unfinished). The export repeats
|
||||
/// games from the oldest pending one on; those fetched already are skipped.
|
||||
fn lichess_keep(a: &mut AccountState, g: &LichessGame, before: Option<i64>) -> bool {
|
||||
/// Whether to write a game of the Lichess export; an unfinished one is remembered as
|
||||
/// pending instead (asked about by id next time), a pending one that ended is written.
|
||||
fn lichess_keep(a: &mut AccountState, g: &LichessGame) -> bool {
|
||||
let pending = a.lichess_pending.iter().position(|(id, _)| id == g.id);
|
||||
if g.playing {
|
||||
if pending.is_none() && g.standard {
|
||||
|
|
@ -668,50 +718,25 @@ fn lichess_keep(a: &mut AccountState, g: &LichessGame, before: Option<i64>) -> b
|
|||
}
|
||||
if let Some(k) = pending {
|
||||
a.lichess_pending.remove(k);
|
||||
return g.standard;
|
||||
}
|
||||
g.standard && before.is_none_or(|b| g.created > b)
|
||||
g.standard
|
||||
}
|
||||
|
||||
/// The games of account `i` of the writer's database from Lichess. `Ok(true)` when
|
||||
/// cancelled.
|
||||
fn lichess(
|
||||
w: &mut Writer,
|
||||
i: usize,
|
||||
progress: &AtomicUsize,
|
||||
/// A pending game Lichess no longer returns is given up after a year.
|
||||
const PENDING_DAYS: i64 = 365;
|
||||
|
||||
/// Reads a Lichess NDJSON answer line by line. `Ok(true)` when cancelled.
|
||||
fn lichess_lines(
|
||||
resp: ureq::http::Response<ureq::Body>,
|
||||
cancel: &AtomicBool,
|
||||
status: &Progress,
|
||||
mut each: impl FnMut(usize, &Value) -> Result<(), Failure>,
|
||||
) -> Result<bool, Failure> {
|
||||
let a = &w.state.accounts[i];
|
||||
let before = a.lichess_last;
|
||||
let from = a
|
||||
.lichess_pending
|
||||
.iter()
|
||||
.map(|(_, t)| *t)
|
||||
.chain(before.map(|b| b + 1))
|
||||
.min();
|
||||
let pending_before: Vec<String> = a.lichess_pending.iter().map(|(id, _)| id.clone()).collect();
|
||||
let mut url = format!(
|
||||
"https://lichess.org/api/games/user/{}?sort=dateAsc&finished=false&pgnInJson=true\
|
||||
&perfType=ultraBullet,bullet,blitz,rapid,classical,correspondence\
|
||||
&clocks=false&evals=false&opening=true",
|
||||
a.username
|
||||
);
|
||||
if let Some(from) = from {
|
||||
url.push_str(&format!("&since={from}"));
|
||||
}
|
||||
let resp = agent(true)
|
||||
.get(&url)
|
||||
.header("Accept", "application/x-ndjson")
|
||||
.call()
|
||||
.map_err(|e| Failure::Network(e.to_string()))?;
|
||||
match resp.status().as_u16() {
|
||||
200 => {}
|
||||
429 => return Err(Failure::RateLimited),
|
||||
code => return Err(Failure::Unexpected(format!("HTTP {code}"))),
|
||||
}
|
||||
let reader = BufReader::new(resp.into_body().into_reader());
|
||||
let mut seen: Vec<String> = Vec::new();
|
||||
for (n, line) in reader.lines().enumerate() {
|
||||
if cancel.load(Ordering::Relaxed) {
|
||||
return Ok(true);
|
||||
|
|
@ -722,30 +747,83 @@ fn lichess(
|
|||
}
|
||||
let v: Value =
|
||||
serde_json::from_str(&line).map_err(|e| Failure::Unexpected(e.to_string()))?;
|
||||
let g = lichess_game(&v)
|
||||
each(n, &v)?;
|
||||
}
|
||||
Ok(false)
|
||||
}
|
||||
|
||||
const LICHESS_PARAMS: &str = "pgnInJson=true&clocks=false&evals=false&opening=true";
|
||||
|
||||
/// The games of account `i` of the writer's database from Lichess: first the pending
|
||||
/// (unfinished last time) ones by id, then the new ones. `Ok(true)` when cancelled.
|
||||
fn lichess(
|
||||
w: &mut Writer,
|
||||
i: usize,
|
||||
progress: &AtomicUsize,
|
||||
cancel: &AtomicBool,
|
||||
status: &Progress,
|
||||
) -> Result<bool, Failure> {
|
||||
let write = |w: &mut Writer, v: &Value| -> Result<i64, Failure> {
|
||||
let g = lichess_game(v)
|
||||
.ok_or_else(|| Failure::Unexpected("a game without id, pgn or createdAt".into()))?;
|
||||
if pending_before.iter().any(|id| id == g.id) {
|
||||
seen.push(g.id.to_owned());
|
||||
}
|
||||
let a = &mut w.state.accounts[i];
|
||||
if lichess_keep(a, &g, before) {
|
||||
let pgn = g.pgn.to_owned();
|
||||
if lichess_keep(&mut w.state.accounts[i], &g)
|
||||
&& let Some(pgn) = g.pgn
|
||||
{
|
||||
let pgn = pgn.to_owned();
|
||||
w.game(&pgn)?;
|
||||
progress.fetch_add(1, Ordering::Relaxed);
|
||||
status.games.fetch_add(1, Ordering::Relaxed);
|
||||
}
|
||||
Ok(g.created)
|
||||
};
|
||||
let pending: Vec<String> = w.state.accounts[i]
|
||||
.lichess_pending
|
||||
.iter()
|
||||
.map(|(id, _)| id.clone())
|
||||
.collect();
|
||||
for chunk in pending.chunks(300) {
|
||||
let resp = retrying(DOWNLOAD_WAITS, cancel, || {
|
||||
agent(true)
|
||||
.post(&format!(
|
||||
"https://lichess.org/api/games/export/_ids?{LICHESS_PARAMS}"
|
||||
))
|
||||
.header("Accept", "application/x-ndjson")
|
||||
.send(chunk.join(","))
|
||||
})?;
|
||||
if lichess_lines(resp, cancel, |_, v| write(w, v).map(|_| ()))? {
|
||||
return Ok(true);
|
||||
}
|
||||
}
|
||||
let year_ago = now_secs() * 1000 - PENDING_DAYS * 86_400_000;
|
||||
w.state.accounts[i]
|
||||
.lichess_pending
|
||||
.retain(|(_, created)| *created > year_ago);
|
||||
w.commit()?;
|
||||
|
||||
let a = &w.state.accounts[i];
|
||||
let mut url = format!(
|
||||
"https://lichess.org/api/games/user/{}?sort=dateAsc&finished=false\
|
||||
&perfType=ultraBullet,bullet,blitz,rapid,classical,correspondence&{LICHESS_PARAMS}",
|
||||
a.username
|
||||
);
|
||||
if let Some(last) = a.lichess_last {
|
||||
url.push_str(&format!("&since={}", last + 1));
|
||||
}
|
||||
let resp = retrying(DOWNLOAD_WAITS, cancel, || {
|
||||
agent(true)
|
||||
.get(&url)
|
||||
.header("Accept", "application/x-ndjson")
|
||||
.call()
|
||||
})?;
|
||||
lichess_lines(resp, cancel, |n, v| {
|
||||
let created = write(w, v)?;
|
||||
let a = &mut w.state.accounts[i];
|
||||
a.lichess_last = Some(a.lichess_last.map_or(g.created, |l| l.max(g.created)));
|
||||
a.lichess_last = Some(a.lichess_last.map_or(created, |l| l.max(created)));
|
||||
if n % 100 == 99 {
|
||||
w.commit()?;
|
||||
}
|
||||
}
|
||||
// The whole export arrived: a game pending before that did not come again is gone
|
||||
// (deleted, or a variant that ended).
|
||||
w.state.accounts[i]
|
||||
.lichess_pending
|
||||
.retain(|(id, _)| !pending_before.contains(id) || seen.contains(id));
|
||||
Ok(false)
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
/// The games of account `i` of the writer's database from Chess.com. `Ok(true)` when
|
||||
|
|
@ -1001,28 +1079,33 @@ mod tests {
|
|||
#[test]
|
||||
fn unfinished_lichess_games_come_later() {
|
||||
let mut a = AccountState::default();
|
||||
let g = |id: &'static str, created: i64, playing: bool| LichessGame {
|
||||
let g = |id: &'static str, playing: bool| LichessGame {
|
||||
id,
|
||||
created,
|
||||
created: 10,
|
||||
playing,
|
||||
standard: true,
|
||||
pgn: "",
|
||||
pgn: (!playing).then_some("1. e4 *"),
|
||||
};
|
||||
// First run: a correspondence game is still on, a later one is over.
|
||||
assert!(!lichess_keep(&mut a, &g("corr", 10, true), None));
|
||||
assert!(lichess_keep(&mut a, &g("blitz", 20, false), None));
|
||||
// First run: a correspondence game is still on, another one is over.
|
||||
assert!(!lichess_keep(&mut a, &g("corr", true)));
|
||||
assert!(lichess_keep(&mut a, &g("blitz", false)));
|
||||
assert_eq!(a.lichess_pending, vec![("corr".to_owned(), 10)]);
|
||||
// The next run starts from the pending game: it is over now and is kept, the
|
||||
// game fetched before is not repeated.
|
||||
assert!(lichess_keep(&mut a, &g("corr", 10, false), Some(20)));
|
||||
assert!(!lichess_keep(&mut a, &g("blitz", 20, false), Some(20)));
|
||||
assert!(lichess_keep(&mut a, &g("new", 30, false), Some(20)));
|
||||
// Asked about by id: still on, then over.
|
||||
assert!(!lichess_keep(&mut a, &g("corr", true)));
|
||||
assert_eq!(a.lichess_pending.len(), 1);
|
||||
assert!(lichess_keep(&mut a, &g("corr", false)));
|
||||
assert!(a.lichess_pending.is_empty());
|
||||
// A variant game is neither kept nor waited for.
|
||||
let mut v = g("960", 40, true);
|
||||
let mut v = g("960", true);
|
||||
v.standard = false;
|
||||
assert!(!lichess_keep(&mut a, &v, Some(30)));
|
||||
assert!(!lichess_keep(&mut a, &v));
|
||||
assert!(a.lichess_pending.is_empty());
|
||||
// An unfinished game may come without its PGN, a finished one may not.
|
||||
let json = |s: &str| serde_json::from_str::<Value>(s).unwrap();
|
||||
let on = json(r#"{"id":"a","createdAt":1,"status":"started"}"#);
|
||||
assert!(lichess_game(&on).is_some_and(|g| g.playing));
|
||||
let over = json(r#"{"id":"a","createdAt":1,"status":"mate"}"#);
|
||||
assert!(lichess_game(&over).is_none());
|
||||
}
|
||||
|
||||
/// Against the real sites, with an account given by `CP_ONLINE_NICK` (kept out of
|
||||
|
|
@ -1068,15 +1151,17 @@ mod tests {
|
|||
for round in 1..=2 {
|
||||
let progress = AtomicUsize::new(0);
|
||||
let cancel = AtomicBool::new(false);
|
||||
let over = AtomicBool::new(false);
|
||||
let done = std::thread::scope(|s| {
|
||||
s.spawn(|| {
|
||||
while progress.load(Ordering::Relaxed) < 150 {
|
||||
while progress.load(Ordering::Relaxed) < 150 && !over.load(Ordering::Relaxed) {
|
||||
std::thread::sleep(Duration::from_millis(50));
|
||||
}
|
||||
cancel.store(true, Ordering::Relaxed);
|
||||
});
|
||||
download_to(std::slice::from_ref(&li), &path, &progress, &cancel)
|
||||
.expect("downloads")
|
||||
let r = download_to(std::slice::from_ref(&li), &path, &progress, &cancel);
|
||||
over.store(true, Ordering::Relaxed);
|
||||
r.expect("downloads")
|
||||
});
|
||||
eprintln!("lichess round {round}: {done:?}");
|
||||
assert!(done.cancelled && done.added >= 150);
|
||||
|
|
@ -1150,6 +1235,7 @@ mod tests {
|
|||
for round in 1..=2 {
|
||||
let progress = AtomicUsize::new(0);
|
||||
let cancel = AtomicBool::new(false);
|
||||
let over = AtomicBool::new(false);
|
||||
let goal = if round == 1 {
|
||||
done.total as usize + 100
|
||||
} else {
|
||||
|
|
@ -1157,12 +1243,14 @@ mod tests {
|
|||
};
|
||||
let d = std::thread::scope(|s| {
|
||||
s.spawn(|| {
|
||||
while progress.load(Ordering::Relaxed) < goal {
|
||||
while progress.load(Ordering::Relaxed) < goal && !over.load(Ordering::Relaxed) {
|
||||
std::thread::sleep(Duration::from_millis(50));
|
||||
}
|
||||
cancel.store(true, Ordering::Relaxed);
|
||||
});
|
||||
download_to(&accounts, &path, &progress, &cancel).expect("downloads")
|
||||
let r = download_to(&accounts, &path, &progress, &cancel);
|
||||
over.store(true, Ordering::Relaxed);
|
||||
r.expect("downloads")
|
||||
});
|
||||
eprintln!("both, round {round}: {d:?}");
|
||||
assert!(d.cancelled);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ egui/eframe 0.36 (wgpu, Wayland/X11). Бинарник `chesspenguin`, app id `i
|
|||
| `large_db.rs` | Большая база ChessBase: панель фильтров справа (игроки с подсказками, турнир, годы, Эло, результат, ECO, ходы, аннотации), фоновые проходы с отменой и задержкой 250 мс для текста, счётчик и прогресс, таблица из записей `.cbh`; компоновка — `docs/design/large-databases.md`; переключатель `[Фильтры | Доска]`, строка условий (чипы), колонка «Ход», «только этот порядок», «сильнейшие сверху»; при открытой доске в фоне строится, чего не хватает для быстрого поиска (`Base::prepare`: свой ускоритель без пригодного `.cbb`, дебютный индекс при достаточной памяти; каталог кэша `boosters/`) со строкой прогресса над доской |
|
||||
| `update.rs` | Обновления: проверка последнего выпуска (GitHub API, при старте, отключается в «О программе»), вид установки (`detect`: zip на Windows, `.app` на macOS, AppImage — только если исполняемый файл внутри `$APPDIR`, архив tar.gz по соседним файлам, `/usr/bin` → pacman/dpkg/rpm, Flatpak по `FLATPAK_ID`, иначе «другое»), выбор файла выпуска по окончанию имени, загрузка с проверкой SHA-256 из `SHA256SUMS.txt`, замена исполняемого файла (`replace_file`: копия рядом и одно переименование; на Windows работающий `.exe` переименовывается в `.old`, удаляется при следующем запуске), команды для пакетов (`cd <папка> && sudo apt/dnf/zypper/pacman … ./файл`, все слова в одинарных кавычках, если в них есть что-то кроме безопасных символов), папка «Загрузки» (XDG, затем `~/.config/user-dirs.dirs` пользователя — у Flatpak своя папка настроек, затем `~/Downloads`, затем домашняя). Тесты: версии, файлы для каждого вида, команды и экранирование (через `sh`), замена работающего исполняемого файла (CI на Windows и macOS тоже), обновление архива из локального «выпуска» |
|
||||
| `update_ui.rs` | Окно «Обновление ChessPenguin»: «Вышла версия X · У вас Y · Что нового», один сценарий на вид установки с главной кнопкой, «Не сейчас», «Пропустить эту версию» (`skipped_version`); скачивание с прогрессом (окно можно закрыть, кнопка у «Настроек» показывает проценты); итог: «Перезапустить сейчас / Позже», шаги для macOS с «Закрыть ChessPenguin», команда с «Копировать», «Открыть папку» и шагами для пакетов; ошибки понятными словами, исходный текст — в «Подробностях». Перезапуск: `request_close(QuitApp)`, в `finish_close` настройки сохраняются, новый процесс запускается без переменных `CP_*`; отмена вопроса о партиях отменяет и перезапуск |
|
||||
| `online.rs` | Онлайн-партии: проба обоих API при старте (повтор через 5 минут), поиск ника, загрузка в PGN-базу в `<data>/online/` с файлом состояния `.online.json` (аккаунты базы, отметки Lichess `since`/незаконченные партии и Chess.com месяц/время, число партий, длина файла и его последние байты — хвост после аварии обрезается), одна загрузка на файл (`Claim`), имена `Ник (Lichess + Chess.com).pgn` или `A (Lichess) + B (Chess.com).pgn`. Живой тест `online_live` (ник — только через `CP_ONLINE_NICK`). |
|
||||
| `online_ui.rs` | Окно «Партии с Lichess и Chess.com»: ник игрока (любого: свой, ученика, соперника; другой ник для Chess.com), площадки, ответившие на пробу, «Найти» (Enter), найденное, «Объединить партии с обоих сайтов в одну базу» (по умолчанию), строка «В базу …» (`targets`: база, где эти аккаунты уже есть, иначе новая), «Скачать», прогресс по сайту (Lichess: из N, оставшееся время; Chess.com: месяц i из n), «Остановить», итоги с «Открыть базу» / «Попробовать снова» и «Подробностями»; при закрытом окне итог — тостом; `stop_all` при выходе. |
|
||||
| `board_search.rs` | Доска поиска по позиции (решение 13, `docs/design/board-search.md`): ввод ходов, линия с переходами по ходам, продолжения со статистикой (полоса Б/Н/Ч, средний Эло, год; для книг — «N глав»), клавиши ←/→/Home/End/Backspace/1–9/F/Ctrl+Backspace, «Вернуть» после сброса, фоновые задачи `Background` с отменой |
|
||||
| `game_view.rs` | Экран партии: доска, шкала оценки, панель анализа, предпросмотр PV, нотация, панель инструментов, клавиатура |
|
||||
| `notation.rs` | Нотация: основная линия таблицей в две колонки, комментарии/варианты блоками, вложенные варианты в скобках |
|
||||
|
|
@ -44,7 +46,7 @@ XDG_CONFIG_HOME=/tmp/cfg CP_OPEN=11 CP_PLY=3 CP_ANALYZE=1 ./target/debug/chesspe
|
|||
```
|
||||
|
||||
`CP_OPEN` — индекс партии (с 0) в первой базе списка, `CP_PLY` — шагов по основной линии,
|
||||
`CP_UPDATE_SOURCE=<папка>` — брать «последний выпуск» из `latest.json` и файлов этой папки вместо GitHub, `CP_UPDATE_KIND=deb|rpm|arch|aur|flatpak|appimage|tarball|windows|mac` — считать установку такой, `CP_UPDATE_OPEN=1` — открыть окно обновления (`=start` — сразу начать), `CP_TAB=reference` — открыть у партии вкладку «Справочник», `CP_ANALYZE` — запустить активный движок, `CP_SETTINGS` — открыть настройки (`=board`, `=about` — сразу эту вкладку), `CP_ENGINE_PANEL` — раскрыть панель настроек движка, `CP_VAR` — перейти в первый вариант после `CP_PLY`, `CP_REVIEW=1` — запустить анализ партии (`=dialog` — только открыть окно), `CP_REPORT=1` — открыть вкладку «Отчёт» (нужен готовый анализ), `CP_BEST=k` — показать на доске k-й ход лучшей линии у первой отметки движка (нужен готовый анализ), `CP_ENGINE_OFFER=1` — окно предложения скачать Stockfish (`=download` — сразу начать загрузку), `CP_BOARD="e4 c5 Nf3"` — доска поиска большой базы с этими ходами (SAN), `CP_SORT=date` — большая база по дате (новые сверху), `CP_PANE=hidden` — большая база без правой панели, `CP_FILTER="player=carlsen;years=2015-2026;elo=2600"` — несколько фильтров большой базы, `CP_FILTER_PLAYER=имя` — фильтр «Игрок» большой базы ChessBase при запуске, `CP_SCREENSHOT=file.png` (+ `CP_SCREENSHOT_DELAY=сек`) — полноэкранный снимок окна и выход; так сделаны `docs/screenshots/`. `CP_ONLINE=<ник>` — открыть окно онлайн-партий и найти ник (`CP_ONLINE_DOWNLOAD=1` — сразу загрузить). Ключ `--bench <база> [отчёт.txt]` печатает замеры базы вместо окна (`docs/dev/import.md`, «Замер на другой машине»). `CP_MEMORY_LIMIT=<МБ>` — считать доступной памятью не больше этого (пути без дебютного индекса и без таблицы позиций PGN).
|
||||
`CP_ONLINE=<ник>` — открыть окно онлайн-партий и найти ник (`CP_ONLINE_DOWNLOAD=1` — сразу скачать). `CP_UPDATE_SOURCE=<папка>` — брать «последний выпуск» из `latest.json` и файлов этой папки вместо GitHub, `CP_UPDATE_KIND=deb|rpm|arch|aur|flatpak|appimage|tarball|windows|mac` — считать установку такой, `CP_UPDATE_OPEN=1` — открыть окно обновления (`=start` — сразу начать), `CP_TAB=reference` — открыть у партии вкладку «Справочник», `CP_ANALYZE` — запустить активный движок, `CP_SETTINGS` — открыть настройки (`=board`, `=about` — сразу эту вкладку), `CP_ENGINE_PANEL` — раскрыть панель настроек движка, `CP_VAR` — перейти в первый вариант после `CP_PLY`, `CP_REVIEW=1` — запустить анализ партии (`=dialog` — только открыть окно), `CP_REPORT=1` — открыть вкладку «Отчёт» (нужен готовый анализ), `CP_BEST=k` — показать на доске k-й ход лучшей линии у первой отметки движка (нужен готовый анализ), `CP_ENGINE_OFFER=1` — окно предложения скачать Stockfish (`=download` — сразу начать загрузку), `CP_BOARD="e4 c5 Nf3"` — доска поиска большой базы с этими ходами (SAN), `CP_SORT=date` — большая база по дате (новые сверху), `CP_PANE=hidden` — большая база без правой панели, `CP_FILTER="player=carlsen;years=2015-2026;elo=2600"` — несколько фильтров большой базы, `CP_FILTER_PLAYER=имя` — фильтр «Игрок» большой базы ChessBase при запуске, `CP_SCREENSHOT=file.png` (+ `CP_SCREENSHOT_DELAY=сек`) — полноэкранный снимок окна и выход; так сделаны `docs/screenshots/`. `CP_ONLINE=<ник>` — открыть окно онлайн-партий и найти ник (`CP_ONLINE_DOWNLOAD=1` — сразу загрузить). Ключ `--bench <база> [отчёт.txt]` печатает замеры базы вместо окна (`docs/dev/import.md`, «Замер на другой машине»). `CP_MEMORY_LIMIT=<МБ>` — считать доступной памятью не больше этого (пути без дебютного индекса и без таблицы позиций PGN).
|
||||
|
||||
## Языки
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,11 @@
|
|||
<category>BoardGame</category>
|
||||
</categories>
|
||||
<releases>
|
||||
<release version="0.8.0" date="2026-10-20">
|
||||
<description>
|
||||
<p>Games from Lichess and Chess.com: download anyone's games by nickname — yours, a pupil's, an opponent's — into a database, both sites merged or one per site, and fetch the new ones with one click. Interrupted downloads continue without duplicates.</p>
|
||||
</description>
|
||||
</release>
|
||||
<release version="0.7.1" date="2026-10-20">
|
||||
<description>
|
||||
<p>Updates: ChessPenguin tells when a new version is out and updates itself where it can (Windows, AppImage, the Linux archive); for packages it downloads the new one and shows the command that installs it.</p>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue