Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
        /// </summary>
        public ServerConfiguration()
        {
            LocalNetworkAddresses = new string[] { };
            Migrations = new string[] { };
            SqliteCacheSize = 0;

            EnableLocalizedGuids = true;
            DisplaySpecialsWithinSeasons = true;

            ImageSavingConvention = ImageSavingConvention.Compatible;
            PublicPort = 8096;
            PublicHttpsPort = 8920;
            HttpServerPortNumber = 8096;
            HttpsPortNumber = 8920;
            EnableHttps = false;
            EnableDashboardResponseCaching = true;
            EnableDashboardResourceMinification = true;
            EnableAnonymousUsageReporting = true;

            EnableAutomaticRestart = true;

            EnableUPnP = true;
            SharingExpirationDays = 30;
            MinResumePct = 5;
            MaxResumePct = 90;

            // 5 minutes
            MinResumeDurationSeconds = 300;

            EnableLibraryMonitor = AutoOnOff.Auto;
            LibraryMonitorDelay = 60;

            EnableInternetProviders = true;
            FindInternetTrailers = true;

            PathSubstitutions = new PathSubstitution[] { };
            ContentTypes = new NameValuePair[] { };

            PreferredMetadataLanguage = "en";
            MetadataCountryCode = "US";

            SortReplaceCharacters = new[] { ".", "+", "%" };
            SortRemoveCharacters = new[] { ",", "&", "-", "{", "}", "'" };
            SortRemoveWords = new[] { "the", "a", "an" };

            SeasonZeroDisplayName = "Specials";

            UICulture = "en-us";

            PeopleMetadataOptions = new PeopleMetadataOptions();

            MetadataOptions = new[]
            {
                new MetadataOptions(1, 1280) {ItemType = "Book"},

                new MetadataOptions(1, 1280)
                {
                    ItemType = "Movie",
                    ImageOptions = new []
                    {
                        new ImageOption
                        {
                            Limit = 1,
                            MinWidth = 1280,
                            Type = ImageType.Backdrop
                        },

                        // Don't download this by default as it's rarely used.
                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Art
                        },

                        // Don't download this by default as it's rarely used.
                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Disc
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Primary
                        },

                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Banner
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Thumb
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Logo
                        }
                    }
                },

                new MetadataOptions(1, 1280)
                {
                    ItemType = "MusicVideo",
                    ImageOptions = new []
                    {
                        new ImageOption
                        {
                            Limit = 1,
                            MinWidth = 1280,
                            Type = ImageType.Backdrop
                        },

                        // Don't download this by default as it's rarely used.
                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Art
                        },

                        // Don't download this by default as it's rarely used.
                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Disc
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Primary
                        },

                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Banner
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Thumb
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Logo
                        }
                    }
                },

                new MetadataOptions(1, 1280)
                {
                    ItemType = "Series",
                    ImageOptions = new []
                    {
                        new ImageOption
                        {
                            Limit = 1,
                            MinWidth = 1280,
                            Type = ImageType.Backdrop
                        },

                        // Don't download this by default as it's rarely used.
                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Art
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Primary
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Banner
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Thumb
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Logo
                        }
                    }
                },

                new MetadataOptions(1, 1280)
                {
                    ItemType = "MusicAlbum",
                    ImageOptions = new []
                    {
                        new ImageOption
                        {
                            Limit = 0,
                            MinWidth = 1280,
                            Type = ImageType.Backdrop
                        },

                        // Don't download this by default as it's rarely used.
                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Disc
                        }
                    }
                },

                new MetadataOptions(1, 1280)
                {
                    ItemType = "MusicArtist",
                    ImageOptions = new []
                    {
                        new ImageOption
                        {
                            Limit = 1,
                            MinWidth = 1280,
                            Type = ImageType.Backdrop
                        },

                        // Don't download this by default
                        // They do look great, but most artists won't have them, which means a banner view isn't really possible
                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Banner
                        },

                        // Don't download this by default
                        // Generally not used
                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Art
                        },

                        // Don't download this by default
                        // Generally not used
                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Logo
                        }
                    }
                },

                new MetadataOptions(1, 1280)
                {
                    ItemType = "BoxSet",
                    ImageOptions = new []
                    {
                        new ImageOption
                        {
                            Limit = 1,
                            MinWidth = 1280,
                            Type = ImageType.Backdrop
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Primary
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Thumb
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Logo
                        },

                        // Don't download this by default as it's rarely used.
                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Art
                        },

                        // Don't download this by default as it's rarely used.
                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Disc
                        },

                        // Don't download this by default as it's rarely used.
                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Banner
                        }
                    }
                },

                new MetadataOptions(0, 1280)
                {
                    ItemType = "Season",
                    ImageOptions = new []
                    {
                        new ImageOption
                        {
                            Limit = 0,
                            MinWidth = 1280,
                            Type = ImageType.Backdrop
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Primary
                        },

                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Banner
                        },

                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Thumb
                        }
                    },
                    DisabledMetadataFetchers = new []{ "The Open Movie Database", "TheMovieDb" }
                },

                new MetadataOptions(0, 1280)
                {
                    ItemType = "Episode",
                    ImageOptions = new []
                    {
                        new ImageOption
                        {
                            Limit = 0,
                            MinWidth = 1280,
                            Type = ImageType.Backdrop
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Primary
                        }
                    },
                    DisabledMetadataFetchers = new []{ "The Open Movie Database" },
                    DisabledImageFetchers = new []{ "TheMovieDb" }
                }
            };
        }
Esempio n. 2
0
        private async Task<string> GetToken(ListingsProviderInfo info, CancellationToken cancellationToken)
        {
            var username = info.Username;

            // Reset the token if there's no username
            if (string.IsNullOrWhiteSpace(username))
            {
                return null;
            }

            var password = info.Password;
            if (string.IsNullOrWhiteSpace(password))
            {
                return null;
            }

            // Avoid hammering SD
            if ((DateTime.UtcNow - _lastErrorResponse).TotalMinutes < 1)
            {
                return null;
            }

            NameValuePair savedToken = null;
            if (!_tokens.TryGetValue(username, out savedToken))
            {
                savedToken = new NameValuePair();
                _tokens.TryAdd(username, savedToken);
            }

            if (!string.IsNullOrWhiteSpace(savedToken.Name) && !string.IsNullOrWhiteSpace(savedToken.Value))
            {
                long ticks;
                if (long.TryParse(savedToken.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out ticks))
                {
                    // If it's under 24 hours old we can still use it
                    if (DateTime.UtcNow.Ticks - ticks < TimeSpan.FromHours(20).Ticks)
                    {
                        return savedToken.Name;
                    }
                }
            }

            await _tokenSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
            try
            {
                var result = await GetTokenInternal(username, password, cancellationToken).ConfigureAwait(false);
                savedToken.Name = result;
                savedToken.Value = DateTime.UtcNow.Ticks.ToString(CultureInfo.InvariantCulture);
                return result;
            }
            catch (HttpException ex)
            {
                if (ex.StatusCode.HasValue)
                {
                    if ((int)ex.StatusCode.Value == 400)
                    {
                        _tokens.Clear();
                        _lastErrorResponse = DateTime.UtcNow;
                    }
                }
                throw;
            }
            finally
            {
                _tokenSemaphore.Release();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
        /// </summary>
        public ServerConfiguration()
        {
            ImageSavingConvention = ImageSavingConvention.Compatible;
            PublicPort = 8096;
            PublicHttpsPort = 8920;
            HttpServerPortNumber = 8096;
            HttpsPortNumber = 8920;
            EnableHttps = false;
            EnableDashboardResponseCaching = true;
            EnableDashboardResourceMinification = true;

            EnableAutomaticRestart = true;
            DenyIFrameEmbedding = true;

            EnableUPnP = true;

            SharingExpirationDays = 30;
            MinResumePct = 5;
            MaxResumePct = 90;

            // 5 minutes
            MinResumeDurationSeconds = 300;

            EnableLibraryMonitor = AutoOnOff.Auto;
            RealtimeLibraryMonitorDelay = 40;

            EnableInternetProviders = true;
            FindInternetTrailers = true;

            PathSubstitutions = new PathSubstitution[] { };
            ContentTypes = new NameValuePair[] { };

            PreferredMetadataLanguage = "en";
            MetadataCountryCode = "US";

            SortReplaceCharacters = new[] { ".", "+", "%" };
            SortRemoveCharacters = new[] { ",", "&", "-", "{", "}", "'" };
            SortRemoveWords = new[] { "the", "a", "an" };

            SeasonZeroDisplayName = "Specials";

            UICulture = "en-us";

            PeopleMetadataOptions = new PeopleMetadataOptions();

            EnableVideoFrameAnalysis = true;
            VideoFrameAnalysisLimitBytes = 600000000;

            InsecureApps9 = new[]
            {
                "Chromecast",
                "iOS",
                "Unknown app",
                "iPad",
                "iPhone",
                "Windows Phone"
            };

            MetadataOptions = new[]
            {
                new MetadataOptions(1, 1280) {ItemType = "Book"},

                new MetadataOptions(1, 1280)
                {
                    ItemType = "Movie",
                    ImageOptions = new []
                    {
                        new ImageOption
                        {
                            Limit = 1,
                            MinWidth = 1280,
                            Type = ImageType.Backdrop
                        },

                        // Don't download this by default as it's rarely used.
                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Art
                        },

                        // Don't download this by default as it's rarely used.
                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Disc
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Primary
                        },

                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Banner
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Thumb
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Logo
                        }
                    }
                },

                new MetadataOptions(1, 1280)
                {
                    ItemType = "MusicVideo",
                    ImageOptions = new []
                    {
                        new ImageOption
                        {
                            Limit = 1,
                            MinWidth = 1280,
                            Type = ImageType.Backdrop
                        },

                        // Don't download this by default as it's rarely used.
                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Art
                        },

                        // Don't download this by default as it's rarely used.
                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Disc
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Primary
                        },

                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Banner
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Thumb
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Logo
                        }
                    }
                },

                new MetadataOptions(1, 1280)
                {
                    ItemType = "Series",
                    ImageOptions = new []
                    {
                        new ImageOption
                        {
                            Limit = 1,
                            MinWidth = 1280,
                            Type = ImageType.Backdrop
                        },

                        // Don't download this by default as it's rarely used.
                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Art
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Primary
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Banner
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Thumb
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Logo
                        }
                    }
                },

                new MetadataOptions(1, 1280)
                {
                    ItemType = "MusicAlbum",
                    ImageOptions = new []
                    {
                        new ImageOption
                        {
                            Limit = 0,
                            MinWidth = 1280,
                            Type = ImageType.Backdrop
                        },

                        // Don't download this by default as it's rarely used.
                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Disc
                        }
                    }
                },

                new MetadataOptions(1, 1280)
                {
                    ItemType = "MusicArtist",
                    ImageOptions = new []
                    {
                        new ImageOption
                        {
                            Limit = 1,
                            MinWidth = 1280,
                            Type = ImageType.Backdrop
                        },

                        // Don't download this by default
                        // They do look great, but most artists won't have them, which means a banner view isn't really possible
                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Banner
                        },

                        // Don't download this by default
                        // Generally not used
                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Art
                        },

                        // Don't download this by default
                        // Generally not used
                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Logo
                        }
                    }
                },

                new MetadataOptions(1, 1280)
                {
                    ItemType = "BoxSet",
                    ImageOptions = new []
                    {
                        new ImageOption
                        {
                            Limit = 1,
                            MinWidth = 1280,
                            Type = ImageType.Backdrop
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Primary
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Thumb
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Logo
                        },

                        // Don't download this by default as it's rarely used.
                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Art
                        },

                        // Don't download this by default as it's rarely used.
                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Disc
                        },

                        // Don't download this by default as it's rarely used.
                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Banner
                        }
                    }
                },

                new MetadataOptions(0, 1280)
                {
                    ItemType = "Season",
                    ImageOptions = new []
                    {
                        new ImageOption
                        {
                            Limit = 0,
                            MinWidth = 1280,
                            Type = ImageType.Backdrop
                        },

                        new ImageOption
                        {
                            Limit = 1,
                            Type = ImageType.Primary
                        },

                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Banner
                        },

                        new ImageOption
                        {
                            Limit = 0,
                            Type = ImageType.Thumb
                        }
                    }
                }
            };
        }