feat: translate subtitles with an OpenAI-compatible LLM
This commit is contained in:
1 parent
48cac86d60
commit
4665bf632a
21 files changed
+1877
-5
No files matched your search
@@ -185,6 +185,24 @@ void MpvItem::addSubtitleFile(const QUrl &url)
|
||||
commandAsync(QStringList{QStringLiteral("sub-add"), localPathOrUrl(url), QStringLiteral("select")});
|
||||
}
|
||||
|
||||
void MpvItem::showSecondarySubtitleFile(const QUrl &url, const QString &title)
|
||||
{
|
||||
if (!url.isValid()) {
|
||||
return;
|
||||
}
|
||||
const QString path = localPathOrUrl(url);
|
||||
for (const QVariant &entry : std::as_const(m_subtitleTracks)) {
|
||||
const QVariantMap track = entry.toMap();
|
||||
if (track.value(QStringLiteral("externalFilename")).toString() == path) {
|
||||
setSecondarySubtitleId(track.value(QStringLiteral("id")).toInt());
|
||||
return;
|
||||
}
|
||||
}
|
||||
// "auto" adds the track without selecting it; updateTracks() selects it as secondary.
|
||||
m_pendingSecondaryPath = path;
|
||||
commandAsync(QStringList{QStringLiteral("sub-add"), path, QStringLiteral("auto"), title});
|
||||
}
|
||||
|
||||
void MpvItem::showText(const QString &text)
|
||||
{
|
||||
commandAsync(QStringList{QStringLiteral("show-text"), text});
|
||||
@@ -241,7 +259,13 @@ void MpvItem::updateTracks(const QVariantList &trackList)
|
||||
{QStringLiteral("codec"), track.value(QStringLiteral("codec")).toString()},
|
||||
{QStringLiteral("external"), track.value(QStringLiteral("external")).toBool()},
|
||||
{QStringLiteral("externalFilename"), track.value(QStringLiteral("external-filename")).toString()},
|
||||
{QStringLiteral("ffIndex"), track.value(QStringLiteral("ff-index"), -1).toInt()},
|
||||
});
|
||||
|
||||
if (!m_pendingSecondaryPath.isEmpty() && track.value(QStringLiteral("external-filename")).toString() == m_pendingSecondaryPath) {
|
||||
m_pendingSecondaryPath.clear();
|
||||
setSecondarySubtitleId(id);
|
||||
}
|
||||
}
|
||||
|
||||
m_subtitleTracks = subtitles;
|
||||
|
||||
Reference in new issue
Block a user