예제 #1
0
        static void GetViewsOfSongFromYoutube_NhacViet()
        {
            List <SpotifyInfo> listSongsFromStatistic = GetDataFromGoogleSheet.GetAllSongsFromStaticSheetVN();
            var ytbGroupCount = (int)Math.Ceiling((double)listSongsFromStatistic.Count / (double)YTB_GROUP_SIZE);

            for (var i = 0; i < ytbGroupCount; i++)
            {
                List <SpotifyInfo> songs = new List <SpotifyInfo>();
                var groupSongs           = listSongsFromStatistic.Skip(i * YTB_GROUP_SIZE).Take(YTB_GROUP_SIZE).ToList();
                Console.WriteLine($"Running {i}/{ytbGroupCount}...");
                var account = Proxy.RandomProxy();
                var client  = Proxy.ChangeProxy(account);
                songs = YoutubeServices.GetYoutubeInfoAsyncVN(groupSongs, client).GetAwaiter().GetResult();
                string rawrange = songs.FirstOrDefault().Range;
                string range    = rawrange.Remove(rawrange.IndexOf("J") + 1);
                range = "Danh sách nhạc tổng!" + range;
                UpdateDataToGoogleSheet.InsertYoutubeVN(songs, range);
                Console.WriteLine($"Done. Wating 10s...");
                Thread.Sleep(10 * 1000);
            }
        }
예제 #2
0
        static void GetViewOfSongFromYoutube()
        {
            List <SpotifyInfo> listSongsFromStatistic = GetDataFromGoogleSheet.GetAllSongsFromStaticSheet();

            //kiểm tra có bài mới không, nếu có thì bắt đầu lấy link youtube + view
            if (numberOfOldSongs > 0 && numberOfOldSongs < listSongsFromStatistic.Count)
            {
                listSongsFromStatistic = listSongsFromStatistic.Skip(numberOfOldSongs).ToList();
            }
            var totalSongs = new List <Songs>();

            foreach (var item in listSongsFromStatistic)
            {
                var song = new Songs();
                song.TrackName   = item.TrackTitle;
                song.TrackArtist = item.Artists;
                song.Code        = item.Code;
                totalSongs.Add(song);
            }
            if (File.Exists(ytbViewResult))
            {
                File.Delete(ytbViewResult);
            }
            var          ytbGroupCount = (int)Math.Ceiling((double)totalSongs.Count / (double)YTB_GROUP_SIZE);
            List <Songs> songs         = new List <Songs>();

            for (var i = 0; i < ytbGroupCount; i++)
            {
                var groupSongs = totalSongs.Skip(i * YTB_GROUP_SIZE).Take(YTB_GROUP_SIZE).ToList();
                Console.WriteLine($"Running {i}...");
                var account = Proxy.RandomProxy();
                var client  = Proxy.ChangeProxy(account);
                songs = YoutubeServices.GetYoutubeInfoAsync(groupSongs, client, ytbViewResult).GetAwaiter().GetResult();
                Console.WriteLine($"Done. Wating 10s...");
                Thread.Sleep(10 * 1000);
            }
            UpdateDataToGoogleSheet.InsertLinkYoutube(songs, numberOfOldSongs);
            UpdateDataToGoogleSheet.InsertViewYoutube(songs, numberOfOldSongs);
        }