Skip to content

Commit

Permalink
Merge pull request #1586 from mregni/develop
Browse files Browse the repository at this point in the history
Fixing smaller issues before forum post
  • Loading branch information
mregni authored Jul 29, 2021
2 parents 214b51f + 65f1dd7 commit 7dc94ac
Show file tree
Hide file tree
Showing 41 changed files with 42 additions and 105 deletions.
20 changes: 8 additions & 12 deletions EmbyStat.Clients.Base/Http/BaseHttpClient.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using EmbyStat.Clients.Base.Converters;
using EmbyStat.Common.Converters;
Expand All @@ -19,8 +16,6 @@
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Querying;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using RestSharp;

Expand Down Expand Up @@ -114,10 +109,12 @@ protected string ExecuteCall(IRestRequest request)
protected async Task<IEnumerable<MediaServerUdpBroadcast>> SearchServer(string message)
{
var list = new List<MediaServerUdpBroadcast>();
Logger.Debug($"Checking following broadcast IPs (own IP: ");
foreach (var ip in GetBroadCastIps())
var ownIp = _accessor.HttpContext?.Connection.RemoteIpAddress ?? IPAddress.Any;
Logger.Debug($"Own IP detected: {ownIp.MapToIPv4()}");
Logger.Debug($"Sending \"{message}\" to following broadcast IPs:");
foreach (var ip in GetBroadCastIps(ownIp))
{
Logger.Debug($"\t{ip}");
Logger.Debug($"\t{ip.MapToIPv4()}");
await Task.Run(async () =>
{
var to = new IPEndPoint(ip, 7359);
Expand All @@ -136,10 +133,9 @@ await Task.Run(async () =>
return list;
}

private IEnumerable<IPAddress> GetBroadCastIps()
private IEnumerable<IPAddress> GetBroadCastIps(IPAddress ip)
{
var ip = _accessor.HttpContext?.Connection.RemoteIpAddress;
Logger.Debug($"{ip})");
Logger.Debug($"{ip.MapToIPv4()})");
var interfaces = NetworkInterface.GetAllNetworkInterfaces();
foreach (var adapter in interfaces)
{
Expand Down Expand Up @@ -201,7 +197,7 @@ public bool Ping(string message)
Logger.Debug($"Ping returned: {result}");
return result == message;
}
catch (Exception e)
catch (System.Exception e)
{
Logger.Error(e, "Ping failed");
return false;
Expand Down
2 changes: 0 additions & 2 deletions EmbyStat.Clients.Base/Http/ServerSearcher.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections;
using System.Diagnostics;
using System.Net;
using System.Net.Sockets;
using System.Text;
Expand Down
1 change: 0 additions & 1 deletion EmbyStat.Clients.Emby/Http/EmbyHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using EmbyStat.Clients.Base.Http;
using EmbyStat.Common.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using RestSharp;

namespace EmbyStat.Clients.Emby.Http
Expand Down
1 change: 0 additions & 1 deletion EmbyStat.Clients.Jellyfin/Http/JellyfinHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using EmbyStat.Clients.Base.Http;
using EmbyStat.Common.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using RestSharp;

namespace EmbyStat.Clients.Jellyfin.Http
Expand Down
4 changes: 1 addition & 3 deletions EmbyStat.Clients.Tmdb/Converter/EpisodeHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using EmbyStat.Common.Models.Show;
using Rollbar.DTOs;
using EmbyStat.Common.Models.Show;
using TMDbLib.Objects.Search;

namespace EmbyStat.Clients.Tmdb.Converter
Expand Down
4 changes: 1 addition & 3 deletions EmbyStat.Clients.Tmdb/ITmdbClient.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Generic;
using System.Threading.Tasks;
using EmbyStat.Common.Models.Show;

Expand Down
7 changes: 1 addition & 6 deletions EmbyStat.Clients.Tmdb/TmdbClient.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EmbyStat.Clients.Tmdb.Converter;
using EmbyStat.Common;
using EmbyStat.Common.Models.Show;
using TMDbLib.Client;
using TMDbLib.Objects.TvShows;

namespace EmbyStat.Clients.Tmdb
{
Expand Down
2 changes: 0 additions & 2 deletions EmbyStat.Common/Models/Entities/Show.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using EmbyStat.Common.Enums;
using EmbyStat.Common.Models.Entities.Helpers;
using LiteDB;

Expand Down
1 change: 0 additions & 1 deletion EmbyStat.Common/Models/Settings/UserSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using EmbyStat.Common.Enums;
using Newtonsoft.Json;
using Rollbar.DTOs;

namespace EmbyStat.Common.Models.Settings
{
Expand Down
2 changes: 1 addition & 1 deletion EmbyStat.Common/Models/StartupOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class StartupOptions
[Option('c', "config-dir", Required = false, Default = "", HelpText = "Folder where config files are stored, default is <current-directory>")]
public string ConfigDir { get; set; }

[Option('l', "log-level", Required = false, Default = 2, HelpText = "Set the proper log level\n1: Debug\n2: Information")]
[Option('g', "log-level", Required = false, Default = 2, HelpText = "Set the proper log level\n1: Debug\n2: Information")]
public int LogLevel { get; set; }

[Option('u', "listen-urls", Required = false, Default = "http://*", HelpText = "Set the url's where EmbyStat needs to listen on. Default is http://* but you can change it to only loopback address here if needed. Don't add port number, it will be added automatically. Use ; if you want to define more then one url.")]
Expand Down
2 changes: 0 additions & 2 deletions EmbyStat.Controllers/Account/AccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
using System.Threading.Tasks;
using EmbyStat.Common.Models.Account;
using EmbyStat.Logging;
using EmbyStat.Services;
using EmbyStat.Services.Interfaces;
using MediaBrowser.Model.Logging;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

Expand Down
1 change: 0 additions & 1 deletion EmbyStat.Controllers/Log/LogController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using AutoMapper;
using EmbyStat.Services.Interfaces;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Net.Http.Headers;

namespace EmbyStat.Controllers.Log
{
Expand Down
1 change: 0 additions & 1 deletion EmbyStat.Controllers/Settings/SettingsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using EmbyStat.Repositories.Interfaces;
using EmbyStat.Services.Interfaces;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Infrastructure;

namespace EmbyStat.Controllers.Settings
{
Expand Down
1 change: 0 additions & 1 deletion EmbyStat.Controllers/Show/ShowController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using EmbyStat.Common.Helpers;
using EmbyStat.Common.Models.Query;
using EmbyStat.Controllers.HelperClasses;
using EmbyStat.Controllers.Movie;
using EmbyStat.Services.Interfaces;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
Expand Down
1 change: 0 additions & 1 deletion EmbyStat.Controllers/Show/ShowDetailViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace EmbyStat.Controllers.Show
{
Expand Down
6 changes: 1 addition & 5 deletions EmbyStat.Controllers/Show/ShowRowViewModel.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 EmbyStat.Controllers.Show
namespace EmbyStat.Controllers.Show
{
public class ShowRowViewModel
{
Expand Down
6 changes: 1 addition & 5 deletions EmbyStat.Jobs/Jobs/Interfaces/IMovieSyncJob.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 EmbyStat.Jobs.Jobs.Interfaces
namespace EmbyStat.Jobs.Jobs.Interfaces
{
public interface IMovieSyncJob : IBaseJob
{
Expand Down
1 change: 0 additions & 1 deletion EmbyStat.Jobs/Jobs/Sync/MovieSyncJob.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.Threading;
using System.Threading.Tasks;
using EmbyStat.Clients.Base;
Expand Down
1 change: 0 additions & 1 deletion EmbyStat.Repositories/Helpers/MediaRepository.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.Encodings.Web;
using System.Web;
using EmbyStat.Common.Enums;
using EmbyStat.Common.Models;
Expand Down
1 change: 0 additions & 1 deletion EmbyStat.Repositories/Interfaces/IMovieRepository.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using EmbyStat.Common.Models.Entities;
using System.Collections.Generic;
using EmbyStat.Common.Enums;
using EmbyStat.Repositories.Interfaces.Helpers;
using EmbyStat.Common.Models;
using EmbyStat.Common.Models.Query;
Expand Down
4 changes: 0 additions & 4 deletions EmbyStat.Repositories/MovieRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using EmbyStat.Common.Enums;
using EmbyStat.Common.Extensions;
using EmbyStat.Common.Models;
using EmbyStat.Common.Models.Entities;
using EmbyStat.Common.Models.Entities.Helpers;
using EmbyStat.Common.Models.Query;
using EmbyStat.Repositories.Helpers;
using EmbyStat.Repositories.Interfaces;
using MoreLinq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace EmbyStat.Repositories
{
Expand Down
3 changes: 1 addition & 2 deletions EmbyStat.Repositories/ShowRepository.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 AutoMapper;
using EmbyStat.Common.Enums;
using EmbyStat.Common.Extensions;
using EmbyStat.Common.Models.Entities;
Expand Down Expand Up @@ -122,7 +121,7 @@ public IEnumerable<Show> GetShowPage(int skip, int take, string sort, Filter[] f
? query.OrderByDescending(x => typeof(Show).GetProperty(selector)?.GetValue(x, null))
: query.OrderBy(x => typeof(Show).GetProperty(selector)?.GetValue(x, null));
}

return query
.Skip(skip)
.Take(take);
Expand Down
4 changes: 0 additions & 4 deletions EmbyStat.Services/Abstract/MediaService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@
using System.Collections.Generic;
using System.Linq;
using EmbyStat.Common;
using EmbyStat.Common.Enums;
using EmbyStat.Common.Extensions;
using EmbyStat.Common.Models.Entities;
using EmbyStat.Common.Models.Entities.Helpers;
using EmbyStat.Repositories.Interfaces;
using EmbyStat.Services.Converters;
using EmbyStat.Services.Interfaces;
using EmbyStat.Services.Models.Cards;
using EmbyStat.Services.Models.Charts;
using EmbyStat.Services.Models.Stat;
using Newtonsoft.Json;

namespace EmbyStat.Services.Abstract
Expand Down
1 change: 0 additions & 1 deletion EmbyStat.Services/Interfaces/IShowService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using EmbyStat.Common.Models.Query;
using EmbyStat.Services.Models.DataGrid;
using EmbyStat.Services.Models.Show;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace EmbyStat.Services.Interfaces
{
Expand Down
6 changes: 1 addition & 5 deletions EmbyStat.Services/Models/DataGrid/ShowRow.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 EmbyStat.Services.Models.DataGrid
namespace EmbyStat.Services.Models.DataGrid
{
public class ShowRow
{
Expand Down
1 change: 0 additions & 1 deletion EmbyStat.Web/ClientApp/.eslintcache

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,11 @@ export const MediaServerDetails = forwardRef<ValidationHandleWithSave, StepProps

const openMediaServer = async () => {
try {
const { type, protocol, address, port, baseUrl, baseUrlNeeded } = getValues();
const htmlPage = type === 0 ? "apikeys" : "apikeys.html";
const { protocol, address, port, baseUrl, baseUrlNeeded } = getValues();
const protocolTxt = protocol === 0 ? "https://" : "http://";
const baseUrlTxt = baseUrlNeeded ? baseUrl : '';
window.open(
`${protocolTxt}${address}:${port}${baseUrlTxt}/web/index.html#!/${htmlPage}`,
`${protocolTxt}${address}:${port}${baseUrlTxt}/web/index.html#!/apikeys.html`,
"_blank"
);
}
Expand Down
2 changes: 1 addition & 1 deletion EmbyStat.Web/ClientApp/src/pages/wizard/Wizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ const Wizard = () => {
<EsButton
onClick={handleBack}
fullWidth={false}
disabled={disableControls || [0, 4, 7].includes(activeStep)}
disabled={disableControls || [0, 7].includes(activeStep)}
>
<KeyboardArrowLeft />
{t('back')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const MediaServerHeader = (props: Props) => {
container
direction="column"
justify="flex-start"
className="m-l-32"
className="m-l-32 m-r-8"
>
<Typography
variant="body1"
Expand Down
24 changes: 18 additions & 6 deletions EmbyStat.Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,34 @@ public static int Main(string[] args)
{
try
{
StartupOptions options = null;
Parser.Default.ParseArguments<StartupOptions>(args).MapResult(opts => options = opts, NotParedOptions);

if (options == null)
var parseResult = Parser.Default.ParseArguments<StartupOptions>(args)
.WithParsed(startupOptions =>
{
if (startupOptions.LogLevel == 1)
{
Console.WriteLine("------------------------------");
Console.WriteLine("!Application is in Debug mode!");
Console.WriteLine("------------------------------");
}
})
;

if (parseResult.Tag == ParserResultType.NotParsed)
{
return 0;
}

StartupOptions options = null;
parseResult.MapResult(opt => options = opt, NotParedOptions);

options = CheckEnvironmentVariables(options);

var configArgs = CreateArgsArray(options);
_logger = SetupLogging(configArgs);
LogLevelChanger.SetNlogLogLevel(NLog.LogLevel.FromOrdinal(options.LogLevel));

LogStartupParameters(configArgs, options.LogLevel, options.Service);

var listeningUrl = string.Join(';', options.ListeningUrls.Split(';').Select(x => $"{x}:{options.Port}"));
var config = BuildConfigurationRoot(configArgs);
var host = BuildWebHost(args, listeningUrl, config);
Expand Down
1 change: 0 additions & 1 deletion EmbyStat.Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using System.Text;
using System.Threading.Tasks;
using AspNetCore.Identity.LiteDB;
using AutoMapper;
using EmbyStat.Clients.Base;
using EmbyStat.Common;
using EmbyStat.Common.Enums;
Expand Down
5 changes: 1 addition & 4 deletions Tests.Unit/Builders/LibraryBuilder.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 EmbyStat.Common.Enums;
using EmbyStat.Common.Enums;
using EmbyStat.Common.Models.Entities;

namespace Tests.Unit.Builders
Expand Down
2 changes: 0 additions & 2 deletions Tests.Unit/Builders/SubtitleStreamBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using EmbyStat.Common.Models.Entities.Helpers;

namespace Tests.Unit.Builders
Expand Down
Loading

0 comments on commit 7dc94ac

Please sign in to comment.