halkyon/halkyon_learn_flutter/test/support/sample_episode.dart

306 lines
7.3 KiB
Dart
Raw Normal View History

feat(jellyfin): watch from one's own Jellyfin server and learn the words of its subtitles Animelon's way of learning from video, from the person's own Jellyfin server: connected per device (Settings, or a studyset's Add material › Watch from Jellyfin) with a name and password or a Quick Connect code, over HTTPS only (plain HTTP only to a server on the same machine); the token stays in the system's keyring. Shows, films and videos tied to a studyset follow the person in their settings as the server's and the item's ids alone (settings schema 9), named by the server when shown. The Watch screen plays the video (video_player on Android, media_kit's libmpv on Linux and Windows) with the line in the studyset's front language cut into the dictionary's words with furigana, and the back language's line beneath; a word tapped pauses the video and becomes a card with the line and its translation as its first hint, tagged with the show. The video's words are listed, most frequent first. The sound is the track in the studyset's language, whichever the file marks default, and the menu switches it; the subtitles read are a whole track, never a forced one (which only covers what the sound doesn't say), and captions for the hard of hearing only without plain ones. The line and its translation take the video's width in a box of a fixed height, so the video keeps its size; in the dark theme the video's colours glow around it, as YouTube's ambient mode, and the words' panel takes the colour of the episode's picture under the pointer. A line is cut into words with one request: DictionaryEndpoint.withKeys looks up every stretch of it that may be a word, as it stands and as every word it may be a conjugation of, in the new dictionary_key table (one row per key, indexed; migration dictionary-keys adds the table and its index, nothing else), which the loader fills beside the entries. The instance gets the text of each line looked up and keeps none of it, as the Watch screen says. Linux builds need libmpv-dev, and the app links libmpv: the snap stages Ubuntu's libmpv2, makes the update-alternatives links for BLAS and LAPACK that ffmpeg's speech recognition needs (staging never runs install scripts), and removes what the GNOME runtime and core24 already hold, as older copies of cairo, pango and librsvg hid the runtime's from its GTK. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-10-13 11:31:37 +02:00
import 'package:halkyon_learn_flutter/src/feature/card/model/card_content.dart';
import 'package:halkyon_learn_flutter/src/feature/dictionary/model/dictionary.dart';
import 'package:halkyon_learn_flutter/src/feature/jellyfin/model/jellyfin.dart';
import 'fake_dictionary_gateway.dart';
import 'fake_jellyfin.dart';
/// The show of the sample library.
const sampleShow = JellyfinItem(
id: 'show-1',
name: 'Sample Journey',
kind: JellyfinItemKind.series,
year: 2026,
);
/// Its first episode.
const sampleEpisode = JellyfinItem(
id: 'episode-1',
name: 'The Station',
kind: JellyfinItemKind.episode,
seriesName: 'Sample Journey',
seasonNumber: 1,
episodeNumber: 1,
runTime: Duration(minutes: 24),
);
/// The episode's playback: a Japanese track and an English one.
const sampleEpisodePlayback = JellyfinPlayback(
itemId: 'episode-1',
mediaSourceId: 'episode-1',
playSessionId: 'session-1',
runTime: Duration(minutes: 24),
subtitles: [
JellyfinSubtitleTrack(
index: 2,
title: '日本語 - Japanese',
language: 'jpn',
isDefault: true,
),
JellyfinSubtitleTrack(index: 3, title: 'English', language: 'eng'),
],
);
/// The episode's Japanese subtitles, as Jellyfin converts them.
const sampleJapanese = '''
WEBVTT
00:00:01.000 --> 00:00:05.000
昨日、駅で友達に会いました。
00:00:06.000 --> 00:00:10.000
まだ読んでいないけど、面白そうだね。
00:00:11.000 --> 00:00:15.000
一緒に旅を続けよう。
00:00:16.000 --> 00:00:20.000
駅で友達を待っている。
''';
/// Its English subtitles.
const sampleEnglish = '''
WEBVTT
00:00:01.000 --> 00:00:05.000
Yesterday I met a friend at the station.
00:00:06.000 --> 00:00:10.000
Not yet, but it looks interesting.
00:00:11.000 --> 00:00:15.000
Let's continue the journey together.
00:00:16.000 --> 00:00:20.000
I'm waiting for a friend at the station.
''';
DictionaryWord _word(
String id,
String headword, {
String? reading,
required List<String> glosses,
List<String> pos = const ['n'],
List<String> misc = const [],
List<String> labels = const ['common'],
List<WordExample> examples = const [],
feat(jellyfin): watch from one's own Jellyfin server and learn the words of its subtitles Animelon's way of learning from video, from the person's own Jellyfin server: connected per device (Settings, or a studyset's Add material › Watch from Jellyfin) with a name and password or a Quick Connect code, over HTTPS only (plain HTTP only to a server on the same machine); the token stays in the system's keyring. Shows, films and videos tied to a studyset follow the person in their settings as the server's and the item's ids alone (settings schema 9), named by the server when shown. The Watch screen plays the video (video_player on Android, media_kit's libmpv on Linux and Windows) with the line in the studyset's front language cut into the dictionary's words with furigana, and the back language's line beneath; a word tapped pauses the video and becomes a card with the line and its translation as its first hint, tagged with the show. The video's words are listed, most frequent first. The sound is the track in the studyset's language, whichever the file marks default, and the menu switches it; the subtitles read are a whole track, never a forced one (which only covers what the sound doesn't say), and captions for the hard of hearing only without plain ones. The line and its translation take the video's width in a box of a fixed height, so the video keeps its size; in the dark theme the video's colours glow around it, as YouTube's ambient mode, and the words' panel takes the colour of the episode's picture under the pointer. A line is cut into words with one request: DictionaryEndpoint.withKeys looks up every stretch of it that may be a word, as it stands and as every word it may be a conjugation of, in the new dictionary_key table (one row per key, indexed; migration dictionary-keys adds the table and its index, nothing else), which the loader fills beside the entries. The instance gets the text of each line looked up and keeps none of it, as the Watch screen says. Linux builds need libmpv-dev, and the app links libmpv: the snap stages Ubuntu's libmpv2, makes the update-alternatives links for BLAS and LAPACK that ffmpeg's speech recognition needs (staging never runs install scripts), and removes what the GNOME runtime and core24 already hold, as older copies of cairo, pango and librsvg hid the runtime's from its GTK. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-10-13 11:31:37 +02:00
}) => DictionaryWord(
ref: (source: 'jmdict', id: id),
headword: headword,
reading: reading,
labels: labels,
senses: [VocabularySense(glosses: glosses, pos: pos, misc: misc)],
examples: examples,
feat(jellyfin): watch from one's own Jellyfin server and learn the words of its subtitles Animelon's way of learning from video, from the person's own Jellyfin server: connected per device (Settings, or a studyset's Add material › Watch from Jellyfin) with a name and password or a Quick Connect code, over HTTPS only (plain HTTP only to a server on the same machine); the token stays in the system's keyring. Shows, films and videos tied to a studyset follow the person in their settings as the server's and the item's ids alone (settings schema 9), named by the server when shown. The Watch screen plays the video (video_player on Android, media_kit's libmpv on Linux and Windows) with the line in the studyset's front language cut into the dictionary's words with furigana, and the back language's line beneath; a word tapped pauses the video and becomes a card with the line and its translation as its first hint, tagged with the show. The video's words are listed, most frequent first. The sound is the track in the studyset's language, whichever the file marks default, and the menu switches it; the subtitles read are a whole track, never a forced one (which only covers what the sound doesn't say), and captions for the hard of hearing only without plain ones. The line and its translation take the video's width in a box of a fixed height, so the video keeps its size; in the dark theme the video's colours glow around it, as YouTube's ambient mode, and the words' panel takes the colour of the episode's picture under the pointer. A line is cut into words with one request: DictionaryEndpoint.withKeys looks up every stretch of it that may be a word, as it stands and as every word it may be a conjugation of, in the new dictionary_key table (one row per key, indexed; migration dictionary-keys adds the table and its index, nothing else), which the loader fills beside the entries. The instance gets the text of each line looked up and keeps none of it, as the Watch screen says. Linux builds need libmpv-dev, and the app links libmpv: the snap stages Ubuntu's libmpv2, makes the update-alternatives links for BLAS and LAPACK that ffmpeg's speech recognition needs (staging never runs install scripts), and removes what the GNOME runtime and core24 already hold, as older copies of cairo, pango and librsvg hid the runtime's from its GTK. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-10-13 11:31:37 +02:00
);
/// The JMdict entries of the sample's words, as the instance gives them.
final sampleWords = [
_word(
'1',
'昨日',
reading: 'きのう',
glosses: ['yesterday'],
labels: ['common', 'jlpt:n5'],
),
_word(
'2',
'駅',
reading: 'えき',
glosses: ['station'],
labels: ['common', 'jlpt:n5'],
),
_word('3', 'で', glosses: ['at', 'in'], pos: ['prt']),
_word(
'4',
'友達',
reading: 'ともだち',
glosses: ['friend'],
labels: ['common', 'jlpt:n5'],
),
_word('5', 'に', glosses: ['to', 'at'], pos: ['prt']),
_word(
'6',
'会う',
reading: 'あう',
glosses: ['to meet'],
pos: ['v5u', 'vi'],
labels: ['common', 'jlpt:n5'],
// As Tatoeba's checked sentences come through JMdict.
examples: [
(
form: '会いましょう',
feat(dictionary): German, Greek, English, Chinese and Korean words A studyset in German, Greek, English, Chinese or Korean finds its dictionary as one in Japanese does (ADR 0008), and its subtitles are cut into words by its language (`WordCutting`): Chinese by its longest words as they stand, the longer words over each cut offered as for Japanese; Korean at its spaces, a word the dictionary lacks as it stands taken without the particle it ends with (집에서 is 집, 아이 stays a child); every other language at its spaces, a word written exactly so first (the noun Essen before the verb essen). A studyset finds the dictionary of its language tag, else of its language alone (zh for zh-Hans). A Wiktionary word shows its genders, principal forms, IPA, romanisation and Hanja; a German or Greek noun of one gender goes onto its card with its article (das Haus, το σπίτι); its tag is its word class, named in full (Noun, Adjective, Preposition), as Wiktionary's adj and adv would read as JMdict's codes. Articles, pronouns, prepositions and conjunctions are left out of a video's words. Chinese words show their pinyin over each character on the Watch screen, carry their HSK level as a tag (HSK-1 … HSK-7-9), and the dictionary adds a level whole; the Watch screen filters by HSK levels for Chinese, JLPT's for Japanese, and by none for a language without. A reading is typed in a session only when it is kana, so pinyin isn't. Words are looked up on the web on Jisho in Japanese, on Wiktionary at the language's section otherwise, and a search's hint speaks of kana and romaji only in Japanese. `DICTIONARY_LANGUAGES` in deploy/.env names the languages an instance keeps (unset: de,el,en,ko,zh; empty: none). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-10-14 07:45:15 +02:00
sentence: 'また会いましょう。',
translation: "Let's meet again.",
),
],
feat(jellyfin): watch from one's own Jellyfin server and learn the words of its subtitles Animelon's way of learning from video, from the person's own Jellyfin server: connected per device (Settings, or a studyset's Add material › Watch from Jellyfin) with a name and password or a Quick Connect code, over HTTPS only (plain HTTP only to a server on the same machine); the token stays in the system's keyring. Shows, films and videos tied to a studyset follow the person in their settings as the server's and the item's ids alone (settings schema 9), named by the server when shown. The Watch screen plays the video (video_player on Android, media_kit's libmpv on Linux and Windows) with the line in the studyset's front language cut into the dictionary's words with furigana, and the back language's line beneath; a word tapped pauses the video and becomes a card with the line and its translation as its first hint, tagged with the show. The video's words are listed, most frequent first. The sound is the track in the studyset's language, whichever the file marks default, and the menu switches it; the subtitles read are a whole track, never a forced one (which only covers what the sound doesn't say), and captions for the hard of hearing only without plain ones. The line and its translation take the video's width in a box of a fixed height, so the video keeps its size; in the dark theme the video's colours glow around it, as YouTube's ambient mode, and the words' panel takes the colour of the episode's picture under the pointer. A line is cut into words with one request: DictionaryEndpoint.withKeys looks up every stretch of it that may be a word, as it stands and as every word it may be a conjugation of, in the new dictionary_key table (one row per key, indexed; migration dictionary-keys adds the table and its index, nothing else), which the loader fills beside the entries. The instance gets the text of each line looked up and keeps none of it, as the Watch screen says. Linux builds need libmpv-dev, and the app links libmpv: the snap stages Ubuntu's libmpv2, makes the update-alternatives links for BLAS and LAPACK that ffmpeg's speech recognition needs (staging never runs install scripts), and removes what the GNOME runtime and core24 already hold, as older copies of cairo, pango and librsvg hid the runtime's from its GTK. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-10-13 11:31:37 +02:00
),
_word(
'7',
'未だ',
reading: 'まだ',
glosses: ['still', 'not yet'],
pos: ['adv'],
misc: ['uk'],
labels: ['common', 'jlpt:n5'],
),
_word(
'8',
'読む',
reading: 'よむ',
glosses: ['to read'],
pos: ['v5m', 'vt'],
labels: ['common', 'jlpt:n5'],
),
_word('9', 'けど', glosses: ['but', 'however'], pos: ['conj']),
_word(
'10',
'面白い',
reading: 'おもしろい',
glosses: ['interesting', 'amusing'],
pos: ['adj-i'],
labels: ['common', 'jlpt:n5'],
),
_word('11', 'だ', glosses: ['be', 'is'], pos: ['cop']),
_word('12', 'ね', glosses: ["isn't it?"], pos: ['prt']),
_word(
'13',
'一緒に',
reading: 'いっしょに',
glosses: ['together'],
pos: ['adv'],
labels: ['common', 'jlpt:n4'],
),
_word(
'14',
'旅',
reading: 'たび',
glosses: ['travel', 'trip', 'journey'],
labels: ['common', 'jlpt:n3'],
),
_word('15', 'を', glosses: ['indicates direct object'], pos: ['prt']),
_word(
'16',
'続ける',
reading: 'つづける',
glosses: ['to continue'],
pos: ['v1', 'vt'],
labels: ['common', 'jlpt:n4'],
),
_word(
'17',
'待つ',
reading: 'まつ',
glosses: ['to wait'],
pos: ['v5t', 'vt'],
labels: ['common', 'jlpt:n5'],
),
];
/// An instance with JMdict holding the sample's words.
FakeDictionaryGateway sampleDictionary() =>
FakeDictionaryGateway(words: sampleWords);
/// The sample library: Anime, holding the show, its season and episode.
FakeJellyfinGateway sampleJellyfin({
JellyfinPlayback playback = sampleEpisodePlayback,
Map<(String, int), String> vtt = const {
('episode-1', 2): sampleJapanese,
('episode-1', 3): sampleEnglish,
},
}) => FakeJellyfinGateway(
tree: {
'': [
const JellyfinItem(
id: 'library-1',
name: 'Anime',
kind: JellyfinItemKind.library,
),
],
'library-1': [sampleShow],
'show-1': [
const JellyfinItem(
id: 'season-1',
name: 'Season 1',
kind: JellyfinItemKind.season,
seriesName: 'Sample Journey',
seasonNumber: 1,
),
],
'season-1': [sampleEpisode],
},
playbacks: {'episode-1': playback},
vtt: vtt,
);
/// The device signed in as `mika` on the sample server.
MemoryJellyfinStore signedInJellyfin() => MemoryJellyfinStore(
kept: JellyfinState(
deviceId: 'device-1',
account: JellyfinAccount(
server: fakeJellyfinServer,
userId: 'user-1',
userName: 'mika',
token: 'token-1',
),
),
);
/// A sample song: its album, by Sample Artist, holds it with lyrics timed
/// line by line, and an instrumental without.
const sampleSong = JellyfinItem(
id: 'song-1',
name: 'Sample Song',
kind: JellyfinItemKind.audio,
artist: 'Sample Artist',
hasLyrics: true,
hasImage: true,
runTime: Duration(minutes: 3),
);
/// A music library of one album: [sampleSong] and an instrumental.
FakeJellyfinGateway sampleMusic() => FakeJellyfinGateway(
tree: {
'': [
const JellyfinItem(
id: 'music-1',
name: 'Music',
kind: JellyfinItemKind.library,
),
],
'music-1': [
const JellyfinItem(
id: 'album-1',
name: 'Sample Album',
kind: JellyfinItemKind.album,
artist: 'Sample Artist',
),
],
'album-1': [
sampleSong,
const JellyfinItem(
id: 'song-2',
name: 'Sample Song (Instrumental)',
kind: JellyfinItemKind.audio,
artist: 'Sample Artist',
runTime: Duration(minutes: 3),
),
],
},
playbacks: {
'song-1': const JellyfinPlayback(
itemId: 'song-1',
mediaSourceId: 'song-1',
playSessionId: 'session-2',
subtitles: [],
runTime: Duration(minutes: 3),
audioOnly: true,
),
},
lyricsOf: {
'song-1': const [
(text: '昨日、駅で友達に会いました。', start: Duration(seconds: 1)),
(text: '', start: Duration(seconds: 5)),
(text: 'まだ読んでいないけど、面白そうだね。', start: Duration(seconds: 6)),
],
},
);