Exemplo n.º 1
0
        public static bool AlbumIsAvailable(Album album)
        {
            string page = "torrents.php?action=advanced&artistname=" + System.Web.HttpUtility.UrlEncode(album.ArtistName) +
                "&groupname=" + System.Web.HttpUtility.UrlEncode(album.AlbumName);
            string result = FetchPage(page);

            // This check is kind of ugly, but it works
            return result.Contains("group_torrent");
        }
Exemplo n.º 2
0
        private void ScanWithDirectoryStructure()
        {
            string music_directory;
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            if (fbd.ShowDialog() == DialogResult.OK)
            {
                music_directory = fbd.SelectedPath;
            }
            else
            {
                return;
            }

            try
            {
                Log("Scanning");
                if (!WhatHelper.LoggedIn)
                {
                    Log("Logging in...");
                    WhatHelper.Login(Username.Text, Password.Text);
                }

                foreach (string artistPath in System.IO.Directory.GetDirectories(music_directory))
                {
                    foreach (string albumName in System.IO.Directory.GetDirectories(artistPath))
                    {
                        Application.DoEvents();

                        Album album = new Album(System.IO.Path.GetFileName(artistPath), System.IO.Path.GetFileName(albumName));
                        Log("Checking for " + album.ToString());
                        if (!WhatHelper.AlbumIsAvailable(album))
                            albumBindingSource.Add(album);
                    }
                }

                Log("Finished");
            }
            catch (Exception ex)
            {
                Log(ex.GetType().ToString() + ": " + ex.Message);
            }
        }
Exemplo n.º 3
0
        private void ScanWithTextFile()
        {
            OpenFileDialog ofd = new OpenFileDialog();
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    Log("Reading file");
                    System.IO.StreamReader sr = new System.IO.StreamReader(ofd.FileName);
                    string[] data = sr.ReadToEnd().Split('\n');
                    sr.Close();

                    if (!WhatHelper.LoggedIn)
                    {
                        Log("Logging in...");
                        WhatHelper.Login(Username.Text, Password.Text);
                    }

                    foreach (string line in data)
                    {
                        Application.DoEvents();

                        string[] parts = line.Split('\\');
                        if (parts.Length != 2)
                        {
                            Log("Invalid format of line, skipping: \"" + line + "\"");
                            continue;
                        }

                        Album album = new Album(parts[0], parts[1]);

                        Log("Checking for " + album.ToString());
                        if (!WhatHelper.AlbumIsAvailable(album))
                            albumBindingSource.Add(album);
                    }
                    Log("Finished");
                }
                catch (Exception ex)
                {
                    Log(ex.GetType().ToString() + ": " + ex.Message);
                }
            }
        }