예제 #1
0
        private void AddSearchResult(BeatInfo info)
        {
            if (this.dgvResult.InvokeRequired)
            {
                AddSearchResultCallBack cb = new AddSearchResultCallBack(AddSearchResult);
                this.Invoke(cb, new object[] { info });
                return;
            }

            if (info != null)
            {
                string[] data = new string[] {
                    info.Title,
                    info.Artist,
                    info.Genre,
                    info.Link,
                };

                tableResults.Rows.Add(data);

                dgvResult.Rows.Add(data);
                // sorting
                dgvResult.Sort(dgvResult.Columns[0], ListSortDirection.Ascending);
            }

            // update results on tab header
            ((TabPage)Parent).Text = searchQuery + " (" + dgvResult.Rows.Count + ")";

            //txtResult.Text = dgvResult.Rows.Count + " kết quả";
        }
예제 #2
0
        public void AddRow(BeatInfo info)
        {
            Main frmMain = (Main)Parent.Parent.Parent;

            // find beat
            for (int i = 0; i < dgvDownload.Rows.Count; i++)
            {
                if (dgvDownload.Rows[i].Cells[3].Value.ToString() == info.Link)
                {
                    return;
                }
            }

            object[] row = new object[] {
                IconList.GetIcon(IconList.GetIconIndex(info.Site)),
                info.Title,
                info.Artist,
                info.Link,
                "",
                "Not started"
            };

            dgvDownload.Rows.Add(row);

            dgvDownload.Rows[dgvDownload.Rows.Count - 1].Cells[0].Tag = info.Site;
            dgvDownload.Rows[dgvDownload.Rows.Count - 1].Cells[5].Tag = DownloaderState.NotStarted;
        }
예제 #3
0
        public void AddRow(BeatInfo info)
        {
            Main frmMain = (Main)Parent.Parent.Parent;

            // find beat
            for (int i = 0; i < dgvDownload.Rows.Count; i++)
            {
                if (dgvDownload.Rows[i].Cells[3].Value.ToString() == info.Link)
                {
                    return;
                }
            }

            object[] row = new object[] {
                IconList.GetIcon(IconList.GetIconIndex(info.Site)),
                info.Title,
                info.Artist,
                info.Link,
                "",
                "Not started"
            };

            dgvDownload.Rows.Add(row);

            dgvDownload.Rows[dgvDownload.Rows.Count - 1].Cells[0].Tag = info.Site;
            dgvDownload.Rows[dgvDownload.Rows.Count - 1].Cells[5].Tag = DownloaderState.NotStarted;
        }
예제 #4
0
        private void AddSearchResult(BeatInfo info)
        {
            if (this.dgvResult.InvokeRequired)
            {
                AddSearchResultCallBack cb = new AddSearchResultCallBack(AddSearchResult);
                this.Invoke(cb, new object[] {info});
                return;
            }

            if (info != null)
            {
                string[] data = new string[] {
                    info.Title,
                    info.Artist,
                    info.Genre,
                    info.Link,
                };

                tableResults.Rows.Add(data);

                dgvResult.Rows.Add(data);
                // sorting
                dgvResult.Sort(dgvResult.Columns[0], ListSortDirection.Ascending);
            }

            // update results on tab header
            ((TabPage)Parent).Text = searchQuery + " (" + dgvResult.Rows.Count  + ")";

            //txtResult.Text = dgvResult.Rows.Count + " kết quả";
        }
예제 #5
0
        public Downloader(BeatInfo info)
        {
            thrDownload = null;

            _BeatInfo = info;

            m_EventStopThread = new ManualResetEvent(false);
            m_EventStopThread.Reset();
            m_EventThreadStopped = new ManualResetEvent(false);
            m_EventThreadStopped.Reset();
        }
예제 #6
0
        public static void UpdateInfo(string filePath, BeatInfo info)
        {
            TagLib.File mp3File = TagLib.File.Create(filePath + ".mp3");
            TagLib.Id3v2.Tag tag = (TagLib.Id3v2.Tag)mp3File.GetTag(TagLib.TagTypes.Id3v2);

            tag.Title = info.Title;
            tag.Performers = new string[] { info.Artist };
            tag.Comment = "Beat Downloader - redphx\nhttp://beat.redphx.com\nhttp://www.karaholics.com";

            mp3File.Save();
        }
예제 #7
0
        public Downloader(BeatInfo info)
        {
            thrDownload = null;

            _BeatInfo = info;

            m_EventStopThread = new ManualResetEvent(false);
            m_EventStopThread.Reset();
            m_EventThreadStopped = new ManualResetEvent(false);
            m_EventThreadStopped.Reset();
        }
예제 #8
0
        public static void UpdateInfo(string filePath, BeatInfo info)
        {
            TagLib.File      mp3File = TagLib.File.Create(filePath + ".mp3");
            TagLib.Id3v2.Tag tag     = (TagLib.Id3v2.Tag)mp3File.GetTag(TagLib.TagTypes.Id3v2);


            tag.Title      = info.Title;
            tag.Performers = new string[] { info.Artist };
            tag.Comment    = "Beat Downloader - redphx\nhttp://beat.redphx.com\nhttp://www.karaholics.com";

            mp3File.Save();
        }
예제 #9
0
        private void AddToDownloadList()
        {
            if (dgvResult.SelectedRows.Count == 0)
            {
                return;
            }

            TabControl  tabContainer = (TabControl)Parent.Parent;
            DownloadTab dlTab        = (DownloadTab)tabContainer.TabPages[0].Controls[0];

            for (int i = 0; i < dgvResult.SelectedRows.Count; i++)
            {
                DataGridViewCellCollection cellCol = dgvResult.SelectedRows[i].Cells;

                BeatInfo beatInfo = new BeatInfo();
                beatInfo.Site   = searchSite;
                beatInfo.Title  = cellCol[0].Value.ToString();
                beatInfo.Artist = cellCol[1].Value.ToString();
                beatInfo.Link   = cellCol[3].Value.ToString();

                dlTab.AddRow(beatInfo);
            }
            tabContainer.SelectTab(0);
        }
예제 #10
0
        private void DoDownload()
        {
            if (isDownloading)
            {
                return;
            }

            int index = FindIndexByStatus(DownloaderState.Queuing);

            if (index == -1)
            {
                return;
            }

            isDownloading = true;

            btnDownload.Enabled = false;
            btnStop.Enabled     = true;


            BeatInfo beatInfo = new BeatInfo();

            beatInfo.Site   = dgvDownload.Rows[index].Cells[0].Tag.ToString();
            beatInfo.Title  = dgvDownload.Rows[index].Cells[1].Value.ToString();
            beatInfo.Artist = dgvDownload.Rows[index].Cells[2].Value.ToString();
            beatInfo.Link   = dgvDownload.Rows[index].Cells[3].Value.ToString();
            beatInfo.Beat   = dgvDownload.Rows[index].Cells[4].Value.ToString();

            // downloading
            SetStatus(index, DownloaderState.Downloading);

            // status label
            lbDownloadStatus.Text = "Downloading \"" + beatInfo.Artist + " - " + beatInfo.Title + "\" ...";

            DownloadBeat(beatInfo);
        }
예제 #11
0
        private void DoDownload()
        {
            if (isDownloading)
            {
                return;
            }

            int index = FindIndexByStatus(DownloaderState.Queuing);

            if (index == -1)
            {
                return;
            }

            isDownloading = true;

            btnDownload.Enabled = false;
            btnStop.Enabled = true;

            BeatInfo beatInfo = new BeatInfo();
            beatInfo.Site = dgvDownload.Rows[index].Cells[0].Tag.ToString();
            beatInfo.Title = dgvDownload.Rows[index].Cells[1].Value.ToString();
            beatInfo.Artist = dgvDownload.Rows[index].Cells[2].Value.ToString();
            beatInfo.Link = dgvDownload.Rows[index].Cells[3].Value.ToString();
            beatInfo.Beat = dgvDownload.Rows[index].Cells[4].Value.ToString();

            // downloading
            SetStatus(index, DownloaderState.Downloading);

            // status label
            lbDownloadStatus.Text = "Downloading \"" + beatInfo.Artist + " - " + beatInfo.Title + "\" ...";

            DownloadBeat(beatInfo);
        }
예제 #12
0
        // search and show
        private void SearchAndShow()
        {
            string query = HttpUtility.UrlPathEncode(searchQuery);

            string      searchURL;
            XmlDocument xmlDoc;

            int total      = 0;
            int page       = 1;
            int totalPages = 1;


            if (searchSite == "sannhac.com")
            {
                searchURL = "http://sannhac.com/ajax.php?cmd=search&x_strSearch=" + query + "&typep=2&x_order=1&ord=ASC&page=";

                try
                {
                    while (true)
                    {
                        if (page > totalPages)
                        {
                            break;
                        }

                        xmlDoc = GlobalCode.GetXML(searchURL + page);

                        if (page == 1)
                        {
                            XmlNodeList xmlConfig = xmlDoc.GetElementsByTagName("config");
                            total = Convert.ToInt32(xmlConfig[0].Attributes["total"].Value);

                            if (total == 0)
                            {
                                AddSearchResult(null);
                                break;
                            }

                            totalPages = (int)Math.Ceiling((decimal)total / 25);
                        }

                        XmlNodeList xnlRec = xmlDoc.GetElementsByTagName("rec");
                        foreach (XmlNode node in xnlRec)
                        {
                            XmlAttributeCollection attr = node.Attributes;

                            BeatInfo beatInfo = new BeatInfo();
                            beatInfo.Title  = attr["song_name"].Value.Replace("&amp;", "&");
                            beatInfo.Artist = attr["singer_name"].Value.Replace("&amp;", "&");
                            beatInfo.Genre  = SearchTab.StripHTML(attr["genre"].Value);
                            beatInfo.Link   = attr["linkSong"].Value;


                            AddSearchResult(beatInfo);
                        }


                        ++page;
                    }
                }

                catch (Exception ex)
                {
                    StopSearching();
                }
            }
            else
            {
                query = query.Replace("%20", "+");
                string webContent;

                MatchCollection patternMatches;
                try
                {
                    while (true)
                    {
                        searchURL = "http://star.zing.vn/star/search/search." + page + ".html?q=" + query;

                        webContent = GlobalCode.GetContent(searchURL);

                        if (page == 1)
                        {
                            // tìm tổng số trang
                            patternMatches = Regex.Matches(webContent, @"href='/star/search/[^\.]+\.([0-9]+)\.html\?q=[^']+' class=''><img src='[^']+icon_lastpage\.gif'", RegexOptions.IgnoreCase);
                            if (patternMatches.Count == 0)
                            {
                                totalPages = 1;
                            }
                            else
                            {
                                totalPages = Convert.ToInt32(patternMatches[0].Groups[1].Value);
                            }
                        }

                        patternMatches = Regex.Matches(webContent, @"<tr class=""[^""]*"">[^<]+(<td ><a onMouseOut=""hideddrivetip\(\)""(?:[^<]+|<(?!/tr>))*)</tr>", RegexOptions.Multiline | RegexOptions.IgnoreCase);

                        // ko có kết quả
                        if (patternMatches.Count == 0)
                        {
                            AddSearchResult(null);
                            break;
                        }
                        else
                        {
                            Match    matchTemp;
                            string[] data = new string[5];
                            foreach (Match matchRow in patternMatches)
                            {
                                data = new string[6];

                                matchTemp = Regex.Match(matchRow.Groups[1].Value, @"ddrivetip\('<b>([^<]+)</b>[\w\W]*\.([0-9]+)\.html[\w\W]*<a title=""([^""]+)""[\w\W]*>([^<]+)</a></td>", RegexOptions.Multiline | RegexOptions.IgnoreCase);


                                BeatInfo beatInfo = new BeatInfo();
                                beatInfo.Title  = matchTemp.Groups[1].Value.Replace(@"\&#039;", "'").Replace("&amp;", "&");
                                beatInfo.Artist = matchTemp.Groups[3].Value.Replace(@"\&#039;", "'").Replace("&amp;", "&");
                                beatInfo.Genre  = matchTemp.Groups[4].Value.Replace("&amp;", "&");
                                beatInfo.Link   = matchTemp.Groups[2].Value;

                                AddSearchResult(beatInfo);
                            }
                        }
                        ++page;
                    }
                }
                catch (Exception ex)
                {
                    //MessageBox.Show(ex.Message);
                    StopSearching();
                }
            }

            StopSearching();
        }
예제 #13
0
        // search and show
        private void SearchAndShow()
        {
            string query = HttpUtility.UrlPathEncode(searchQuery);

            string searchURL;
            XmlDocument xmlDoc;

            int total = 0;
            int page = 1;
            int totalPages = 1;

            if (searchSite == "sannhac.com")
            {
                searchURL = "http://sannhac.com/ajax.php?cmd=search&x_strSearch=" + query + "&typep=2&x_order=1&ord=ASC&page=";

                try
                {
                    while (true)
                    {
                        if (page > totalPages)
                        {
                            break;
                        }

                        xmlDoc = GlobalCode.GetXML(searchURL + page);

                        if (page == 1)
                        {
                            XmlNodeList xmlConfig = xmlDoc.GetElementsByTagName("config");
                            total = Convert.ToInt32(xmlConfig[0].Attributes["total"].Value);

                            if (total == 0)
                            {
                                AddSearchResult(null);
                                break;
                            }

                            totalPages = (int)Math.Ceiling((decimal)total / 25);
                        }

                        XmlNodeList xnlRec = xmlDoc.GetElementsByTagName("rec");
                        foreach (XmlNode node in xnlRec)
                        {
                            XmlAttributeCollection attr = node.Attributes;

                            BeatInfo beatInfo = new BeatInfo();
                            beatInfo.Title = attr["song_name"].Value.Replace("&amp;", "&");
                            beatInfo.Artist = attr["singer_name"].Value.Replace("&amp;", "&");
                            beatInfo.Genre = SearchTab.StripHTML(attr["genre"].Value);
                            beatInfo.Link = attr["linkSong"].Value;

                            AddSearchResult(beatInfo);
                        }

                        ++page;
                    }
                }

                catch (Exception ex)
                {
                    StopSearching();
                }
            }
            else
            {
                query = query.Replace("%20", "+");
                string webContent;

                MatchCollection patternMatches;
                try
                {
                    while (true)
                    {
                        searchURL = "http://star.zing.vn/star/search/search." + page + ".html?q=" + query;

                        webContent = GlobalCode.GetContent(searchURL);

                        if (page == 1)
                        {
                            // tìm tổng số trang
                            patternMatches = Regex.Matches(webContent, @"href='/star/search/[^\.]+\.([0-9]+)\.html\?q=[^']+' class=''><img src='[^']+icon_lastpage\.gif'", RegexOptions.IgnoreCase);
                            if (patternMatches.Count == 0)
                            {
                                totalPages = 1;
                            }
                            else
                            {
                                totalPages = Convert.ToInt32(patternMatches[0].Groups[1].Value);
                            }
                        }

                        patternMatches = Regex.Matches(webContent, @"<tr class=""[^""]*"">[^<]+(<td ><a onMouseOut=""hideddrivetip\(\)""(?:[^<]+|<(?!/tr>))*)</tr>", RegexOptions.Multiline | RegexOptions.IgnoreCase);

                        // ko có kết quả
                        if (patternMatches.Count == 0)
                        {
                            AddSearchResult(null);
                            break;
                        }
                        else
                        {
                            Match matchTemp;
                            string[] data = new string[5];
                            foreach (Match matchRow in patternMatches)
                            {
                                data = new string[6];

                                matchTemp = Regex.Match(matchRow.Groups[1].Value, @"ddrivetip\('<b>([^<]+)</b>[\w\W]*\.([0-9]+)\.html[\w\W]*<a title=""([^""]+)""[\w\W]*>([^<]+)</a></td>", RegexOptions.Multiline | RegexOptions.IgnoreCase);

                                BeatInfo beatInfo = new BeatInfo();
                                beatInfo.Title = matchTemp.Groups[1].Value.Replace(@"\&#039;", "'").Replace("&amp;", "&");
                                beatInfo.Artist = matchTemp.Groups[3].Value.Replace(@"\&#039;", "'").Replace("&amp;", "&");
                                beatInfo.Genre = matchTemp.Groups[4].Value.Replace("&amp;", "&");
                                beatInfo.Link = matchTemp.Groups[2].Value;

                                AddSearchResult(beatInfo);
                            }
                        }
                        ++page;

                    }
                }
                catch (Exception ex)
                {
                    //MessageBox.Show(ex.Message);
                    StopSearching();
                }
            }

            StopSearching();
        }
예제 #14
0
        private void AddToDownloadList()
        {
            if (dgvResult.SelectedRows.Count == 0)
            {
                return;
            }

            TabControl tabContainer = (TabControl)Parent.Parent;
            DownloadTab dlTab = (DownloadTab)tabContainer.TabPages[0].Controls[0];

            for (int i = 0; i < dgvResult.SelectedRows.Count; i++)
            {
                DataGridViewCellCollection cellCol = dgvResult.SelectedRows[i].Cells;

                BeatInfo beatInfo = new BeatInfo();
                beatInfo.Site = searchSite;
                beatInfo.Title = cellCol[0].Value.ToString();
                beatInfo.Artist = cellCol[1].Value.ToString();
                beatInfo.Link = cellCol[3].Value.ToString();

                dlTab.AddRow(beatInfo);

            }
            tabContainer.SelectTab(0);
        }