mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-21 13:53:19 -07:00
Finished #415
This commit is contained in:
parent
2aebbe0259
commit
7db336e202
19 changed files with 229 additions and 89 deletions
|
@ -24,6 +24,9 @@
|
|||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ************************************************************************/
|
||||
#endregion
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace PlexRequests.Core.SettingModels
|
||||
{
|
||||
public sealed class PlexSettings : ExternalSettings
|
||||
|
@ -36,5 +39,6 @@ namespace PlexRequests.Core.SettingModels
|
|||
public bool EnableTvEpisodeSearching { get; set; }
|
||||
|
||||
public string PlexAuthToken { get; set; }
|
||||
public string MachineIdentifier { get; set; }
|
||||
}
|
||||
}
|
|
@ -26,6 +26,7 @@
|
|||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using Mono.Data.Sqlite;
|
||||
|
@ -66,6 +67,11 @@ namespace PlexRequests.Core
|
|||
{
|
||||
MigrateToVersion1900();
|
||||
}
|
||||
|
||||
if(version > 1899 && version <= 1910)
|
||||
{
|
||||
MigrateToVersion1910();
|
||||
}
|
||||
}
|
||||
|
||||
return Db.DbConnection().ConnectionString;
|
||||
|
@ -244,5 +250,30 @@ namespace PlexRequests.Core
|
|||
Log.Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Migrates to version1910.
|
||||
/// </summary>
|
||||
public void MigrateToVersion1910()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Get the new machine Identifier
|
||||
var settings = new SettingsServiceV2<PlexSettings>(new SettingsJsonRepository(Db, new MemoryCacheProvider()));
|
||||
var plex = settings.GetSettings();
|
||||
if (!string.IsNullOrEmpty(plex.PlexAuthToken))
|
||||
{
|
||||
var api = new PlexApi(new ApiRequest());
|
||||
var server = api.GetServer(plex.PlexAuthToken); // Get the server info
|
||||
plex.MachineIdentifier = server.Server.FirstOrDefault(x => x.AccessToken == plex.PlexAuthToken)?.MachineIdentifier;
|
||||
|
||||
settings.SaveSettings(plex); // Save the new settings
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue