mirror of
https://github.com/narrrl/proton-stream.git
synced 2026-11-04 00:47:00 +01:00
feat(meta,core,app,android,ios): AniSkip where files have no chapters
Most files that are not fansub releases carry no chapters, so they had no skip button. AniSkip knows where an episode's opening and ending are, by MyAnimeList id and episode number. ani.zip sends each entry's MyAnimeList id and enrichment now keeps it on every episode row; schema v14 adds the column and marks AniList titles un-enriched, deleting nothing, as v13 did. When a file has loaded with no chapter naming an opening or ending, and its length is known, each client asks once, with enrichment on only. The answer lives as long as the file is open. with_skip_ranges cuts it into the chapters as chapters named Opening and Ending, so the skip button, auto-skip, the up-next countdown and the seek bar's marks all work through the code a chaptered file uses. A file's own opening or ending always wins over AniSkip's. PRIVACY.md lists what is sent: the MyAnimeList id, the episode number and the file's length.
This commit is contained in:
1 parent
466630a9ba
commit
cf8ee58f6b
23 files changed
+728
-11
No files matched your search
@@ -1116,6 +1116,11 @@ impl App {
|
||||
matcher.error = Some(error);
|
||||
}
|
||||
}
|
||||
Event::SkipTimes { player, ranges } => {
|
||||
if let Some(playback) = self.playback.as_mut().filter(|p| p.id == player) {
|
||||
playback.set_skip_ranges(ranges);
|
||||
}
|
||||
}
|
||||
Event::PlaybackReady { target, stream } => {
|
||||
let opening = self.opening.take();
|
||||
// Dropped before the new one is built: two mpv cores would
|
||||
@@ -1457,6 +1462,34 @@ impl App {
|
||||
})
|
||||
}
|
||||
|
||||
/// Once a file has loaded with no chapters naming its opening or ending,
|
||||
/// ask AniSkip, when the episode's provider entry has a MyAnimeList id.
|
||||
fn ask_skip_times(&mut self) {
|
||||
let Some(playback) = &mut self.playback else {
|
||||
return;
|
||||
};
|
||||
let Some(length) = playback.wants_skip_times() else {
|
||||
return;
|
||||
};
|
||||
playback.skips_asked = true;
|
||||
let target = &playback.target;
|
||||
let found = self.library.get(&target.title_key).and_then(|title| {
|
||||
let episode = title.episodes().find(|episode| {
|
||||
episode.node.share_id == target.share_id && episode.node.link_id == target.link_id
|
||||
})?;
|
||||
let number = episode.node.parsed.episode?;
|
||||
self.episodes
|
||||
.get(&title.key)?
|
||||
.get(episode.node.parsed.season, number)
|
||||
});
|
||||
if let Some((mal_id, number)) =
|
||||
found.and_then(|found| Some((found.mal_id?, found.entry_number?)))
|
||||
{
|
||||
self.engine
|
||||
.request_skip_times(playback.id, mal_id, number, length);
|
||||
}
|
||||
}
|
||||
|
||||
/// Near the end of a file, fetch the opening blocks of the next one.
|
||||
///
|
||||
/// The last two minutes, or the credits if the chapters say where they
|
||||
@@ -2311,6 +2344,7 @@ impl eframe::App for App {
|
||||
}
|
||||
}
|
||||
self.warm_next();
|
||||
self.ask_skip_times();
|
||||
self.auto_skip(ctx);
|
||||
self.save_subtitle_style(ctx);
|
||||
self.window.observe(ctx);
|
||||
|
||||
Reference in new issue
Block a user