Esempio n. 1
0
        /// <summary>
        /// Load playlist info from JSON file stored in local app data
        /// </summary>
        public static YoutubePlaylistInfo Load()
        {
            YoutubePlaylistInfo youtubePlaylistInfo = new YoutubePlaylistInfo();

            if (File.Exists($"{_filepath}\\{_filename}"))
            {
                using (StreamReader file = File.OpenText($"{_filepath}\\{_filename}"))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    youtubePlaylistInfo = (YoutubePlaylistInfo)serializer.Deserialize(file, typeof(YoutubePlaylistInfo));
                }
            }

            return(youtubePlaylistInfo);
        }
Esempio n. 2
0
        /// <summary>
        /// Save playlist info into JSON file stored in local app data
        /// </summary>
        public static void Save(string youTubeClientId, string youTubeClientSecret, string twitchBotApiLink, int broadcasterId)
        {
            YoutubePlaylistInfo youtubePlaylistInfo = new YoutubePlaylistInfo
            {
                ClientId         = youTubeClientId,
                ClientSecret     = youTubeClientSecret,
                BroadcasterId    = broadcasterId,
                TwitchBotApiLink = twitchBotApiLink
            };

            Directory.CreateDirectory(_filepath);

            using (StreamWriter file = File.CreateText($"{_filepath}\\{_filename}"))
            {
                JsonSerializer serializer = new JsonSerializer();
                serializer.Serialize(file, youtubePlaylistInfo);
            }
        }