tizen removal check

This commit is contained in:
PatrickSt1991
2025-06-02 15:46:59 +02:00
parent 1dfd9f7f7e
commit 38dfe0b053
5 changed files with 70 additions and 22 deletions

View File

@@ -186,6 +186,24 @@ namespace Samsung_Jellyfin_Installer.Localization {
}
}
/// <summary>
/// Looks up a localized string similar to Failed to remove old app version.
/// </summary>
public static string FailedRemoveOld {
get {
return ResourceManager.GetString("FailedRemoveOld", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Please remove the old Jellyfin app by hand from the TV.
/// </summary>
public static string FailedRemoveOldExtra {
get {
return ResourceManager.GetString("FailedRemoveOldExtra", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Generating keypair.
/// </summary>

View File

@@ -297,4 +297,10 @@
<data name="UsingCustomWGT" xml:space="preserve">
<value />
</data>
<data name="FailedRemoveOld" xml:space="preserve">
<value>Kunne ikke fjerne den gamle appversion</value>
</data>
<data name="FailedRemoveOldExtra" xml:space="preserve">
<value>Fjern venligst den gamle Jellyfin-app manuelt fra tv'et</value>
</data>
</root>

View File

@@ -297,4 +297,10 @@
<data name="UsingCustomWGT" xml:space="preserve">
<value>Aangepast WGT-bestand gebruiken</value>
</data>
<data name="FailedRemoveOld" xml:space="preserve">
<value>Het is niet gelukt om de oude app-versie te verwijderen</value>
</data>
<data name="FailedRemoveOldExtra" xml:space="preserve">
<value>Verwijder de oude Jellyfin-app handmatig van de tv</value>
</data>
</root>

View File

@@ -297,4 +297,10 @@
<data name="UsingCustomWGT" xml:space="preserve">
<value>Using custom WGT file</value>
</data>
<data name="FailedRemoveOld" xml:space="preserve">
<value>Failed to remove old app version</value>
</data>
<data name="FailedRemoveOldExtra" xml:space="preserve">
<value>Please remove the old Jellyfin app by hand from the TV</value>
</data>
</root>

View File

@@ -112,7 +112,7 @@ namespace Samsung_Jellyfin_Installer.Services
updateStatus("CheckTizenOS".Localized());
string tizenOs = await FetchTizenOsVersion(TizenSdbPath);
if (new Version(tizenOs) >= new Version("7.0"))
{
try
@@ -170,7 +170,13 @@ namespace Samsung_Jellyfin_Installer.Services
if (Settings.Default.DeletePreviousInstall)
{
updateStatus("Removing old Jellyfin app");
await RemoveJellyfinAppByIdAsync(tvName, updateStatus);
bool removeOldJelly = await RemoveJellyfinAppByIdAsync(tvName, updateStatus);
if (!removeOldJelly)
{
MessageBox.Show("FailedRemoveOldExtra".Localized(), "Error", MessageBoxButton.OK);
return InstallResult.FailureResult("FailedRemoveOld".Localized());
}
}
updateStatus("InstallingPackage".Localized());
@@ -434,34 +440,40 @@ namespace Samsung_Jellyfin_Installer.Services
catch { /* Ignore cleanup errors */ }
}
}
public async Task RemoveJellyfinAppByIdAsync(string tvName, Action<string> updateStatus)
private async Task<string> SearchJellyfinApp()
{
string appId = null;
string output = await RunCommandAsync(TizenSdbPath, "sdb shell 0 vd_applist | findstr Jellyfin");
var jellyfinPattern = @"'Jellyfin'\s+'([^']+)'";
var match = Regex.Match(output, jellyfinPattern, RegexOptions.IgnoreCase);
if (match.Success && match.Groups.Count > 1)
appId = match.Groups[1].Value;
return appId;
}
public async Task<bool> RemoveJellyfinAppByIdAsync(string tvName, Action<string> updateStatus)
{
try
{
string output = await RunCommandAsync(TizenSdbPath, "shell 0 applist");
var jellyfinPattern = @"'Jellyfin'\s+'([^']+)'";
var match = Regex.Match(output, jellyfinPattern, RegexOptions.IgnoreCase);
string appId = await SearchJellyfinApp();
if (match.Success && match.Groups.Count > 1)
{
string appId = match.Groups[1].Value;
if (!string.IsNullOrEmpty(appId))
{
try
{
await RunCommandAsync(TizenSdbPath, $"uninstall -t {tvName} -p {appId}");
}
catch (Exception ex)
{
updateStatus($"Output: {ex.Message}".Localized());
}
}
}
if (string.IsNullOrEmpty(appId))
return true;
await RunCommandAsync(TizenCliPath, $"uninstall -t {tvName} -p {appId}");
appId = await SearchJellyfinApp();
if (!string.IsNullOrEmpty(appId))
return false;
return true;
}
catch (Exception ex)
{
updateStatus($"Output: {ex.Message}".Localized());
return false;
}
}
}