Skip to content

Commit

Permalink
Merge pull request #2 from tidusjar/develop
Browse files Browse the repository at this point in the history
Getting Develop up to date
  • Loading branch information
anojht authored Mar 29, 2018
2 parents b2ecc24 + 9bd545c commit 8a94f96
Show file tree
Hide file tree
Showing 76 changed files with 698 additions and 261 deletions.
60 changes: 59 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,79 @@

### **New Features**

- Added the Recently Added Newsletter! You are welcome. [tidusjar]

- Added a new scrollbar to Ombi. [tidusjar]

- Added the ability to automatically generate the API Key on startup if it does not exist #2070. [tidusjar]

- Updated npm dependancies. [Jamie]

- Update README.md. [Jamie]

- Update README.md. [Jamie]

- Update ISSUE_TEMPLATE.md. [Jamie]

- Update appveyor.yml. [Jamie]

- Added recently added stuff. [Jamie]

- Added the recently added engine with some basic methods. [Jamie]

- Added the ability to refresh out backend metadata (#2078) [Jamie]

### **Fixes**

- Fixed #2074 and #2079. [Jamie]
- Specific favicons for different platforms. [louis-lau]

- MovieDbId was switched to string fron number so accomodated for change. [Anojh]

- Removing duplicate functions. [Anojh Thayaparan]

- Conflict resolving and adopting Jamie's new method. [Anojh]

- Wrote new calls to just get poster and bg. [Anojh]

- Fix for issue #1907, which is to add content poster and bg to issue details page. [Anojh]

- Dynamic Background Animation. [Anojh]

- Improved the message for #2037. [tidusjar]

- Improved the way we use the notification variables, we have now split out the Username and Alias (Requested User is depricated but not removed) [tidusjar]

- Removed redundant timers. [Anojh]

- More optimizations by reducing requests. [Anojh]

- Improved version. [Anojh]

- Dynamic Background Animation. [Anojh]

- Fixed #2055 and #1903. [Jamie]

- Small changes to the auto updater, let's see how this works. [Jamie]

- Fixed build. [Jamie]

- Fixed the update check for the master build. [Jamie]

- Fixed build. [Jamie]

- Fixed #2074 and #2079. [Jamie]


## v3.0.3030 (2018-03-14)

### **New Features**

- Updated the .Net core dependancies #2072. [Jamie]

### **Fixes**

- Delete Ombi.testdb. [Jamie]


## v3.0.3020 (2018-03-13)

Expand Down
3 changes: 2 additions & 1 deletion src/Ombi.Core/Engine/Interfaces/ITvRequestEngine.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Ombi.Core.Models.Requests;
using Ombi.Core.Models.Search;
using Ombi.Store.Entities.Requests;

Expand All @@ -9,7 +10,7 @@ public interface ITvRequestEngine : IRequestEngine<TvRequests>
{

Task RemoveTvRequest(int requestId);
Task<RequestEngineResult> RequestTvShow(SearchTvShowViewModel tv);
Task<RequestEngineResult> RequestTvShow(TvRequestViewModel tv);
Task<RequestEngineResult> DenyChildRequest(int requestId);
Task<IEnumerable<TvRequests>> SearchTvRequest(string search);
Task<IEnumerable<TreeNode<TvRequests, List<ChildRequests>>>> SearchTvRequestTree(string search);
Expand Down
2 changes: 1 addition & 1 deletion src/Ombi.Core/Engine/MovieRequestEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public async Task<RequestEngineResult> RequestMovie(MovieRequestViewModel model)
{
Result = false,
Message = "There was an issue adding this movie!",
ErrorMessage = $"TheMovieDb didn't have any information for ID {model.TheMovieDbId}"
ErrorMessage = $"Please try again later"
};
}
var fullMovieName =
Expand Down
10 changes: 5 additions & 5 deletions src/Ombi.Core/Engine/TvRequestEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public TvRequestEngine(ITvMazeApi tvApi, IRequestServiceMain requestService, IPr
private IAuditRepository Audit { get; }
private readonly IRepository<RequestLog> _requestLog;

public async Task<RequestEngineResult> RequestTvShow(SearchTvShowViewModel tv)
public async Task<RequestEngineResult> RequestTvShow(TvRequestViewModel tv)
{
var user = await GetUser();

var tvBuilder = new TvShowRequestBuilder(TvApi);
(await tvBuilder
.GetShowInfo(tv.Id))
.GetShowInfo(tv.TvDbId))
.CreateTvList(tv)
.CreateChild(tv, user.Id);

Expand Down Expand Up @@ -78,9 +78,9 @@ public async Task<RequestEngineResult> RequestTvShow(SearchTvShowViewModel tv)
}
}

await Audit.Record(AuditType.Added, AuditArea.TvRequest, $"Added Request {tv.Title}", Username);
await Audit.Record(AuditType.Added, AuditArea.TvRequest, $"Added Request {tvBuilder.ChildRequest.Title}", Username);

var existingRequest = await TvRepository.Get().FirstOrDefaultAsync(x => x.TvDbId == tv.Id);
var existingRequest = await TvRepository.Get().FirstOrDefaultAsync(x => x.TvDbId == tv.TvDbId);
if (existingRequest != null)
{
// Remove requests we already have, we just want new ones
Expand Down Expand Up @@ -127,7 +127,7 @@ public async Task<RequestEngineResult> RequestTvShow(SearchTvShowViewModel tv)
var newRequest = tvBuilder.CreateNewRequest(tv);
return await AddRequest(newRequest.NewRequest);
}

public async Task<IEnumerable<TvRequests>> GetRequests(int count, int position)
{
var shouldHide = await HideFromOtherUsers();
Expand Down
80 changes: 57 additions & 23 deletions src/Ombi.Core/Helpers/TvShowRequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Threading.Tasks;
using Ombi.Api.TvMaze;
using Ombi.Api.TvMaze.Models;
using Ombi.Core.Models.Requests;
using Ombi.Core.Models.Search;
using Ombi.Helpers;
using Ombi.Store.Entities;
Expand All @@ -23,7 +24,7 @@ public TvShowRequestBuilder(ITvMazeApi tvApi)
private ITvMazeApi TvApi { get; }

public ChildRequests ChildRequest { get; set; }
public List<SeasonRequests> TvRequests { get; protected set; }
public List<SeasonsViewModel> TvRequests { get; protected set; }
public string PosterPath { get; protected set; }
public DateTime FirstAir { get; protected set; }
public TvRequests NewRequest { get; protected set; }
Expand All @@ -33,7 +34,7 @@ public async Task<TvShowRequestBuilder> GetShowInfo(int id)
{
ShowInfo = await TvApi.ShowLookupByTheTvDbId(id);

DateTime.TryParse(ShowInfo.premiered, out DateTime dt);
DateTime.TryParse(ShowInfo.premiered, out var dt);

FirstAir = dt;

Expand All @@ -43,49 +44,40 @@ public async Task<TvShowRequestBuilder> GetShowInfo(int id)
return this;
}

public TvShowRequestBuilder CreateChild(SearchTvShowViewModel model, string userId)
public TvShowRequestBuilder CreateChild(TvRequestViewModel model, string userId)
{
ChildRequest = new ChildRequests
{
Id = model.Id,
Id = model.TvDbId,
RequestType = RequestType.TvShow,
RequestedDate = DateTime.UtcNow,
Approved = false,
RequestedUserId = userId,
SeasonRequests = new List<SeasonRequests>(),
Title = model.Title,
Title = ShowInfo.name,
SeriesType = ShowInfo.type.Equals("Animation", StringComparison.CurrentCultureIgnoreCase) ? SeriesType.Anime : SeriesType.Standard
};

return this;
}

public TvShowRequestBuilder CreateTvList(SearchTvShowViewModel tv)
public TvShowRequestBuilder CreateTvList(TvRequestViewModel tv)
{
TvRequests = new List<SeasonRequests>();
TvRequests = new List<SeasonsViewModel>();
// Only have the TV requests we actually requested and not everything
foreach (var season in tv.SeasonRequests)
foreach (var season in tv.Seasons)
{
for (int i = season.Episodes.Count - 1; i >= 0; i--)
{
if (!season.Episodes[i].Requested)
{
season.Episodes.RemoveAt(i); // Remove the episode since it's not requested
}
}

if (season.Episodes.Any())
{
TvRequests.Add(season);
}
}

return this;

}


public async Task<TvShowRequestBuilder> BuildEpisodes(SearchTvShowViewModel tv)
public async Task<TvShowRequestBuilder> BuildEpisodes(TvRequestViewModel tv)
{
if (tv.RequestAll)
{
Expand Down Expand Up @@ -173,26 +165,68 @@ public async Task<TvShowRequestBuilder> BuildEpisodes(SearchTvShowViewModel tv)
else
{
// It's a custom request
ChildRequest.SeasonRequests = TvRequests;
var seasonRequests = new List<SeasonRequests>();
var episodes = await TvApi.EpisodeLookup(ShowInfo.id);
foreach (var ep in episodes)
{
var existingSeasonRequest = seasonRequests.FirstOrDefault(x => x.SeasonNumber == ep.season);
if (existingSeasonRequest != null)
{
var requestedSeason = tv.Seasons.FirstOrDefault(x => x.SeasonNumber == ep.season);
var requestedEpisode = requestedSeason?.Episodes?.Any(x => x.EpisodeNumber == ep.number) ?? false;
if (requestedSeason != null && requestedEpisode)
{
// We already have this, let's just add the episodes to it
existingSeasonRequest.Episodes.Add(new EpisodeRequests
{
EpisodeNumber = ep.number,
AirDate = FormatDate(ep.airdate),
Title = ep.name,
Url = ep.url,
});
}
}
else
{
var newRequest = new SeasonRequests {SeasonNumber = ep.season};
var requestedSeason = tv.Seasons.FirstOrDefault(x => x.SeasonNumber == ep.season);
var requestedEpisode = requestedSeason?.Episodes?.Any(x => x.EpisodeNumber == ep.number) ?? false;
if (requestedSeason != null && requestedEpisode)
{
newRequest.Episodes.Add(new EpisodeRequests
{
EpisodeNumber = ep.number,
AirDate = FormatDate(ep.airdate),
Title = ep.name,
Url = ep.url,
});
seasonRequests.Add(newRequest);
}
}
}

foreach (var s in seasonRequests)
{
ChildRequest.SeasonRequests.Add(s);
}
}
return this;
}


public TvShowRequestBuilder CreateNewRequest(SearchTvShowViewModel tv)
public TvShowRequestBuilder CreateNewRequest(TvRequestViewModel tv)
{
NewRequest = new TvRequests
{
Id = tv.Id,
Overview = ShowInfo.summary.RemoveHtml(),
PosterPath = PosterPath,
Title = ShowInfo.name,
ReleaseDate = FirstAir,
Status = ShowInfo.status,
ImdbId = ShowInfo.externals?.imdb ?? string.Empty,
TvDbId = tv.Id,
TvDbId = tv.TvDbId,
ChildRequests = new List<ChildRequests>(),
TotalSeasons = tv.SeasonRequests.Count()
TotalSeasons = tv.Seasons.Count()
};
NewRequest.ChildRequests.Add(ChildRequest);

Expand Down
25 changes: 25 additions & 0 deletions src/Ombi.Core/Models/Requests/TvRequestViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Collections.Generic;

namespace Ombi.Core.Models.Requests
{
public class TvRequestViewModel
{
public bool RequestAll { get; set; }
public bool LatestSeason { get; set; }
public bool FirstSeason { get; set; }
public int TvDbId { get; set; }
public List<SeasonsViewModel> Seasons { get; set; } = new List<SeasonsViewModel>();
}

public class SeasonsViewModel
{
public int SeasonNumber { get; set; }
public List<EpisodesViewModel> Episodes { get; set; } = new List<EpisodesViewModel>();
}

public class EpisodesViewModel
{
public int EpisodeNumber { get; set; }
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
<td style="font-family: sans-serif; font-size: 14px; vertical-align: top;" valign="top">
<br />
<br />
<p style="font-family: sans-serif; font-size: 20px; font-weight: normal; margin: 0; Margin-bottom: 15px;">Here is a list of Movies and TV Shows that have recently been added!</p>
<p style="font-family: sans-serif; font-size: 20px; font-weight: normal; margin: 0; Margin-bottom: 15px;">{@INTRO}</p>

</td>
</tr>
Expand Down
Loading

0 comments on commit 8a94f96

Please sign in to comment.