Skip to content

Commit 878511b

Browse files
committed
release v0.2.2
1 parent b1ed975 commit 878511b

File tree

5 files changed

+38
-34
lines changed

5 files changed

+38
-34
lines changed

FlyleafLib/MediaPlayer/SubtitlesManager.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public class SubManager : INotifyPropertyChanged
6767
{
6868
private readonly Lock _locker = new();
6969
private CancellationTokenSource? _cts;
70-
public SubtitleData? SelectedSub { get; set => Set(ref field, value); } = null;
70+
public SubtitleData? SelectedSub { get; set => Set(ref field, value); }
7171
public int CurrentIndex { get; private set => Set(ref field, value); } = -1;
7272

7373
public PositionState State
@@ -94,7 +94,7 @@ private set
9494
/// <summary>
9595
/// True when addition to Subs is running... (Reading all subtitles, OCR, ASR)
9696
/// </summary>
97-
public bool IsLoading { get; private set => Set(ref field, value); } = false;
97+
public bool IsLoading { get; private set => Set(ref field, value); }
9898

9999
// LanguageSource with fallback
100100
public Language? Language
@@ -776,7 +776,7 @@ public void ReadAll(bool useBitmap, Action<SubtitleData> addSub, CancellationTok
776776
string text = Utils.BytePtrToStringUTF8(sub.rects[0]->ass).Trim();
777777
avsubtitle_free(&sub);
778778

779-
subData.Text = ParseSubtitles.SSAtoSubStyles(text, out var subStyles);
779+
subData.Text = ParseSubtitles.SSAtoSubStyles(text, out var subStyles).Trim();
780780
subData.SubStyles = subStyles;
781781

782782
if (string.IsNullOrEmpty(subData.Text))
@@ -1183,8 +1183,7 @@ protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
11831183

11841184
public void AddRange(IEnumerable<T> list)
11851185
{
1186-
if (list == null)
1187-
ArgumentNullException.ThrowIfNull(list);
1186+
ArgumentNullException.ThrowIfNull(list);
11881187

11891188
_suppressNotification = true;
11901189

LLPlayer/LLPlayer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<ApplicationIcon>LLPlayer.ico</ApplicationIcon>
1414
<Description>The media player for language learning.</Description>
1515
<PackageProjectUrl>https://llplayer.com</PackageProjectUrl>
16-
<Version>0.2.1</Version>
16+
<Version>0.2.2</Version>
1717
</PropertyGroup>
1818

1919
<ItemGroup>

LLPlayer/ViewModels/SubtitlesDownloaderDialogVM.cs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.ComponentModel;
33
using System.IO;
44
using FlyleafLib;
5+
using FlyleafLib.MediaFramework.MediaPlaylist;
56
using FlyleafLib.MediaPlayer;
67
using LLPlayer.Extensions;
78
using LLPlayer.Services;
@@ -211,12 +212,24 @@ private void Playlist_OnPropertyChanged(object? sender, PropertyChangedEventArgs
211212
FL.Player.Playlist.Selected != null)
212213
{
213214
// Update query when video changes
214-
string? title = FL.Player.Playlist.Selected.Title;
215-
if (Query != title)
215+
UpdateQuery(FL.Player.Playlist.Selected);
216+
}
217+
}
218+
219+
private void UpdateQuery(PlaylistItem selected)
220+
{
221+
string title = selected.Title;
222+
if (title == selected.OriginalTitle && File.Exists(selected.Url))
223+
{
224+
FileInfo fi = new(selected.Url);
225+
if (!string.IsNullOrEmpty(fi.Extension) && title.EndsWith(fi.Extension))
216226
{
217-
Query = title;
227+
// remove extension part
228+
title = title[..^fi.Extension.Length];
218229
}
219230
}
231+
232+
Query = title;
220233
}
221234

222235
#region IDialogAware
@@ -241,18 +254,7 @@ public void OnDialogOpened(IDialogParameters parameters)
241254
var selected = FL.Player.Playlist.Selected;
242255
if (selected != null)
243256
{
244-
string title = selected.Title;
245-
if (title == selected.OriginalTitle && File.Exists(selected.Url))
246-
{
247-
FileInfo fi = new(selected.Url);
248-
if (!string.IsNullOrEmpty(fi.Extension) && title.EndsWith(fi.Extension))
249-
{
250-
// remove extension part
251-
title = title[..^fi.Extension.Length];
252-
}
253-
}
254-
255-
Query = title;
257+
UpdateQuery(selected);
256258
}
257259

258260
// Register update playlist event

Plugins/YoutubeDL/YoutubeDL.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ private void NewPlaylistItem(string path)
380380
const string suffix = "-orig";
381381

382382
string langCode = subtitle1.Key;
383-
bool isOriginal = langCode.EndsWith(suffix);
383+
bool isOriginal = langCode.EndsWith(suffix, StringComparison.OrdinalIgnoreCase);
384384

385385
if (isOriginal)
386386
{

README.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ LLPlayer has many features for language learning that are not available in norma
2828
- **Real-time Translation:** Supports [many translation engines](https://github.com/umlx5h/LLPlayer/wiki/Translation-Engine), such as Google, DeepL, Ollama, LM Studio, OpenAI.
2929
- **Context-aware Translation:** Highly accurate translation by recognizing the context of subtitles using LLM.
3030
- **Real-time OCR subtitles:** Can convert bitmap subtitles to text subtitles in real time, powered by [Tesseract OCR](https://github.com/tesseract-ocr/tesseract) and Microsoft OCR.
31-
- **Subtitles Sidebar:** Both text and bitmap are supported. Seek and word lookup available. Has anti-spoiler functionality.
31+
- **Subtitles Sidebar:** Both text and bitmap are supported. Seek and word lookup available. Also supports incremental subtitle search.
3232
- **Instant word lookup:** Word lookup and browser searches can be performed on subtitle text.
3333
- **Customizable Browser Search:** Browser searches can be performed from the context menu of a word, and the search site can be completely customized.
3434
- **Plays online videos:** With [yt-dlp](https://github.com/yt-dlp/yt-dlp) integration, any online video can be played back in real time, with AI subtitle generation, word lookups!
@@ -314,17 +314,20 @@ If you want to update, please download and copy it to the specified path.
314314
VLC is a general-purpose media player.
315315
In contrast, LLPlayer has many useful features especially for language learning.
316316

317-
| | VLC | LLPlayer |
318-
| -------------------------------- | ------------------------------ | --------------------------------- |
319-
| Cross-Platform (Win, Linux, Mac) | ✔️ ||
320-
| Auto-generated subtitles | not yet (whisper.cpp) | ✔️ (whisper.cpp, faster-whisper) |
321-
| Real-time translation | not yet (probably SeamlessM4T) | ✔️ (Google, DeepL, Ollama, OpenAI) |
322-
| Context-aware translation | ❌ (probably) | ✔️ (by LLM) |
323-
| Word Translation || ✔️ |
324-
| Word Search || ✔️ |
325-
| Subtitle Sidebar || ✔️ |
326-
| Subtitle Seeking || ✔️ |
327-
| Dual Subtitles | ✔️ (awkward to use) | ✔️ |
317+
| | VLC | LLPlayer |
318+
| -------------------------------- | ---------------------- | ------------------------------- |
319+
| Cross-Platform (Win, Linux, Mac) | ✔️ ||
320+
| Auto-generated subtitles | not yet (whisper.cpp) | ✔️ (whisper.cpp, faster-whisper) |
321+
| Real-time translation | not yet | ✔️ |
322+
| Local translation | not yet (SeamlessM4t?) | ✔️ (Ollama, LM Studio) |
323+
| Online translation || ✔️ (Google, DeepL, OpenAI) |
324+
| Context-aware translation || ✔️ (by LLM) |
325+
| Word Translation || ✔️ |
326+
| Word Search || ✔️ |
327+
| Subtitle Sidebar || ✔️ |
328+
| Incremental Subtitle Search || ✔️ |
329+
| Subtitle Seeking || ✔️ |
330+
| Dual Subtitles | ✔️ (awkward to use) | ✔️ |
328331

329332
#### Q: Why perform subtitle generation and translation in real time?
330333

0 commit comments

Comments
 (0)