<commit_before>﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Web.Mvc;

using NZBDash.Api.Controllers;
using NZBDash.Common;
using NZBDash.Core.Settings;
using NZBDash.UI.Helpers;
using NZBDash.UI.Models.Dashboard;
using NZBDash.UI.Models.NzbGet;

using UrlHelper = NZBDash.UI.Helpers.UrlHelper;

namespace NZBDash.UI.Controllers.Application
{
    public class NzbGetController : Controller
    {
        public NzbGetController()
        {
            Api = new StatusApiController();
        }

        public StatusApiController Api { get; set; }

        [HttpGet]
        public ActionResult Index()
        {
            var admin = new NzbGetSettingsConfiguration();
            var config = admin.GetSettings();
            var formattedUri = UrlHelper.ReturnUri(config.IpAddress).ToString();
            try
            {
                var statusInfo = Api.GetNzbGetStatus(formattedUri, config.Username, config.Password);
                var downloadSpeed = statusInfo.Result.DownloadRate / 1024;
                var nzbModel = new NzbGetViewModel
                {
                    DownloadSpeed = downloadSpeed.ToString(CultureInfo.CurrentUICulture),
                    Status = statusInfo.Result.ServerPaused ? "Paused" : "Running",
                };

                return View(nzbModel);
            }
            catch (Exception e)
            {

            }
        }

        [HttpGet]
        public ActionResult GetNzbGetDownloadInformation()
        {
            var admin = new NzbGetSettingsConfiguration();
            var config = admin.GetSettings();
            var formattedUri = UrlHelper.ReturnUri(config.IpAddress).ToString();
            try
            {
                var statusInfo = Api.GetNzbGetStatus(formattedUri, config.Username, config.Password);

                var downloadInfo = Api.GetNzbGetList(formattedUri, config.Username, config.Password);

                var downloadSpeed = statusInfo.Result.DownloadRate / 1024;

                var model = new DownloaderViewModel
                {
                    Application = Applications.NzbGet,
                    DownloadSpeed = downloadSpeed.ToString(CultureInfo.CurrentUICulture),
                    DownloadItem = new List<DownloadItem>()
                };

                var results = downloadInfo.result;<commit_msg>Added return in the catch block (NOTE: will log it when logging is done).<commit_after>﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Web.Mvc;

using NZBDash.Api.Controllers;
using NZBDash.Common;
using NZBDash.Core.Settings;
using NZBDash.UI.Helpers;
using NZBDash.UI.Models.Dashboard;
using NZBDash.UI.Models.NzbGet;

using UrlHelper = NZBDash.UI.Helpers.UrlHelper;

namespace NZBDash.UI.Controllers.Application
{
    public class NzbGetController : Controller
    {
        public NzbGetController()
        {
            Api = new StatusApiController();
        }

        public StatusApiController Api { get; set; }

        [HttpGet]
        public ActionResult Index()
        {
            var admin = new NzbGetSettingsConfiguration();
            var config = admin.GetSettings();
            var formattedUri = UrlHelper.ReturnUri(config.IpAddress).ToString();
            try
            {
                var statusInfo = Api.GetNzbGetStatus(formattedUri, config.Username, config.Password);
                var downloadSpeed = statusInfo.Result.DownloadRate / 1024;
                var nzbModel = new NzbGetViewModel
                {
                    DownloadSpeed = downloadSpeed.ToString(CultureInfo.CurrentUICulture),
                    Status = statusInfo.Result.ServerPaused ? "Paused" : "Running",
                };

                return View(nzbModel);
            }
            catch (Exception e)
            {
                return View("Error");
            }
        }

        [HttpGet]
        public ActionResult GetNzbGetDownloadInformation()
        {
            var admin = new NzbGetSettingsConfiguration();
            var config = admin.GetSettings();
            var formattedUri = UrlHelper.ReturnUri(config.IpAddress).ToString();
            try
            {
                var statusInfo = Api.GetNzbGetStatus(formattedUri, config.Username, config.Password);

                var downloadInfo = Api.GetNzbGetList(formattedUri, config.Username, config.Password);

                var downloadSpeed = statusInfo.Result.DownloadRate / 1024;

                var model = new DownloaderViewModel
                {
                    Application = Applications.NzbGet,
                    DownloadSpeed = downloadSpeed.ToString(CultureInfo.CurrentUICulture),
                    DownloadItem = new List<DownloadItem>()
                };

                var results = downloadInfo.result;
{'fraction_non_alphanumeric': 0.08005762502572546, 'fraction_numerical': 0.0032928586128833093, 'mean_word_length': 1.924187725631769, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5007838', 'n_tokens_mistral': 1277, 'n_tokens_neox': 1190, 'n_words': 256}