Beispiel #1
0
        private async static Task Harvest_KingdomMelody_Links()
        {
            var discs     = new List <string>();
            var discCodes = new Dictionary <string, string>();

            for (int i = 1; i <= 9; i++)
            {
                if (i == 7 || i == 8)
                {
                    continue;
                }

                var currentDisc     = $"Kingdom Melodies - Disk {i}";
                var currentDiscCode = $"iam-{i}";
                discCodes.Add(currentDiscCode, currentDisc);

                discs.Add(currentDiscCode);

                await MusicHarverster.HarvestMusicLinks("iam", currentDiscCode);
            }

            if (!Directory.Exists($"../../media/Music/Melodies/iam"))
            {
                Directory.CreateDirectory($"../../media/Music/Melodies/iam");
            }

            File.WriteAllText($"../../media/Music/Melodies/index.json", JsonConvert.SerializeObject(
                                  new[] { new { Key = "iam", Value = "Sing Praises to Jehovah (1984)" } }));

            File.WriteAllText($"../../media/Music/Melodies/iam/index.json", JsonConvert.SerializeObject(
                                  discs.Select(x => new
            {
                Key   = x,
                Value = discCodes[x]
            })));
        }
Beispiel #2
0
        private async static Task Harvest_SingToJehovah_Vocal_Links()
        {
            var tasks = new List <Task>();

            var languageDiscs = new Dictionary <string, List <string> >();
            var languageCodes = new Dictionary <string, string>();
            var discCodes     = new Dictionary <string, string>();

            for (int i = 1; i <= 6; i++)
            {
                var currentDisc     = string.Format("Disc {0}", i);
                var currentDiscCode = $"iasnv{i}";
                discCodes.Add(currentDiscCode, currentDisc);

                var harvestLink = $"https://www.jw.org/apps/TRGCHlZRQVNYVrXF?booknum=0&output=json&pub={currentDiscCode}&fileformat=MP3%2CAAC&alllangs=1&langwritten=E&txtCMSLang=E";

                var jsonString = await DownloadUtility.GetAsync(harvestLink);

                var model = JsonConvert.DeserializeObject <dynamic>(jsonString);

                foreach (var item in model.languages)
                {
                    var languageCode = item.Name;
                    var language     = model.languages[item.Name]["name"].Value;

                    languageCodes[languageCode] = language;

                    await MusicHarverster.HarvestMusicLinks("iasnv", currentDiscCode, languageCode);

                    if (languageDiscs.ContainsKey(languageCode))
                    {
                        languageDiscs[languageCode].Add(currentDiscCode);
                    }
                    else
                    {
                        languageDiscs[languageCode] = new List <string>(new[] { currentDiscCode });
                    }
                }
            }

            if (!Directory.Exists($"../../media/Music/Vocals/iasnv"))
            {
                Directory.CreateDirectory($"../../media/music/Vocals/iasnv");
            }

            File.WriteAllText($"../../media/Music/Vocals/index.json", JsonConvert.SerializeObject(
                                  new [] { new { Key = "iasnv", Value = "Sing to Jehovah (2009)" } }));


            File.WriteAllText($"../../media/Music/Vocals/iasnv/index.json", JsonConvert.SerializeObject(
                                  languageDiscs.Select(x => new
            {
                Key   = x.Key,
                Value = languageCodes[x.Key]
            }).ToList()));

            foreach (var discs in languageDiscs)
            {
                if (!Directory.Exists($"../../media/Music/Vocals/iasnv/{discs.Key}"))
                {
                    Directory.CreateDirectory($"../../media/Music/Vocals/iasnv/{discs.Key}");
                }

                File.WriteAllText($"../../media/Music/Vocals/iasnv/{discs.Key}/index.json", JsonConvert.SerializeObject(
                                      discs.Value.Select(x => new
                {
                    Key   = x,
                    Value = discCodes[x]
                })));
            }
        }