static async void Search() { // Disable logging Log.setMode(false); // Keyword string querystring = "Kurdo"; // Number of result pages int querypages = 1; //////////////////////////////// // Start searching //////////////////////////////// VideoSearch videos = new VideoSearch(); var items = await videos.GetVideos(querystring, querypages); foreach (var item in items) { Console.WriteLine("Title: " + item.getTitle()); Console.WriteLine("Author: " + item.getAuthor()); Console.WriteLine("Description: " + item.getDescription()); Console.WriteLine("Duration: " + item.getDuration()); Console.WriteLine("Url: " + item.getUrl()); Console.WriteLine("Thumbnail: " + item.getThumbnail()); Console.WriteLine("ViewCount: " + item.getViewCount()); Console.WriteLine(""); } }
public static async Task <List <VideoSearchComponents> > VideoSearch(string queryString, int queryPages = 1) { var videos = new VideoSearch(); var items = await videos.GetVideos(queryString, queryPages); return(items); }
static async Task Main(string[] args) { Console.WriteLine("Hello World!"); string querystring = "travis"; int querypages = 1; VideoSearch videos = new VideoSearch(); var items = await videos.GetVideos(querystring, querypages); foreach (var item in items) { Console.WriteLine("Title: " + item.getTitle()); Console.WriteLine("Author: " + item.getAuthor()); Console.WriteLine("Description: " + item.getDescription()); Console.WriteLine("Duration: " + item.getDuration()); Console.WriteLine("Url: " + item.getUrl()); Console.WriteLine("Thumbnail: " + item.getThumbnail()); Console.WriteLine("ViewCount: " + item.getViewCount()); Console.WriteLine(""); var t = item; await GetAudio(t.getUrl(), t.getTitle() + ".mp4"); } Console.WriteLine("Complete"); // >> Download << // string link = "https://www.youtube.com/watch?v=daKz_b7LrsE"; // IEnumerable<VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(link, false); // DownloadVideo(videoInfos); }
public async Task GetYtLink([Optional] params string[] rawQuery) { try { if (rawQuery is null || rawQuery.Length == 0) { await ReplyAsync("usage: `b!yt <query>`"); return; } string searchQuery = rawQuery.ParseText(); VideoSearch videos = new VideoSearch(); var items = await videos.GetVideos(searchQuery, 1); //EmbedBuilder embed = new EmbedBuilder(); await ReplyAsync(items.First().getUrl()); } catch (InvalidOperationException ex) { await ReplyAsync($"Such video doesn't exist."); Serilog.Log.Error(ex, "Issue while getting a video:"); return; } }
public async Task DownloadAllMoviesThemeSongsAsync() { _logger.LogInformation("1"); VideoSearch videoSearch = new VideoSearch(); var movies = GetMoviesFromLibrary(); _logger.LogInformation(movies.Count().ToString()); foreach (var movie in movies) { var title = String.Format("{0} {1} Soundtrack", movie.Name, movie.ProductionYear); _logger.LogInformation(title); var results = await videoSearch.GetVideos(title, 1); var link = results[0].getUrl(); _logger.LogInformation(link); try { //IEnumerable<YoutubeExtractor.VideoInfo> videoInfos = YoutubeExtractor.DownloadUrlResolver.GetDownloadUrls(link); await downloadYoutubeAudioAsync(movie.ContainingFolderPath, link); } catch (Exception e) { _logger.LogInformation(e.Message); _logger.LogInformation("error"); } } }
public async Task AddSong([Remainder] string url) { if (!(Uri.TryCreate(url, UriKind.Absolute, out Uri uriResult) && uriResult.Scheme == Uri.UriSchemeHttp)) { int querypages = 1; VideoSearch videos = new VideoSearch(); var result = videos.GetVideos(url, querypages).Result.FirstOrDefault(); if (result == null) { await Context.Channel.SendMessageAsync($"Die Suche nach `{url}` konnte keine Ergebnisse erziehlen."); } else { url = result.getUrl(); } } if (await _audioService.AddToPlaylist(Context.Guild, url)) { var videoInfos = DownloadUrlResolver.GetDownloadUrls(url, false).FirstOrDefault(); if (videoInfos != null) { await Context.Channel.SendMessageAsync($"`{videoInfos.Title}` wurde erfolgreich zur Playlist hinzugefügt."); return; } } await Context.Channel.SendMessageAsync($"Ups, da ging was schief."); }
public async Task DownloadAllMoviesThemeSongsAsync() { _logger.LogInformation("1"); VideoSearch videoSearch = new VideoSearch(); var movies = GetMoviesFromLibrary(); _logger.LogInformation(movies.Count().ToString()); foreach (var movie in movies) { var title = movie.OriginalTitle + " bso " + movie.ProductionYear; _logger.LogInformation(title); var results = await videoSearch.GetVideos(title, 1); var link = results[0].getUrl(); _logger.LogInformation(link); try { await downloadYoutubeAudioAsync(movie.Path, link); } catch (Exception e) { _logger.LogInformation(e.Message); _logger.LogInformation("error"); } } }
public async Task <List <string> > DownloadVideos(string outputPath, string searchQuery) { var videoPaths = new List <string>(); var videoPath = DownloadVideoAndReturnPath((await _videoSearch.GetVideos(searchQuery, 1)).First(), outputPath); videoPaths.Add(videoPath); return(videoPaths); }
async void YouTubeSearch(string querystring) { AudioS audioSearch; int querypages = 1; VideoSearch videos = new VideoSearch(); var items = await videos.GetVideos(querystring, querypages); searchList.Items.Clear(); foreach (var item in items) { audioSearch = new AudioS(item.getAuthor(), item.getTitle().Trim(), item.getDescription(), item.getDuration(), item.getUrl(), item.getThumbnail()); searchList.Items.Add(audioSearch); } }
public async void PerformSearch() { Videos = new ObservableCollection <VideoModel>(); string querystring = searchTerm; int querypages = 1; VideoSearch videos = new VideoSearch(); var items = await videos.GetVideos(querystring, querypages); foreach (var i in items) { var t = new VideoModel() { Author = i.getAuthor(), Downloaded = false, ImageLocation = i.getThumbnail(), Selected = false, Title = i.getTitle(), Url = i.getUrl(), }; var sp = t.Title.IndexOf('-') - 1; var art = ""; var track = ""; if (sp <= 1) { art = t.Title.Trim(); track = ""; } else { art = t.Title.Substring(0, sp).Trim(); track = t.Title.Remove(0, sp + 2).Trim(); } t.Artist = art; t.SongName = track; Videos.Add( t ); } ItemCount = Videos.Count; }
private static async void AramaYap(Form1 frm) { frm.listBox1.Items.Clear(); frm.linkler.Clear(); Log.setMode(false); VideoSearch videolar = new VideoSearch(); var veriler = await videolar.GetVideos(frm.textBox1.Text, 1); foreach (var veri in veriler) { string ekle = frm.IsimDuzenle(veri.getTitle()); frm.listBox1.Items.Add(ekle); frm.linkler.Add(veri.getUrl()); } }
private async void SearchBar_KeyUp(object sender, KeyRoutedEventArgs e) { if (e.Key == Windows.System.VirtualKey.Enter) { this.searching = true; var items = new VideoSearch(); this.songListObservable.Clear(); LoadingDialog dialog = new LoadingDialog(); var t = dialog.ShowAsync(); var videos = await items.GetVideos(this.SearchBar.Text, 1); foreach (var item in videos) { var s = new Song(item.getTitle(), item.getUrl(), "none", Helper.ImageURLToBase64(item.getThumbnail()), item.getDuration()); this.songListObservable.Add(s); } t.Cancel(); } }
public async Task Play([Remainder] string url) { if (!(Uri.TryCreate(url, UriKind.Absolute, out Uri uriResult) && uriResult.Scheme == Uri.UriSchemeHttp)) { int querypages = 1; VideoSearch videos = new VideoSearch(); var result = videos.GetVideos(url, querypages).Result.FirstOrDefault(); if (result == null) { await Context.Channel.SendMessageAsync($"Die Suche nach `{url}` konnte keine Ergebnisse erziehlen."); } else { url = result.getUrl(); } } if (_audioService.Play(Context.Guild, url)) { try { var videoInfos = DownloadUrlResolver.GetDownloadUrls(url, false).FirstOrDefault(); if (videoInfos != null) { await Context.Channel.SendMessageAsync($"`{videoInfos.Title}` wird abgespielt."); return; } } catch (Exception ex) { _logger.Error(ex, $"Error in {nameof(Play)}"); await Context.Channel.SendMessageAsync($"Ups, da ging was schief."); return; } } await Context.Channel.SendMessageAsync($"Ups, da ging was schief."); }
private async Task <int> search(string songNames) { string querystring = songNames; int querypages = 1; VideoSearch videos = new VideoSearch(); //var items = new List<VideoSearchComponents>(); //await Task.Factory.StartNew(async () => items = await videos.GetVideos(querystring, querypages)); var items = await videos.GetVideos(querystring, querypages); foreach (var item in items) { Console.WriteLine("Thumbnail: " + item.getThumbnail()); //var request = WebRequest.Create(string.Format("https://img.youtube.com/vi/{}/0.jpg", item.getUrl().ToString().Remove(0, 32))); var request = WebRequest.Create(item.getThumbnail()); using (var response = request.GetResponse()) using (var stream = response.GetResponseStream()) { songImg.Image = Bitmap.FromStream(stream); } return(0); } return(0); }
public async Task <string> GetVideo(string query) { var items = await videos.GetVideos(query, 1); return(items[0].getUrl()); }
// hàm tìm kiếm private async void searchVideos(bool checkHasName = false) { // tắt form record nếu đang hoạt động if (activeForm != null) { activeForm.Close(); } // lấy câu truy vấn string querySong; if (checkHasName) { querySong = MusicApp.nowPlayingPlaylist[0].Name + "karaoke"; } else { querySong = textBox_titleVideo.Text; } // tạo list data mới list = new List <video>(); // lấy video thông qua youtube search VideoSearch videos = new VideoSearch(); var items = await videos.GetVideos(querySong, 1); // lấy 10 video đầu , lười sửa code nên chơi cục súc vậy :v int i = 1; foreach (var item in items) { if (i > 10) { break; } video vd = new video(); string title_utf8 = DecodeFromUtf8(item.getTitle()); vd.Title = title_utf8; vd.Author = item.getAuthor(); vd.Url = item.getUrl(); byte[] imageBytes = new WebClient().DownloadData(item.getThumbnail()); using (MemoryStream ms = new MemoryStream(imageBytes)) { vd.Thumbnail = Image.FromStream(ms); } list.Add(vd); i++; } // gán data cho cho các pic, label, cũng lười nên chơi cục súc pictureBox_item1.Image = list[0].Thumbnail; label_item1.Text = list[0].Title; pictureBox_item2.Image = list[1].Thumbnail; label_item2.Text = list[1].Title; pictureBox_item3.Image = list[2].Thumbnail; label_item3.Text = list[2].Title; pictureBox_item4.Image = list[3].Thumbnail; label_item4.Text = list[3].Title; pictureBox_item5.Image = list[4].Thumbnail; label_item5.Text = list[4].Title; pictureBox_item6.Image = list[5].Thumbnail; label_item6.Text = list[5].Title; pictureBox_item7.Image = list[6].Thumbnail; label_item7.Text = list[6].Title; pictureBox_item8.Image = list[7].Thumbnail; label_item8.Text = list[7].Title; pictureBox_item9.Image = list[8].Thumbnail; label_item9.Text = list[8].Title; pictureBox_item10.Image = list[9].Thumbnail; label_item10.Text = list[9].Title; // show panel chứa data panel_videosSearch.Visible = true; }