Skip to content

Commit

Permalink
Remove a lot of MAL stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
da3dsoul committed Jun 14, 2018
1 parent 027fbfe commit 14a38d0
Show file tree
Hide file tree
Showing 31 changed files with 4 additions and 3,627 deletions.
2 changes: 1 addition & 1 deletion Shoko.Commons
Expand Up @@ -527,8 +527,6 @@ public CL_Response SaveServerSettings(CL_ServerSettings contractIn)
ServerSettings.WebCache_TvDB_Send = contractIn.WebCache_TvDB_Send;
ServerSettings.WebCache_Trakt_Get = contractIn.WebCache_Trakt_Get;
ServerSettings.WebCache_Trakt_Send = contractIn.WebCache_Trakt_Send;
ServerSettings.WebCache_MAL_Get = contractIn.WebCache_MAL_Get;
ServerSettings.WebCache_MAL_Send = contractIn.WebCache_MAL_Send;
ServerSettings.WebCache_UserInfo = contractIn.WebCache_UserInfo;

// TvDB
Expand Down Expand Up @@ -578,13 +576,6 @@ public CL_Response SaveServerSettings(CL_ServerSettings contractIn)
ServerSettings.Trakt_UpdateFrequency = (ScheduledUpdateFrequency) contractIn.Trakt_UpdateFrequency;
ServerSettings.Trakt_SyncFrequency = (ScheduledUpdateFrequency) contractIn.Trakt_SyncFrequency;

// MAL
ServerSettings.MAL_AutoLink = contractIn.MAL_AutoLink;
ServerSettings.MAL_Username = contractIn.MAL_Username;
ServerSettings.MAL_Password = contractIn.MAL_Password;
ServerSettings.MAL_UpdateFrequency = (ScheduledUpdateFrequency) contractIn.MAL_UpdateFrequency;
ServerSettings.MAL_NeverDecreaseWatchedNums = contractIn.MAL_NeverDecreaseWatchedNums;

//Plex
ServerSettings.Plex_Server = contractIn.Plex_ServerHost;
ServerSettings.Plex_Libraries = contractIn.Plex_Sections.Length > 0
Expand Down
@@ -1,39 +1,19 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.ServiceModel;
using System.Threading;
using AniDBAPI;
using AniDBAPI.Commands;
using Shoko.Models;
using Shoko.Models.Azure;
using Shoko.Models.Server;
using Shoko.Commons.Extensions;
using Shoko.Models.Enums;
using Shoko.Models.Client;
using Shoko.Models.Interfaces;
using NLog;
using NutzCode.CloudFileSystem;
using Pri.LongPath;
using Shoko.Server.Commands;
using Shoko.Server.Commands.AniDB;
using Shoko.Server.Commands.MAL;
using Shoko.Server.Commands.TvDB;
using Shoko.Server.Databases;
using Shoko.Server.Models;
using Shoko.Server.Providers.Azure;
using Shoko.Server.Providers.MovieDB;
using Shoko.Server.Providers.MyAnimeList;
using Shoko.Server.Providers.TraktTV;
using Shoko.Server.Repositories;
using Shoko.Models.TvDB;
using Shoko.Server.Commands.Plex;
using Shoko.Server.Extensions;
using Shoko.Server.Repositories.NHibernate;
using Shoko.Server.Repositories.Cached;
using Shoko.Server.Providers.TraktTV.Contracts;
using Shoko.Server.Tasks;

namespace Shoko.Server
Expand Down
Expand Up @@ -9,19 +9,16 @@
using Shoko.Models.Server;
using Shoko.Models.TvDB;
using Shoko.Server.Commands;
using Shoko.Server.Commands.MAL;
using Shoko.Server.Commands.TvDB;
using Shoko.Server.Databases;
using Shoko.Server.Extensions;
using Shoko.Server.Models;
using Shoko.Server.Providers.Azure;
using Shoko.Server.Providers.MovieDB;
using Shoko.Server.Providers.MyAnimeList;
using Shoko.Server.Providers.TraktTV;
using Shoko.Server.Providers.TraktTV.Contracts;
using Shoko.Server.Providers.TvDB;
using Shoko.Server.Repositories;
using TvDbSharper.Dto;

namespace Shoko.Server
{
Expand Down Expand Up @@ -1197,139 +1194,6 @@ public CL_TraktDeviceCode GetTraktDeviceCode()

#endregion

#region MAL

public CL_CrossRef_AniDB_MAL_Response GetMALCrossRefWebCache(int animeID)
{
try
{
return AzureWebAPI.Get_CrossRefAniDBMAL(animeID);
}
catch (Exception ex)
{
logger.Error(ex, ex.ToString());
return null;
}
}

public List<CL_MALAnime_Response> SearchMAL(string criteria)
{
List<CL_MALAnime_Response> results = new List<CL_MALAnime_Response>();
try
{
anime malResults = MALHelper.SearchAnimesByTitle(criteria);

foreach (animeEntry res in malResults.entry)
results.Add(res.ToContract());

return results;
}
catch (Exception ex)
{
logger.Error(ex, ex.ToString());
return results;
}
}


public string LinkAniDBMAL(int animeID, int malID, string malTitle, int epType, int epNumber)
{
try
{
CrossRef_AniDB_MAL xrefTemp = RepoFactory.CrossRef_AniDB_MAL.GetByMALID(malID);
if (xrefTemp != null)
{
string animeName = string.Empty;
try
{
SVR_AniDB_Anime anime = RepoFactory.AniDB_Anime.GetByAnimeID(xrefTemp.AnimeID);
if (anime != null) animeName = anime.MainTitle;
}
catch
{
}
return
$"Not using MAL link as this MAL ID ({malID}) is already in use by {xrefTemp.AnimeID} ({animeName})";
}

MALHelper.LinkAniDBMAL(animeID, malID, malTitle, epType, epNumber, false);

return string.Empty;
}
catch (Exception ex)
{
logger.Error(ex, ex.ToString());
return ex.Message;
}
}

public string LinkAniDBMALUpdated(int animeID, int malID, string malTitle, int oldEpType, int oldEpNumber,
int newEpType, int newEpNumber)
{
try
{
CrossRef_AniDB_MAL xrefTemp = RepoFactory.CrossRef_AniDB_MAL
.GetByAnimeConstraint(animeID, oldEpType, oldEpNumber).FirstOrDefault(a => a.MALID == malID);
if (xrefTemp == null)
return $"Could not find MAL link ({animeID}/{oldEpType}/{oldEpNumber})";

RepoFactory.CrossRef_AniDB_MAL.Delete(xrefTemp);

return LinkAniDBMAL(animeID, malID, malTitle, newEpType, newEpNumber);
}
catch (Exception ex)
{
logger.Error(ex, ex.ToString());
return ex.Message;
}
}


public string RemoveLinkAniDBMAL(int animeID, int malID, int epType, int epNumber)
{
try
{
MALHelper.RemoveLinkAniDBMAL(animeID, malID, epType, epNumber);

return string.Empty;
}
catch (Exception ex)
{
logger.Error(ex, ex.ToString());
return ex.Message;
}
}

public string TestMALLogin()
{
try
{
if (MALHelper.VerifyCredentials())
return string.Empty;

return "Login is not valid";
}
catch (Exception ex)
{
logger.Error(ex, "Error in TestMALLogin: " + ex.ToString());
return ex.Message;
}
}

public void SyncMALUpload()
{
CommandRequest_MALUploadStatusToMAL cmd = new CommandRequest_MALUploadStatusToMAL();
cmd.Save();
}

public void SyncMALDownload()
{
CommandRequest_MALDownloadStatusFromMAL cmd = new CommandRequest_MALDownloadStatusFromMAL();
cmd.Save();
}

#endregion

#region Other Cross Refs

public CL_CrossRef_AniDB_Other_Response GetOtherAnimeCrossRefWebCache(int animeID, int crossRefType)
Expand Down
98 changes: 0 additions & 98 deletions Shoko.Server/API/v2/Modules/Core.cs
Expand Up @@ -9,24 +9,17 @@
using System.Threading;
using System.Threading.Tasks;
using AniDBAPI;
using FluentNHibernate.MappingModel;
using Nancy;
using Nancy.ModelBinding;
using Nancy.Security;
using NLog;
using Shoko.Commons.Extensions;
using Shoko.Commons.Utils;
using Shoko.Models.Client;
using Shoko.Models.Enums;
using Shoko.Models.Server;
using Shoko.Server.API.v2.Models.core;
using Shoko.Server.Commands;
using Shoko.Server.Commands.MAL;
using Shoko.Server.Extensions;
using Shoko.Server.Models;
using Shoko.Server.PlexAndKodi;
using Shoko.Server.Providers.MyAnimeList;
using Shoko.Server.Providers.TraktTV;
using Shoko.Server.Repositories;
using Shoko.Server.Utilities;

Expand Down Expand Up @@ -66,18 +59,6 @@ public Core() : base("/api")

#endregion

#region 03.MyAnimeList

Post["/mal/set", true] = async (x,ct) => await Task.Factory.StartNew(SetMAL, ct);
Get["/mal/get", true] = async (x,ct) => await Task.Factory.StartNew(GetMAL, ct);
Get["/mal/test", true] = async (x,ct) => await Task.Factory.StartNew(TestMAL, ct);
Get["/mal/update", true] = async (x,ct) => await Task.Factory.StartNew(ScanMAL, ct);
Get["/mal/download", true] = async (x,ct) => await Task.Factory.StartNew(DownloadFromMAL, ct);
Get["/mal/upload", true] = async (x,ct) => await Task.Factory.StartNew(UploadToMAL, ct);
//Get["/mal/votes/sync", true] = async (x,ct) => await Task.Factory.StartNew(SyncMALVotes, ct); <-- not implemented as CommandRequest

#endregion

#region 04.Trakt

Post["/trakt/set"] = x => APIStatus.NotImplemented();
Expand Down Expand Up @@ -506,85 +487,6 @@ private object UpdateMissingAniDBXML()

#endregion

#region 03.MyAnimeList

/// <summary>
/// Set MAL account with login, password
/// </summary>
/// <returns></returns>
private object SetMAL()
{
Credentials cred = this.Bind();
if (!String.IsNullOrEmpty(cred.login) && cred.login != string.Empty && !String.IsNullOrEmpty(cred.password) &&
cred.password != string.Empty)
{
ServerSettings.MAL_Username = cred.login;
ServerSettings.MAL_Password = cred.password;
return APIStatus.OK();
}

return new APIMessage(400, "Login and Password missing");
}

/// <summary>
/// Return current used MAL Creditentials
/// </summary>
/// <returns></returns>
private object GetMAL()
{
Credentials cred = new Credentials
{
login = ServerSettings.MAL_Username,
password = ServerSettings.MAL_Password
};
return cred;
}

/// <summary>
/// Test MAL Creditionals against MAL
/// </summary>
/// <returns></returns>
private object TestMAL()
{
return MALHelper.VerifyCredentials()
? APIStatus.OK()
: APIStatus.Unauthorized();
}

/// <summary>
/// Scan MAL
/// </summary>
/// <returns></returns>
private object ScanMAL()
{
Importer.RunImport_ScanMAL();
return APIStatus.OK();
}

/// <summary>
/// Download Watched States from MAL
/// </summary>
/// <returns></returns>
private object DownloadFromMAL()
{
CommandRequest_MALDownloadStatusFromMAL cmd = new CommandRequest_MALDownloadStatusFromMAL();
cmd.Save();
return APIStatus.OK();
}

/// <summary>
/// Upload Watched States to MAL
/// </summary>
/// <returns></returns>
private object UploadToMAL()
{
CommandRequest_MALUploadStatusToMAL cmd = new CommandRequest_MALUploadStatusToMAL();
cmd.Save();
return APIStatus.OK();
}

#endregion

#region 04.Trakt

/// <summary>
Expand Down
2 changes: 0 additions & 2 deletions Shoko.Server/Commands/AniDB/CommandRequest_AddFileToMyList.cs
@@ -1,12 +1,10 @@
using System;
using System.Collections.Generic;
using System.Xml;
using AniDBAPI;
using Shoko.Commons.Queue;
using Shoko.Models.Enums;
using Shoko.Models.Queue;
using Shoko.Models.Server;
using Shoko.Server.Commands.MAL;
using Shoko.Server.Extensions;
using Shoko.Server.Models;
using Shoko.Server.Repositories;
Expand Down
10 changes: 1 addition & 9 deletions Shoko.Server/Commands/AniDB/CommandRequest_VoteAnime.cs
Expand Up @@ -5,7 +5,6 @@
using Shoko.Models.Enums;
using Shoko.Models.Queue;
using Shoko.Models.Server;
using Shoko.Server.Commands.MAL;

namespace Shoko.Server.Commands
{
Expand Down Expand Up @@ -47,13 +46,6 @@ public override void ProcessCommand()
try
{
ShokoService.AnidbProcessor.VoteAnime(AnimeID, VoteValue, (AniDBVoteType) VoteType);

if (!string.IsNullOrEmpty(ServerSettings.MAL_Username) &&
!string.IsNullOrEmpty(ServerSettings.MAL_Password))
{
CommandRequest_MALUpdatedWatchedStatus cmdMAL = new CommandRequest_MALUpdatedWatchedStatus(AnimeID);
cmdMAL.Save();
}
}
catch (Exception ex)
{
Expand Down Expand Up @@ -112,4 +104,4 @@ public override CommandRequest ToDatabaseObject()
return cq;
}
}
}
}

0 comments on commit 14a38d0

Please sign in to comment.