public static void ReadCsv(string fullPath)
        {
            try
            {
                Core.YoutubeFiles.Clear();
                int fieldCount     = 0;
                int rowCountBefore = 0;
                // open the file "data.csv" which is a CSV file with headers
                List <YoutubeFile> YoutubeFiles = new List <YoutubeFile>();
                using (CsvReader csv = new CsvReader(new StreamReader(fullPath), true))
                {
                    fieldCount = csv.FieldCount;
                    string[] headers = csv.GetFieldHeaders();
                    //rowCountBefore = csv.Count();
                    YoutubeFile item = null;
                    long        no   = 1;
                    while (csv.ReadNextRecord())
                    {
                        item        = new YoutubeFile();
                        item.NO     = no;
                        item.ID     = csv[0].Trim();
                        item.TITLE  = csv[1].Trim();
                        item.ARTIST = csv[2].Trim();
                        item.ALBUM  = csv[3].Trim();
                        item.LABEL  = csv[4].Trim();
                        item.ISRC   = csv[5].Trim();

                        item.COMP_ID        = csv[6].Trim();
                        item.COMP_TITLE     = csv[7].Trim();
                        item.COMP_ISWC      = csv[8].Trim();
                        item.COMP_WRITERS   = csv[9].Trim();
                        item.COMP_CUSTOM_ID = csv[10].Trim();
                        item.QUANTILE       = csv[11].Trim();
                        YoutubeFiles.Add(item);
                        no++;
                    }
                }
                Core.YoutubeFiles = YoutubeFiles;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #2
0
        public IActionResult Info(int actionType)
        {
            if ((ActionType)actionType == ActionType.SkipSong)
            {
                this.Skip();
            }
            else if ((ActionType)actionType == ActionType.ToggleMusic)
            {
                this.PauseResume();
            }

            ViewData["Title"]              = "Info";
            ViewData["Paused"]             = ServiceLocator.Musicplayer.IsPaused;
            ViewData["CurrentPlayingSong"] = ServiceLocator.Musicplayer.CurrentPlayingSong != null ? ServiceLocator.Musicplayer.CurrentPlayingSong.Name : "";

            ViewData["Users"] = this.userManager.Users.Count;

            for (int i = 0; i < this.userManager.Users.Count; i++)
            {
                ViewData["User" + i] = this.userManager.Users[i].Name;
                ViewData["User" + i + "TimePlayed"]   = this.userManager.Users[i].TimePlayed;
                ViewData["User" + i + "YoutubeLinks"] = this.userManager.Users[i].YoutubeLinks.Count;
                for (int j = 0; j < this.userManager.Users[i].YoutubeLinks.Count; j++)
                {
                    YoutubeFile youtubefile = this.userManager.Users[i].YoutubeLinks.ElementAt(j);

                    string additionalInfo = " downloading...";
                    if (youtubefile.Downloaded == true)
                    {
                        additionalInfo = " Title: " + youtubefile.Name + " Duration: " + youtubefile.Duration + " seconds";
                    }

                    ViewData["User" + i + "YoutubeLink" + j] = youtubefile.Url + additionalInfo;
                }
            }

            return(View());
        }
コード例 #3
0
        /// <summary>
        /// Create report to total 7 file
        /// </summary>
        /// <param name="isCheckIsrc"></param>
        /// <param name="isCheckLabel"></param>
        /// <param name="isCheckTitle"></param>
        /// <param name="indexDetect"></param>
        /// <param name="key"></param>
        public static void CreateReporting(bool isCheckIsrc, bool isCheckLabel, bool isCheckTitle, int indexDetect, string key)
        {
            try
            {
                LanguageDetect languageDetect = new LanguageDetect(key);
                #region clear data
                Core.YoutubeFiles1.Clear();
                Core.YoutubeFiles2.Clear();
                Core.YoutubeFiles3.Clear();
                Core.YoutubeFiles4_non_vi.Clear();
                Core.YoutubeFiles4_vi.Clear();
                Core.YoutubeFiles5_non_vi.Clear();
                Core.YoutubeFiles5_vi.Clear();
                #endregion

                bool check = true;
                for (int i = 0; i < Core.YoutubeFiles.Count; i++)
                {
                    #region 1.file1
                    check = true;
                    foreach (var item in Core.ConfigFile1.configItems)
                    {
                        if (item.IsCheck)
                        {
                            check = Compare(i, item);
                            if (!check)
                            {
                                break;
                            }
                        }
                    }
                    if (check)
                    {
                        YoutubeFile youtubeFileClone = (YoutubeFile)Core.YoutubeFiles[i].Clone();
                        Core.YoutubeFiles1.Add(youtubeFileClone);
                    }
                    #endregion

                    #region 2.file2
                    check = true;
                    foreach (var item in Core.ConfigFile2.configItems)
                    {
                        if (item.IsCheck)
                        {
                            check = Compare(i, item);
                            if (!check)
                            {
                                break;
                            }
                        }
                    }
                    if (check)
                    {
                        YoutubeFile youtubeFileClone = (YoutubeFile)Core.YoutubeFiles[i].Clone();
                        Core.YoutubeFiles2.Add(youtubeFileClone);
                    }
                    #endregion

                    #region 3.file3
                    check = true;
                    foreach (var item in Core.ConfigFile3.configItems)
                    {
                        if (item.IsCheck)
                        {
                            check = Compare(i, item);
                            if (!check)
                            {
                                break;
                            }
                        }
                    }
                    if (check)
                    {
                        YoutubeFile youtubeFileClone = (YoutubeFile)Core.YoutubeFiles[i].Clone();
                        Core.YoutubeFiles3.Add(youtubeFileClone);
                    }
                    #endregion

                    #region 4.file4-none-vi
                    check = true;
                    foreach (var item in Core.ConfigFile4_non_vi.configItems)
                    {
                        if (item.IsCheck)
                        {
                            check = Compare(i, item);
                            if (!check)
                            {
                                break;
                            }
                        }
                    }
                    if (check)
                    {
                        YoutubeFile youtubeFileClone = (YoutubeFile)Core.YoutubeFiles[i].Clone();
                        Core.YoutubeFiles4_non_vi.Add(youtubeFileClone);
                    }
                    else
                    {
                        int a = 1;
                    }
                    #endregion

                    #region 5.file5-none-vi
                    check = true;
                    foreach (var item in Core.ConfigFile5_non_vi.configItems)
                    {
                        if (item.IsCheck)
                        {
                            check = Compare(i, item);
                            if (!check)
                            {
                                break;
                            }
                        }
                    }
                    if (check)
                    {
                        YoutubeFile youtubeFileClone = (YoutubeFile)Core.YoutubeFiles[i].Clone();
                        Core.YoutubeFiles5_non_vi.Add(youtubeFileClone);
                    }
                    #endregion

                    #region 6.file4-vi
                    //1. điều kiện
                    check = true;
                    foreach (var item in Core.ConfigFile4_vi.configItems)
                    {
                        if (item.IsCheck)
                        {
                            check = Compare(i, item);
                            if (!check)
                            {
                                break;
                            }
                        }
                    }
                    if (check)
                    {
                        if (isCheckIsrc)
                        {
                            List <ViDetectItem> itemCompare = Core.ConfigFile4_vi.viDetectItems;
                            #region loc tiếng việt
                            check = CheckVi(check, i, itemCompare, isCheckLabel, isCheckTitle);
                            #endregion
                            ////neu chua phai la tieng viet, dungapi
                            ////cuoi cung dung API
                            //if (!check)
                            //{
                            //    check = languageDetect.DetectLanguage(Core.YoutubeFiles[i].TITLE, indexDetect);
                            //    //test
                            //    if(check)
                            //    {
                            //        int a = 1;
                            //    }
                            //}
                        }
                        //file4-vi: file tieng viet
                        if (check)
                        {
                            YoutubeFile youtubeFileClone = (YoutubeFile)Core.YoutubeFiles[i].Clone();
                            Core.YoutubeFiles4_vi.Add(youtubeFileClone);
                        }
                        else
                        {
                            //file4-agin-none-vi: file tieng viet
                            YoutubeFile youtubeFileClone = (YoutubeFile)Core.YoutubeFiles[i].Clone();
                            Core.YoutubeFiles4_again_aftert_Convert_vi.Add(youtubeFileClone);
                        }
                    }
                    #endregion

                    #region 7.file5-vi
                    check = true;
                    foreach (var item in Core.ConfigFile5_vi.configItems)
                    {
                        if (item.IsCheck)
                        {
                            check = Compare(i, item);
                            if (!check)
                            {
                                break;
                            }
                        }
                    }
                    if (check)
                    {
                        if (isCheckIsrc)
                        {
                            List <ViDetectItem> itemCompare = Core.ConfigFile4_vi.viDetectItems;
                            #region loc tiếng việt
                            check = CheckVi(check, i, itemCompare, isCheckLabel, isCheckTitle);
                            #endregion
                            ////neu chua phai la tieng viet, dungapi
                            ////cuoi cung dung API
                            //if (!check)
                            //{
                            //    check = languageDetect.DetectLanguage(Core.YoutubeFiles[i].TITLE, indexDetect);
                            //    //test
                            //    if (check)
                            //    {
                            //        int a = 1;
                            //    }
                            //}
                        }
                        //file5-vi: file tieng viet
                        if (check)
                        {
                            YoutubeFile youtubeFileClone = (YoutubeFile)Core.YoutubeFiles[i].Clone();
                            Core.YoutubeFiles5_vi.Add(youtubeFileClone);
                        }
                        else
                        {
                            //file5-agin-none-vi: file tieng viet
                            YoutubeFile youtubeFileClone = (YoutubeFile)Core.YoutubeFiles[i].Clone();
                            Core.YoutubeFiles5_again_aftert_Convert_vi.Add(youtubeFileClone);
                        }
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                string str = ex.ToString();
            }
        }