Skip to content
This repository was archived by the owner on Mar 30, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ obj/
*.suo
*.pubxml
packages/*/
MalApi/package/
MalApi/package/
.vs/
14 changes: 10 additions & 4 deletions MalApi.Example/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace MalApi.Example
{
Expand All @@ -24,7 +22,15 @@ static void Main(string[] args)
api.UserAgent = "MalApiExample";
api.TimeoutInMs = 15000;

MalUserLookupResults userLookup = api.GetAnimeListForUser("LordHighCaptain");
var animeUpdateInfo = new UpdateAnimeObject(episode: "26", status: "2", score: "9");
string userLookup2 = api.UpdateAnimeForUser(1, animeUpdateInfo, "user", "pass");

var mangaUpdateInfo = new UpdateMangaObject(chapter: "20", volume: "3", score: "8");
string userLookup3 = api.UpdateMangaForUser(952, mangaUpdateInfo, "user", "pass");



MalUserLookupResults userLookup = api.GetAnimeListForUser("user");
foreach (MyAnimeListEntry listEntry in userLookup.AnimeList)
{
Console.WriteLine("Rating for {0}: {1}", listEntry.AnimeInfo.Title, listEntry.Score);
Expand Down
5 changes: 1 addition & 4 deletions MalApi.IntegrationTests/GetAnimeDetailsTest.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using FluentAssertions;
Expand Down
7 changes: 1 addition & 6 deletions MalApi.IntegrationTests/GetAnimeListForUserTest.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MalApi;
using System.Threading.Tasks;
using System.Threading.Tasks;
using Xunit;
using System.Threading;

Expand Down
6 changes: 1 addition & 5 deletions MalApi.IntegrationTests/GetRecentOnlineUsersTest.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading;
using System.Threading.Tasks;
using Xunit;

Expand Down
3 changes: 1 addition & 2 deletions MalApi.NetCoreExample/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using MalApi;
using System;
using System;

namespace MalApi.NetCoreExample
{
Expand Down
4 changes: 0 additions & 4 deletions MalApi.UnitTests/AnimeListCacheTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MalApi;
using System.Threading;
using Xunit;

namespace MalApi.UnitTests
Expand Down
6 changes: 1 addition & 5 deletions MalApi.UnitTests/Helpers.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.IO;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace MalApi.UnitTests
{
Expand Down
11 changes: 5 additions & 6 deletions MalApi.UnitTests/MalAppInfoXmlTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml.Linq;
using FluentAssertions;
Expand All @@ -25,7 +24,7 @@ public void ParseWithTextReaderTest()
public void ParseWithXElementTest()
{
XDocument doc = XDocument.Parse(Helpers.GetResourceText("test_clean.xml"));
MalUserLookupResults results = MalAppInfoXml.Parse(doc);
MalUserLookupResults results = MalAppInfoXml.ParseAnimeResults(doc);
DoAsserts(results);
}

Expand All @@ -42,7 +41,7 @@ public void ParseInvalidUserWithTextReaderTest()
public void ParseInvalidUserWithXElementTest()
{
XDocument doc = XDocument.Parse(Helpers.GetResourceText("test_no_such_user.xml"));
Assert.Throws<MalUserNotFoundException>(() => MalAppInfoXml.Parse(doc));
Assert.Throws<MalUserNotFoundException>(() => MalAppInfoXml.ParseAnimeResults(doc));
}

[Fact]
Expand All @@ -58,7 +57,7 @@ public void ParseOldInvalidUserWithTextReaderTest()
public void ParseOldInvalidUserWithXElementTest()
{
XDocument doc = XDocument.Parse(Helpers.GetResourceText("test_no_such_user_old.xml"));
Assert.Throws<MalUserNotFoundException>(() => MalAppInfoXml.Parse(doc));
Assert.Throws<MalUserNotFoundException>(() => MalAppInfoXml.ParseAnimeResults(doc));
}

private void DoAsserts(MalUserLookupResults results)
Expand All @@ -74,7 +73,7 @@ private void DoAsserts(MalUserLookupResults results)

Assert.Equal(7, entry.NumEpisodesWatched);
Assert.Equal(7, entry.Score);
Assert.Equal(CompletionStatus.Watching, entry.Status);
Assert.Equal(AnimeCompletionStatus.Watching, entry.Status);

// Test tags with Equal, not equivalent, because order in tags matters
Assert.Equal(new List<string>() { "duck", "goose" }, entry.Tags);
Expand All @@ -85,7 +84,7 @@ private void DoAsserts(MalUserLookupResults results)
entry.AnimeInfo.Synonyms.Should().BeEquivalentTo(new List<string>() { "The Vanishment of Haruhi Suzumiya", "Suzumiya Haruhi no Syoshitsu", "Haruhi movie", "The Disappearance of Haruhi Suzumiya" });
Assert.Equal((decimal?)null, entry.Score);
Assert.Equal(0, entry.NumEpisodesWatched);
Assert.Equal(CompletionStatus.PlanToWatch, entry.Status);
Assert.Equal(AnimeCompletionStatus.PlanToWatch, entry.Status);
Assert.Equal(new List<string>(), entry.Tags);

entry = results.AnimeList.Where(anime => anime.AnimeInfo.AnimeId == 889).First();
Expand Down
6 changes: 1 addition & 5 deletions MalApi.UnitTests/MyAnimeListApiTests.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Collections.Generic;
using System.IO;
using FluentAssertions;
using Xunit;
Expand Down
4 changes: 2 additions & 2 deletions MalApi.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26430.14
VisualStudioVersion = 15.0.26430.15
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MalApi", "MalApi\MalApi.csproj", "{85BC477F-4798-4006-A342-715E7565B3BB}"
EndProject
Expand All @@ -18,7 +18,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{00247D
.nuget\NuGet.targets = .nuget\NuGet.targets
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MalApi.NetCoreExample", "MalApi.NetCoreExample\MalApi.NetCoreExample.csproj", "{EF72FAC1-AE34-4D7B-9839-4ED50288CFB4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MalApi.NetCoreExample", "MalApi.NetCoreExample\MalApi.NetCoreExample.csproj", "{EF72FAC1-AE34-4D7B-9839-4ED50288CFB4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MalApi
namespace MalApi
{
public enum CompletionStatus
public enum AnimeCompletionStatus
{
Watching = 1,
Completed = 2,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MalApi
{
Expand All @@ -16,7 +14,7 @@ public class MalAnimeInfoFromUserLookup : IEquatable<MalAnimeInfoFromUserLookup>
public MalAnimeType Type { get; private set; }

public ICollection<string> Synonyms { get; private set; }
public MalSeriesStatus Status { get; private set; }
public MalAnimeSeriesStatus Status { get; private set; }

/// <summary>
/// Could be 0 for anime that hasn't aired yet or less than the planned number of episodes for a series currently airing.
Expand All @@ -27,7 +25,7 @@ public class MalAnimeInfoFromUserLookup : IEquatable<MalAnimeInfoFromUserLookup>
public UncertainDate EndDate { get; private set; }
public string ImageUrl { get; private set; }

public MalAnimeInfoFromUserLookup(int animeId, string title, MalAnimeType type, ICollection<string> synonyms, MalSeriesStatus status,
public MalAnimeInfoFromUserLookup(int animeId, string title, MalAnimeType type, ICollection<string> synonyms, MalAnimeSeriesStatus status,
int numEpisodes, UncertainDate startDate, UncertainDate endDate, string imageUrl)
{
AnimeId = animeId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MalApi
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MalApi
namespace MalApi
{
public enum MalSeriesStatus
public enum MalAnimeSeriesStatus
{
Airing = 1,
FinishedAiring = 2,
Expand Down
7 changes: 1 addition & 6 deletions MalApi/MalAnimeType.cs → MalApi/Anime/MalAnimeType.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MalApi
namespace MalApi
{
public enum MalAnimeType
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MalApi
{
public class MyAnimeListEntry : IEquatable<MyAnimeListEntry>
{
public decimal? Score { get; private set; }
public CompletionStatus Status { get; private set; }
public AnimeCompletionStatus Status { get; private set; }
public int NumEpisodesWatched { get; private set; }
public UncertainDate MyStartDate { get; private set; }
public UncertainDate MyFinishDate { get; private set; }
public DateTime MyLastUpdate { get; private set; }
public MalAnimeInfoFromUserLookup AnimeInfo { get; private set; }
public ICollection<string> Tags { get; private set; }

public MyAnimeListEntry(decimal? score, CompletionStatus status, int numEpisodesWatched, UncertainDate myStartDate,
public MyAnimeListEntry(decimal? score, AnimeCompletionStatus status, int numEpisodesWatched, UncertainDate myStartDate,
UncertainDate myFinishDate, DateTime myLastUpdate, MalAnimeInfoFromUserLookup animeInfo, ICollection<string> tags)
{
Score = score;
Expand Down
85 changes: 85 additions & 0 deletions MalApi/Anime/UpdateAnimeObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using System.Xml.Serialization;

namespace MalApi
{
[XmlRoot("entry")]
public class UpdateAnimeObject : UpdateObjectBase
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Object" is kind of generic. "AnimeUpdate" would describe the purpose as well.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The properties in this class are all strings. The users of the library should be dealing with integers for episode count, AnimeCompletionStatus for status, etc, instead of expecting them to serialize those properties to strings.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does it mean if a property is not set? Does it not get updated or does it get set to an empty value in MAL? This should be documented in a doc comment on the class.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be nice to link to the MAL documentation at https://myanimelist.net/modules.php?go=api#animevalues in a comment.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with all your comments.

{
[XmlElement("episode")]
public string Episode { get; set; } = null;

[XmlElement("status")]
public string Status { get; set; } = null;

[XmlElement("score")]
public string Score { get; set; } = null;

[XmlElement("storage_type")]
public string StorageType { get; set; } = null;

[XmlElement("storage_value")]
public string StorageValue { get; set; } = null;

[XmlElement("times_rewatched")]
public string TimesRewatched { get; set; } = null;

[XmlElement("rewatch_value")]
public string RewatchValue { get; set; } = null;

[XmlElement("date_start")]
public string DateStart { get; set; } = null;

[XmlElement("date_finish")]
public string DateFinish { get; set; } = null;

[XmlElement("priority")]
public string Priority { get; set; } = null;

[XmlElement("enable_discussion")]
public string EnableDiscussion { get; set; } = null;

[XmlElement("enable_rewatching")]
public string EnableRewatching { get; set; } = null;

[XmlElement("comments")]
public string Comments { get; set; } = null;

[XmlElement("tags")]
public string Tags { get; set; } = null;

private UpdateAnimeObject()
{
}

public UpdateAnimeObject(string episode = null,
string status = null,
string score = null,
string storageType = null,
string storageValue = null,
string timesRewatched = null,
string rewatchValue = null,
string dateStart = null,
string dateFinish = null,
string priority = null,
string enableDiscussion = null,
string enableRewatching = null,
string comments = null,
string tags = null)
{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this constructor adding any value over calling the default constructor and then setting properties?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really... I'll remove it.

Episode = episode;
Status = status;
Score = score;
StorageType = storageType;
StorageValue = storageValue;
TimesRewatched = timesRewatched;
RewatchValue = rewatchValue;
DateStart = dateStart;
DateFinish = dateFinish;
Priority = priority;
EnableDiscussion = enableDiscussion;
EnableRewatching = enableRewatching;
Comments = comments;
Tags = tags;
}
}
}
5 changes: 1 addition & 4 deletions MalApi/AnimeDetailsResults.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Generic;

namespace MalApi
{
Expand Down
2 changes: 0 additions & 2 deletions MalApi/AnimeListCache.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace MalApi
Expand Down
3 changes: 0 additions & 3 deletions MalApi/CachingMyAnimeListApi.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

Expand Down
3 changes: 0 additions & 3 deletions MalApi/Genre.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MalApi
{
Expand Down
3 changes: 0 additions & 3 deletions MalApi/IMyAnimeListApi.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

Expand Down
Loading