Ejemplo n.º 1
0
        public static void DecodePlaylist()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            if (openFileDialog.ShowDialog() == true)
            {
                try
                {
                    string          playlistJson     = File.ReadAllText(openFileDialog.FileName);
                    PlaylistDetails playlist         = JsonConvert.DeserializeObject <PlaylistDetails>(playlistJson);
                    SaveFileDialog  saveMaFileDialog = new SaveFileDialog();
                    foreach (var map in playlist.songs)
                    {
                        map.hash = map.hash.ToLower();
                    }
                    VistaFolderBrowserDialog openFolderDialog = new VistaFolderBrowserDialog();
                    if (openFolderDialog.ShowDialog() == true)
                    {
                        string FolderPath = openFolderDialog.SelectedPath;
                        foreach (var map in playlist.songs)
                        {
                            using (WebClient wc = new WebClient())
                            {
                                var client = new WebClient();
                                client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; " + "Windows NT 5.2; .NET CLR 1.0.3705;)");

                                string response = "";
                                try
                                {
                                    Uri mapUri = new Uri(@"https://beatsaver.com/api/maps/by-hash/" + map.hash);
                                    response = client.DownloadString(mapUri);
                                }
                                catch (Exception e)
                                {
                                    MessageBox.Show("Error");
                                }
                                MapDetails mapdet = new MapDetails();
                                mapdet = JsonConvert.DeserializeObject <MapDetails>(response);
                                Uri    address  = new Uri(urlBase + mapdet.downloadURL);
                                string FileName = FolderPath + @"\" + map.songName + ".zip";
                                DownloadUrl(address, FileName);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show("Error");
                }
            }
        }
Ejemplo n.º 2
0
 public static void ReadLink(string enteredUrl)
 {
     using (WebClient wc = new WebClient())
     {
         var client = new WebClient();
         client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; " + "Windows NT 5.2; .NET CLR 1.0.3705;)");
         string response = "";
         try
         {
             response   = client.DownloadString(enteredUrl);
             BSRCorrect = true;
         }
         catch (Exception e)
         {
             BSRCorrect = false;
         }
         mapdetails = JsonConvert.DeserializeObject <MapDetails>(response);
     }
 }