Skip to content

Commit

Permalink
Merge pull request mregni#2 from mregni/master
Browse files Browse the repository at this point in the history
Fixed broken movie links
  • Loading branch information
hackthis02 authored Aug 13, 2020
2 parents b8bf086 + c3c3a18 commit dcc93f7
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 109 deletions.
1 change: 0 additions & 1 deletion Api/TheTvDbProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Linq;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
using MediaBrowser.Model.IO;
Expand Down
6 changes: 1 addition & 5 deletions Api/UpdateModel.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.Tasks;
using System.Collections.Generic;

namespace Statistics.Api
{
Expand Down
5 changes: 0 additions & 5 deletions Calculators/Calculator.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Entities;
Expand Down
6 changes: 0 additions & 6 deletions Calculators/ShowProgressCalculator.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.ApiClient;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Querying;
using statistics.Models.Configuration;
using Statistics.Api;
using statistics.Calculators;
using MediaBrowser.Model.Logging;

namespace Statistics.Helpers
{
Expand Down
1 change: 1 addition & 0 deletions Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public PluginConfiguration()

public string LastUpdated { get; set; }
public string Version { get; set; }
public string ServerId { get; set; }

public List<MovieQuality> MovieQualityItems { get; set; }

Expand Down
32 changes: 16 additions & 16 deletions Configuration/configPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ <h2>Show Statistics</h2>

return html;
},
createStatWithPoster: function (v) {
createStatWithPoster: function (v, i) {
var html = '<div class="col ' +
v.Size +
'"><div class="statCard"><div class="statCard-content">';
Expand All @@ -264,7 +264,7 @@ <h2>Show Statistics</h2>
"');\"><i class=\"md-icon\">info_outline</i></div>";

if (v.Id !== undefined) {
html += '<a href=/web/itemdetails.html?id=' + v.Id + '><img src="/Items/' + v.Id + '/Images/Primary" height="105px"></a>'
html += '<a is="emby-linkbutton" href="/item?id=' + v.Id + '&serverId=' + i + '"><img src="/Items/' + v.Id + '/Images/Primary" height="105px"></a>'
html += '<div>'
}

Expand Down Expand Up @@ -306,25 +306,25 @@ <h2>Show Statistics</h2>
$("#movieStat", page).append(MainPage.createStat(config.TotalMovies));
$("#movieStat", page).append(MainPage.createStat(config.TotalBoxsets));
$("#movieStat", page).append(MainPage.createStat(config.TotalMovieStudios));
$("#movieStat", page).append(MainPage.createStatWithPoster(config.BiggestMovie));
$("#movieStat", page).append(MainPage.createStatWithPoster(config.LongestMovie));
$("#movieStat", page).append(MainPage.createStatWithPoster(config.NewestAddedMovie));
$("#movieStat", page).append(MainPage.createStatWithPoster(config.OldestMovie));
$("#movieStat", page).append(MainPage.createStatWithPoster(config.NewestMovie));
$("#movieStat", page).append(MainPage.createStatWithPoster(config.HighestRating));
$("#movieStat", page).append(MainPage.createStatWithPoster(config.LowestRating));
$("#movieStat", page).append(MainPage.createStatWithPoster(config.HighestBitrateMovie));
$("#movieStat", page).append(MainPage.createStatWithPoster(config.LowestBitrateMovie));
$("#movieStat", page).append(MainPage.createStatWithPoster(config.BiggestMovie, config.ServerId));
$("#movieStat", page).append(MainPage.createStatWithPoster(config.LongestMovie, config.ServerId));
$("#movieStat", page).append(MainPage.createStatWithPoster(config.NewestAddedMovie, config.ServerId));
$("#movieStat", page).append(MainPage.createStatWithPoster(config.OldestMovie, config.ServerId));
$("#movieStat", page).append(MainPage.createStatWithPoster(config.NewestMovie, config.ServerId));
$("#movieStat", page).append(MainPage.createStatWithPoster(config.HighestRating, config.ServerId));
$("#movieStat", page).append(MainPage.createStatWithPoster(config.LowestRating, config.ServerId));
$("#movieStat", page).append(MainPage.createStatWithPoster(config.HighestBitrateMovie, config.ServerId));
$("#movieStat", page).append(MainPage.createStatWithPoster(config.LowestBitrateMovie, config.ServerId));


$("#showStat", page).append(MainPage.createStat(config.TotalShows));
$("#showStat", page).append(MainPage.createStat(config.TotalOwnedEpisodes));
$("#showStat", page).append(MainPage.createStat(config.TotalShowStudios));
$("#showStat", page).append(MainPage.createStatWithPoster(config.BiggestShow));
$("#showStat", page).append(MainPage.createStatWithPoster(config.LongestShow));
$("#showStat", page).append(MainPage.createStatWithPoster(config.OldestShow));
$("#showStat", page).append(MainPage.createStatWithPoster(config.NewestShow));
$("#showStat", page).append(MainPage.createStatWithPoster(config.NewestAddedEpisode));
$("#showStat", page).append(MainPage.createStatWithPoster(config.BiggestShow, config.ServerId));
$("#showStat", page).append(MainPage.createStatWithPoster(config.LongestShow, config.ServerId));
$("#showStat", page).append(MainPage.createStatWithPoster(config.OldestShow, config.ServerId));
$("#showStat", page).append(MainPage.createStatWithPoster(config.NewestShow, config.ServerId));
$("#showStat", page).append(MainPage.createStatWithPoster(config.NewestAddedEpisode, config.ServerId));

Dashboard.hideLoadingMsg();
}
Expand Down
45 changes: 17 additions & 28 deletions Configuration/moviePage.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ <h1>Movie list</h1>
<button is="emby-button" type="button" class="raised button-cancel block emby-button" onclick="Emby.Page.back();">Go back</button>
</div>

<h2 id="unkTitle">Unknown</h2>
<h2 id="unkTitle"></h2>
<div id="unk"></div>
<h2 id="dvdTitle">DVD</h2>
<h2 id="dvdTitle"></h2>
<div id="dvd"></div>
<h2 id="Q700Title">480P</h2>
<h2 id="Q700Title"></h2>
<div id="Q700"></div>
<h2 id="Q1260Title">720P</h2>
<h2 id="Q1260Title"></h2>
<div id="Q1260"></div>
<h2 id="Q1900Title">1080P</h2>
<h2 id="Q1900Title"></h2>
<div id="Q1900"></div>
<h2 id="Q2500Title">1440P</h2>
<h2 id="Q2500Title"></h2>
<div id="Q2500"></div>
<h2 id="Q3800Title">4K</h2>
<h2 id="Q3800Title"></h2>
<div id="Q3800"></div>
</div>
</div>
Expand All @@ -44,31 +44,20 @@ <h2 id="Q3800Title">4K</h2>
(function () {
var MoviesPage = {
pluginId: '291d866f-baad-464a-aed6-a4a8b95a8fd7',
sections: ["#unk", "#dvd", "#Q700", "#Q1260", "#Q1900", "#Q2500", "#Q3800"],
res: ["Unknown", "DVD", "480P", "720P", "1080P", "1440P", "4K"],
loadStats: function (page) {
Dashboard.showLoadingMsg();

ApiClient.getPluginConfiguration(MoviesPage.pluginId).then(function (config) {
$("#unkTitle").append(" (" + config.MovieQualityItems[0].Movies.length + ")")
$("#dvdTitle").append(" (" + config.MovieQualityItems[1].Movies.length + ")")
$("#Q700Title").append(" (" + config.MovieQualityItems[2].Movies.length + ")")
$("#Q1260Title").append(" (" + config.MovieQualityItems[3].Movies.length + ")")
$("#Q1900Title").append(" (" + config.MovieQualityItems[4].Movies.length + ")")
$("#Q2500Title").append(" (" + config.MovieQualityItems[5].Movies.length + ")")
$("#Q3800Title").append(" (" + config.MovieQualityItems[6].Movies.length + ")")
$.each(MoviesPage.sections, function (i, section) {
$(section + "Title").html(MoviesPage.res[i] + " (" + config.MovieQualityItems[i].Movies.length + ")");

$.each(config.MovieQualityItems[0].Movies, function (i, v) { $("#unk", page)
.append('<a href=/web/itemdetails.html?id=' + v.Id + '><img src="/Items/' + v.Id + '/Images/Primary" height="200px" alt="' + v.Name + '" /></a>'); });
$.each(config.MovieQualityItems[1].Movies, function (i, v) { $("#dvd", page)
.append('<a href=/web/itemdetails.html?id=' + v.Id + '><img src="/Items/' + v.Id + '/Images/Primary" height="200px" alt="' + v.Name + '" /></a>'); });
$.each(config.MovieQualityItems[2].Movies, function (i, v) { $("#Q700", page)
.append('<a href=/web/itemdetails.html?id=' + v.Id + '><img src="/Items/' + v.Id + '/Images/Primary" height="200px" alt="' + v.Name + '" /></a>'); });
$.each(config.MovieQualityItems[3].Movies, function (i, v) { $("#Q1260", page)
.append('<a href=/web/itemdetails.html?id=' + v.Id + '><img src="/Items/' + v.Id + '/Images/Primary" height="200px" alt="' + v.Name + '" /></a>'); });
$.each(config.MovieQualityItems[4].Movies, function (i, v) { $("#Q1900", page)
.append('<a href=/web/itemdetails.html?id=' + v.Id + '><img src="/Items/' + v.Id + '/Images/Primary" height="200px" alt="' + v.Name + '" /></a>'); });
$.each(config.MovieQualityItems[5].Movies, function (i, v) { $("#Q2500", page)
.append('<a href=/web/itemdetails.html?id=' + v.Id + '><img src="/Items/' + v.Id + '/Images/Primary" height="200px" alt="' + v.Name + '" /></a>'); });
$.each(config.MovieQualityItems[6].Movies, function (i, v) { $("#Q3800", page)
.append('<a href=/web/itemdetails.html?id=' + v.Id + '><img src="/Items/' + v.Id + '/Images/Primary" height="200px" alt="' + v.Name + '" /></a>'); });
$(section, page).html('');
$.each(config.MovieQualityItems[i].Movies, function (j, v) {$(section, page)
.append('<a is="emby-linkbutton" href="/item?id=' + v.Id + '&serverId=' + config.ServerId + '"><img src="/Items/' + v.Id + '/Images/Primary" height="200px" alt="' + v.Name + '" /></a>');
});
})
Dashboard.hideLoadingMsg();
});
}
Expand Down
50 changes: 20 additions & 30 deletions Configuration/movieTextPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ <h1>Movie list</h1>
<button is="emby-button" type="button" class="raised button-cancel block emby-button" onclick="Emby.Page.back();">Go back</button>
</div>

<h2 id="unkTitle">Unknown</h2>
<h2 id="unkTitle"></h2>
<div><table id="unk"></table></div>
<h2 id="dvdTitle">DVD</h2>
<h2 id="dvdTitle"></h2>
<div><table id="dvd"></table></div>
<h2 id="Q700Title">480P</h2>
<h2 id="Q700Title"></h2>
<div><table id="Q700"></table></div>
<h2 id="Q1260Title">720P</h2>
<h2 id="Q1260Title"></h2>
<div><table id="Q1260"></table></div>
<h2 id="Q1900Title">1080P</h2>
<h2 id="Q1900Title"></h2>
<div><table id="Q1900"></table></div>
<h2 id="Q2500Title">1440P</h2>
<h2 id="Q2500Title"></h2>
<div><table id="Q2500"></table></div>
<h2 id="Q3800Title">4K</h2>
<h2 id="Q3800Title"></h2>
<div><table id="Q3800"></table></div>
</div>
</div>
Expand All @@ -44,37 +44,27 @@ <h2 id="Q3800Title">4K</h2>
(function () {
var MoviesListPage = {
pluginId: '291d866f-baad-464a-aed6-a4a8b95a8fd7',
sections: ["#unk", "#dvd", "#Q700", "#Q1260", "#Q1900", "#Q2500", "#Q3800"],
res: ["Unknown", "DVD", "480P", "720P", "1080P", "1440P", "4K"],
loadStats: function (page) {
Dashboard.showLoadingMsg();
ApiClient.getPluginConfiguration(MoviesListPage.pluginId).then(function (config) {
$("#unkTitle").append(" (" + config.MovieQualityItems[0].Movies.length + ")")
$("#dvdTitle").append(" (" + config.MovieQualityItems[1].Movies.length + ")")
$("#Q700Title").append(" (" + config.MovieQualityItems[2].Movies.length + ")")
$("#Q1260Title").append(" (" + config.MovieQualityItems[3].Movies.length + ")")
$("#Q1900Title").append(" (" + config.MovieQualityItems[4].Movies.length + ")")
$("#Q2500Title").append(" (" + config.MovieQualityItems[5].Movies.length + ")")
$("#Q3800Title").append(" (" + config.MovieQualityItems[6].Movies.length + ")")
$.each(MoviesListPage.sections, function (i, section) {
$(section + "Title").html(MoviesListPage.res[i] + " (" + config.MovieQualityItems[i].Movies.length + ")");


$(section, page).html('')
$.each(config.MovieQualityItems[i].Movies, function (j, v) { $(section, page)
.append(MoviesListPage.makeTable(v, config.ServerId)); });

})

$.each(config.MovieQualityItems[0].Movies, function (i, v) { $("#unk", page)
.append(MoviesListPage.makeTable(v)); });
$.each(config.MovieQualityItems[1].Movies, function (i, v) { $("#dvd", page)
.append(MoviesListPage.makeTable(v)); });
$.each(config.MovieQualityItems[2].Movies, function (i, v) { $("#Q700", page)
.append(MoviesListPage.makeTable(v)); });
$.each(config.MovieQualityItems[3].Movies, function (i, v) { $("#Q1260", page)
.append(MoviesListPage.makeTable(v)); });
$.each(config.MovieQualityItems[4].Movies, function (i, v) { $("#Q1900", page)
.append(MoviesListPage.makeTable(v)); });
$.each(config.MovieQualityItems[5].Movies, function (i, v) { $("#Q2500", page)
.append(MoviesListPage.makeTable(v)); });
$.each(config.MovieQualityItems[6].Movies, function (i, v) { $("#Q3800", page)
.append(MoviesListPage.makeTable(v)); });
Dashboard.hideLoadingMsg();
});
},
makeTable: function(movie) {
makeTable: function (movie, ServerId) {
var html = '<tr>';
html += '<td><a href=/web/itemdetails.html?id=' + movie.Id + '>' + movie.Name + '</a></td>';
html += '<td><a is="emby-linkbutton" href="/item?id=' + movie.Id + '&serverId=' + ServerId + '">' + movie.Name + '</a></td>';
html += '<td>' + movie.Year + '</td>';
return html + '</tr>';
}
Expand Down
6 changes: 1 addition & 5 deletions Models/Movie.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace statistics.Models
namespace statistics.Models
{
public class Movie
{
Expand Down
5 changes: 1 addition & 4 deletions Models/MovieQuality.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using MediaBrowser.Controller.Entities.Movies;
using System.Collections.Generic;
using Statistics.Enum;

namespace statistics.Models
Expand Down
1 change: 0 additions & 1 deletion Models/RunTimeModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using Statistics.Enum;

namespace Statistics.ViewModel
{
Expand Down
12 changes: 7 additions & 5 deletions ScheduledTasks/CalculateStatsTask.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Entities;
Expand All @@ -14,7 +14,6 @@
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Tasks;
using statistics;
using statistics.Calculators;
using statistics.Configuration;
using statistics.Models.Configuration;
using Statistics.Api;
Expand All @@ -23,7 +22,7 @@

namespace Statistics.ScheduledTasks
{
public class CalculateStatsTask : IScheduledTask
public class CalculateStatsTask : IScheduledTask
{
private readonly IFileSystem _fileSystem;
private readonly IHttpClient _httpClient;
Expand All @@ -33,12 +32,13 @@ public class CalculateStatsTask : IScheduledTask
private readonly IUserDataManager _userDataManager;
private readonly IUserManager _userManager;
private readonly IZipClient _zipClient;
private IApplicationHost _appHost;

public CalculateStatsTask(ILogManager logger,
IUserManager userManager,
IUserDataManager userDataManager,
ILibraryManager libraryManager, IZipClient zipClient, IHttpClient httpClient, IFileSystem fileSystem,
IServerApplicationPaths serverApplicationPaths)
IServerApplicationPaths serverApplicationPaths, IApplicationHost appHost)
{
_logger = logger.GetLogger("Statistics");
_libraryManager = libraryManager;
Expand All @@ -48,6 +48,7 @@ public CalculateStatsTask(ILogManager logger,
_httpClient = httpClient;
_fileSystem = fileSystem;
_serverApplicationPaths = serverApplicationPaths;
_appHost = appHost;
}

private static PluginConfiguration PluginConfiguration => Plugin.Instance.Configuration;
Expand Down Expand Up @@ -78,6 +79,7 @@ async Task IScheduledTask.Execute(CancellationToken cancellationToken, IProgress
var numComplete = 0;

PluginConfiguration.LastUpdated = DateTime.Now.ToString("g");
PluginConfiguration.ServerId = _appHost.SystemId;

numComplete++;
progress.Report(percentPerUser * numComplete);
Expand Down
Loading

0 comments on commit dcc93f7

Please sign in to comment.