mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-08 14:10:50 -07:00
fixed #25
This commit is contained in:
parent
35b1f2b257
commit
f5cb4d6879
5 changed files with 97 additions and 5 deletions
|
@ -238,9 +238,79 @@ namespace PlexRequests.Api.Models.Plex
|
||||||
public string Type { get; set; }
|
public string Type { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[XmlRoot(ElementName = "Directory")]
|
||||||
|
public class Directory1
|
||||||
|
{
|
||||||
|
[XmlElement(ElementName = "Genre")]
|
||||||
|
public List<Genre> Genre { get; set; }
|
||||||
|
[XmlElement(ElementName = "Role")]
|
||||||
|
public List<Role> Role { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "allowSync")]
|
||||||
|
public string AllowSync { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "librarySectionID")]
|
||||||
|
public string LibrarySectionID { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "librarySectionTitle")]
|
||||||
|
public string LibrarySectionTitle { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "librarySectionUUID")]
|
||||||
|
public string LibrarySectionUUID { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "personal")]
|
||||||
|
public string Personal { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "sourceTitle")]
|
||||||
|
public string SourceTitle { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "ratingKey")]
|
||||||
|
public string RatingKey { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "key")]
|
||||||
|
public string Key { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "studio")]
|
||||||
|
public string Studio { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "type")]
|
||||||
|
public string Type { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "title")]
|
||||||
|
public string Title { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "contentRating")]
|
||||||
|
public string ContentRating { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "summary")]
|
||||||
|
public string Summary { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "index")]
|
||||||
|
public string Index { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "rating")]
|
||||||
|
public string Rating { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "viewCount")]
|
||||||
|
public string ViewCount { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "lastViewedAt")]
|
||||||
|
public string LastViewedAt { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "year")]
|
||||||
|
public string Year { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "thumb")]
|
||||||
|
public string Thumb { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "art")]
|
||||||
|
public string Art { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "banner")]
|
||||||
|
public string Banner { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "theme")]
|
||||||
|
public string Theme { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "duration")]
|
||||||
|
public string Duration { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "originallyAvailableAt")]
|
||||||
|
public string OriginallyAvailableAt { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "leafCount")]
|
||||||
|
public string LeafCount { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "viewedLeafCount")]
|
||||||
|
public string ViewedLeafCount { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "childCount")]
|
||||||
|
public string ChildCount { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "addedAt")]
|
||||||
|
public string AddedAt { get; set; }
|
||||||
|
[XmlAttribute(AttributeName = "updatedAt")]
|
||||||
|
public string UpdatedAt { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
[XmlRoot(ElementName = "MediaContainer")]
|
[XmlRoot(ElementName = "MediaContainer")]
|
||||||
public class PlexSearch
|
public class PlexSearch
|
||||||
{
|
{
|
||||||
|
[XmlElement(ElementName = "Directory")]
|
||||||
|
public Directory1 Directory { get; set; }
|
||||||
[XmlElement(ElementName = "Video")]
|
[XmlElement(ElementName = "Video")]
|
||||||
public List<Video> Video { get; set; }
|
public List<Video> Video { get; set; }
|
||||||
[XmlElement(ElementName = "Provider")]
|
[XmlElement(ElementName = "Provider")]
|
||||||
|
|
|
@ -98,13 +98,13 @@ namespace PlexRequests.Api
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
var json = JsonConvert.DeserializeObject<T>(response.Content);
|
var json = JsonConvert.DeserializeObject<T>(response.Content);
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.Fatal(e);
|
Log.Fatal(e);
|
||||||
|
Log.Info(response.Content);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,6 +79,27 @@ namespace PlexRequests.Services.Tests
|
||||||
Assert.That(result, Is.True);
|
Assert.That(result, Is.True);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IsAvailableDirectoryTitleTest()
|
||||||
|
{
|
||||||
|
var settingsMock = new Mock<ISettingsService<PlexSettings>>();
|
||||||
|
var authMock = new Mock<ISettingsService<AuthenticationSettings>>();
|
||||||
|
var requestMock = new Mock<IRequestService>();
|
||||||
|
var plexMock = new Mock<IPlexApi>();
|
||||||
|
|
||||||
|
var searchResult = new PlexSearch { Directory = new Directory1 {Title = "title"} };
|
||||||
|
|
||||||
|
settingsMock.Setup(x => x.GetSettings()).Returns(new PlexSettings { Ip = "abc" });
|
||||||
|
authMock.Setup(x => x.GetSettings()).Returns(new AuthenticationSettings { PlexAuthToken = "abc" });
|
||||||
|
plexMock.Setup(x => x.SearchContent(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<Uri>())).Returns(searchResult);
|
||||||
|
|
||||||
|
Checker = new PlexAvailabilityChecker(settingsMock.Object, authMock.Object, requestMock.Object, plexMock.Object);
|
||||||
|
|
||||||
|
var result = Checker.IsAvailable("title");
|
||||||
|
|
||||||
|
Assert.That(result, Is.True);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void IsNotAvailableTest()
|
public void IsNotAvailableTest()
|
||||||
{
|
{
|
||||||
|
|
|
@ -98,8 +98,9 @@ namespace PlexRequests.Services
|
||||||
}
|
}
|
||||||
|
|
||||||
var results = PlexApi.SearchContent(authSettings.PlexAuthToken, title, plexSettings.FullUri);
|
var results = PlexApi.SearchContent(authSettings.PlexAuthToken, title, plexSettings.FullUri);
|
||||||
var result = results.Video.FirstOrDefault(x => x.Title == title);
|
var result = results.Video?.FirstOrDefault(x => x.Title == title);
|
||||||
return result?.Title != null;
|
var directoryTitle = results.Directory?.Title == title;
|
||||||
|
return result?.Title != null || directoryTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ValidateSettings(PlexSettings plex, AuthenticationSettings auth, IEnumerable<RequestedModel> requests)
|
private bool ValidateSettings(PlexSettings plex, AuthenticationSettings auth, IEnumerable<RequestedModel> requests)
|
||||||
|
|
|
@ -267,12 +267,12 @@ namespace PlexRequests.UI.Modules
|
||||||
|
|
||||||
var showInfo = tvApi.GetInformation(showId, token).data;
|
var showInfo = tvApi.GetInformation(showId, token).data;
|
||||||
|
|
||||||
#if !DEBUG
|
//#if !DEBUG
|
||||||
if (CheckIfTitleExistsInPlex(showInfo.seriesName))
|
if (CheckIfTitleExistsInPlex(showInfo.seriesName))
|
||||||
{
|
{
|
||||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = $"{showInfo.seriesName} is already in Plex!" });
|
return Response.AsJson(new JsonResponseModel { Result = false, Message = $"{showInfo.seriesName} is already in Plex!" });
|
||||||
}
|
}
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
DateTime firstAir;
|
DateTime firstAir;
|
||||||
DateTime.TryParse(showInfo.firstAired, out firstAir);
|
DateTime.TryParse(showInfo.firstAired, out firstAir);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue