Esempio n. 1
0
        public static IReadOnlyList <ILanguage> LoadLanguages(IYoutubeAccountContainer container)
        {
            if (!loaded)
            {
                var communicator = new YoutubeAccountCommunicator();
                if (container.RegisteredAccounts.Count > 0)
                {
                    var account = container.RegisteredAccounts.First();

                    LOGGER.Info($"Loading languages for account with id: '{account.Id}', title: '{account.Title}'");

                    languages = GetLanguages(account.GetActiveToken()).ToList();
                }
                else
                {
                    LOGGER.Info($"No accounts registered => using fallback languages");

                    // Fallback
                    foreach (var lang in StandardLanguages.Languages)
                    {
                        LOGGER.Info($"Adding language with id: {lang.Id}, hl: {lang.Hl} and title: '{lang.Name}'");

                        languages.Add(lang);
                    }
                }

                loaded = true;
            }
            else
            {
                LOGGER.Info($"Languages were already loaded");
            }

            return(languages.AsReadOnly());
        }
        public static IReadOnlyList <ICategory> LoadCategories(IYoutubeAccountContainer container)
        {
            if (!loaded)
            {
                var communicator = new YoutubeAccountCommunicator();
                if (container.RegisteredAccounts.Count > 0)
                {
                    var account = container.RegisteredAccounts.First();

                    var region = account.Region;
                    if (account.Region == null)
                    {
                        region = "de";
                    }

                    LOGGER.Info($"Loading categores for account with id: '{account.Id}', title: '{account.Title}' and region: {region}");

                    categories = GetVideoCategories(region, account.GetActiveToken()).ToList();
                }
                else
                {
                    LOGGER.Info($"No accounts registered => using fallback categories");

                    // Fallback
                    foreach (var cat in StandardCategories.Categories)
                    {
                        LOGGER.Info($"Adding category with id: {cat.Id} and title: '{cat.Title}'");

                        categories.Add(cat);
                    }
                }

                loaded = true;
            }
            else
            {
                LOGGER.Info($"Categories were already loaded");
            }

            return(categories.AsReadOnly());
        }