public void Test_SearchStory_DeleteByUserId() { var result = new SearchStoryDb(); var storyService = kernel.Get <IStoryService>(); var storyDb = fakerStory.Generate(1).First(); storyService.Save(storyDb); var userId = storyDb.UserId; storyService.Save(fakerStory.Generate(1).First()); using (var context = new YoutubeContext()) { result = context.SearchStories.FirstOrDefault(r => r.UserId == userId); result.Should().NotBeNull(); } storyService.DeleteByUserId(userId); using (var context = new YoutubeContext()) { result = context.SearchStories.FirstOrDefault(r => r.UserId == userId); result.Should().BeNull(); } }
// GET: Videos public ActionResult Index() { IEnumerable data = new YoutubeContext().Videos .Select(v => new VideoModel { VideoID = v.VideoID, VideoTitle = v.VideoTitle, VideoUrl = v.VideoUrl, VideoUploader = v.VideoUploader, VideoUploadDate = v.VideoUploadDate, VideoViews = v.VideoViews, VideoDuration = v.VideoDuration, VideoThumbnail = v.VideoThumbnail, VideoDescription = v.VideoDescription }).ToList(); // Vrati sve videe koji su u playlisti Michael Jackson //IEnumerable data = new YoutubeContext().Videos // .Where(v => v.Playlists.Any(p => p.PlaylistName.Contains("Michael Jackson"))) // .Select(v => new VideoModel // { // VideoID = v.VideoID, // VideoTitle = v.VideoTitle, // VideoAuthor = v.VideoAuthor, // VideoDuration = v.VideoDuration, // VideoThumbnail = v.VideoThumbnail // }).ToList(); return(Json(data, JsonRequestBehavior.AllowGet)); }
public void EventListeningTest() { var yc = new YoutubeContext(Url, true) {BaseDirectory = new DirectoryInfo(Path.GetTempPath())}; var ad = new AudioDownloader(yc); var sb = new StringBuilder(); yc.DownloadFailed += (sender, args) => { Debug.WriteLine(args.Subject + "\n" + args.Exception); sb.AppendLine(args.Subject + "\n" + args.Exception); }; yc.ProgresStateChanged += (sender, args) => { if (args.UIHandled || args.Stage != YoutubeStage.ExtractingAudio) return; Debug.Write(args.Precentage.ToString("A###") + " "); sb.Append(args.Precentage.ToString("A###") + " "); args.UIHandled = true; }; yc.ProgresStateChanged += (sender, args) => { if (args.UIHandled || args.Stage != YoutubeStage.Downloading) return; Debug.Write(args.Precentage.ToString("D###") + " "); sb.Append(args.Precentage.ToString("D###") + " "); args.UIHandled = true; }; yc.ProgresStateChanged += (sender, args) => { if (args.UIHandled) return; Debug.Write($"{{{args.Stage.ToString()}}}"); sb.Append($"{{{args.Stage.ToString()}}}"); }; DownloadUrlResolver.FindHighestAudioQualityDownloadUrl(yc); try { ad.Execute(); yc.WaitForThumbnail(); Assert.IsTrue(File.Exists(yc.AudioPath?.FullName ?? "/")); Debug.WriteLine(yc.AudioPath?.FullName ?? ""); } finally { if (yc.AudioPath != null && File.Exists(yc.AudioPath.FullName)) File.Delete(yc.AudioPath.FullName); } var events = Enum.GetValues(typeof(YoutubeStage)).Cast<YoutubeStage>() .Where(s => s != YoutubeStage.DecipheringUrls && s != YoutubeStage.Downloading && s != YoutubeStage.ExtractingAudio && s != YoutubeStage.Undefined ) .Select(ys => $"{{{ys}}}").ToArray(); var c = sb.ToString(); foreach (var @event in events) Assert.IsTrue(c.Contains(@event), $"c.Contains(YoutubeStage.{@event})"); }
public void ContextWithoutThumbnailUPTOSDTest() { var token = new CancellationTokenSource(); var n = new YoutubeContext(uptosd, false); n.ProgresStateChanged += (sender, args) => { if (args.Stage == YoutubeStage.ThumbnailFound) token.Cancel(); }; Task.Delay(5000, token.Token).Wait(token.Token); Assert.IsTrue(n.Thumbnail == "Resources/default.png"); }
public void ContextWithThumbnailUPTOSDTest() { var token = new CancellationTokenSource(); var n = new YoutubeContext(uptosd, true); n.ProgresStateChanged += (sender, args) => { if (args.Stage == YoutubeStage.ThumbnailFound) { token.Cancel(); } }; Task.Delay(15000, token.Token).Wait(token.Token); }
public void ContextToVideoAsync() { var yc = new YoutubeContext(Url) {BaseDirectory = new DirectoryInfo(Path.GetTempPath())}; try { yc.ToVideoAsync(VideoType.Mp4).Wait(); Assert.IsTrue(File.Exists(yc.VideoPath.FullName)); Debug.WriteLine(yc.VideoPath.FullName); } finally { if (yc.VideoPath != null && File.Exists(yc.VideoPath.FullName)) File.Delete(yc.VideoPath.FullName); Assert.IsFalse(File.Exists(yc.VideoPath.FullName)); } }
public void Test_SearchRequest_Save() { var requestService = kernel.Get <ISearchRequestService>(); var searchRequest = fakerRequest.Generate(1).First(); var title = searchRequest.Title; requestService.Save(searchRequest); using (var context = new YoutubeContext()) { var result = context.SearchRequests.Where(r => r.Title == title).First(); result.Should().NotBeNull(); } }
public void Test_SearchStory_Save() { var storyService = kernel.Get <IStoryService>(); var storyDb = fakerStory.Generate(1).First(); var userId = storyDb.UserId; storyService.Save(storyDb); using (var context = new YoutubeContext()) { var result = context.SearchStories.Where(r => r.UserId == userId).First(); result.Should().NotBeNull(); } }
public void Test_SearchStory_GetAllStories() { var storyService = kernel.Get <IStoryService>(); var count = 0; using (var context = new YoutubeContext()) { count = context.SearchStories.Count(); } storyService.Save(fakerStory.Generate(1).First()); storyService.Save(fakerStory.Generate(1).First()); var allStories = storyService.GetAllStories().ToList(); allStories.Should().HaveCount(count + 2); }
public Tablo GetirIdile(int id) { using var context = new YoutubeContext(); return(context.Set <Tablo>().Find(id)); }
public List <Tablo> HepsiniGetir() { using var context = new YoutubeContext(); return(context.Set <Tablo>().ToList()); }
public void Sil(Tablo tablo) { using var context = new YoutubeContext(); context.Set <Tablo>().Remove(tablo); context.SaveChanges(); }
public void Guncelle(Tablo tablo) { using var context = new YoutubeContext(); context.Set <Tablo>().Update(tablo); context.SaveChanges(); }
public UploadedFileRepository(IMapper mapper, YoutubeContext database) { _mapper = mapper; _database = database; }
public List <TEntity> getAll() { using var context = new YoutubeContext(); return(context.Set <TEntity>().OrderByDescending(c => c.Id).ToList()); }
public void UrlDownloadingTest() { var yc = new YoutubeContext(Url) {BaseDirectory = new DirectoryInfo(Path.GetTempPath())}; DownloadUrlResolver.FindHighestAudioQualityDownloadUrl(yc); var ad = new AudioDownloader(yc); try { ad.Execute(); Assert.IsTrue(File.Exists(yc.AudioPath.FullName)); Debug.WriteLine(yc.AudioPath.FullName); } finally { if (yc != null && File.Exists(yc.AudioPath.FullName)) File.Delete(yc.AudioPath.FullName); } }
public void UrlDownloadingFileAlreadyExistsTest() { var yc = new YoutubeContext(Url) {BaseDirectory = new DirectoryInfo(Path.GetTempPath())}; var yc2 = new YoutubeContext(Url) {BaseDirectory = new DirectoryInfo(Path.GetTempPath())}; DownloadUrlResolver.FindHighestAudioQualityDownloadUrlAsync(yc).Wait(); DownloadUrlResolver.FindHighestAudioQualityDownloadUrlAsync(yc2).Wait(); if (yc.VideoInfo.RequiresDecryption) DownloadUrlResolver.DecryptDownloadUrl(yc.VideoInfo); var tf = Path.GetTempPath(); var ad = new AudioDownloader(yc); var ad2 = new AudioDownloader(yc2); try { ad.Execute(); ad2.Execute(); Debug.WriteLine(yc.AudioPath.FullName); Debug.WriteLine(yc2.AudioPath.FullName); Assert.IsTrue(File.Exists(yc.AudioPath.FullName)); Assert.IsTrue(File.Exists(yc2.AudioPath.FullName)); Assert.IsTrue(yc.AudioPath.FullName != yc2.AudioPath.FullName); } finally { if (ad != null && File.Exists(yc.AudioPath.FullName)) File.Delete(yc.AudioPath.FullName); if (ad2 != null && File.Exists(yc2.AudioPath.FullName)) File.Delete(yc2.AudioPath.FullName); } }
public Seeder(YoutubeContext database) { _database = database; }
public void BestAudioQuality() { var url = "https://www.youtube.com/watch?v=cNw8A5pwbVI"; var c = new YoutubeContext(url); DownloadUrlResolver.FindHighestAudioQualityDownloadUrlAsync(c).Wait(); }
public StoryRepository(YoutubeContext ctx) { _context = ctx; }
public SectionRepository(IMapper mapper, YoutubeContext database) { _mapper = mapper; _database = database; }
public CommentRepository(IMapper mapper, YoutubeContext database) { _mapper = mapper; _database = database; }
public SearchRequestsRepository(YoutubeContext ctx) { _context = ctx; }
public ChannelSubscriberRepository(IMapper mapper, YoutubeContext database) { _mapper = mapper; _database = database; }
public VideoRepository(IMapper mapper, YoutubeContext database) { _mapper = mapper; _database = database; }
public VideoRepository(YoutubeContext youtubeContext) { _db = youtubeContext; }
public void Update(TEntity table) { using var context = new YoutubeContext(); context.Set <TEntity>().Update(table); context.SaveChanges(); }
public void Ekle(Tablo tablo) { using var context = new YoutubeContext(); context.Set <Tablo>().Add(tablo); context.SaveChanges(); }
public ChannelRepository(YoutubeContext ctx) { _context = ctx; }
public void GetHighestAudioQualiyBothAsyncTest() { var yc = new YoutubeContext(Url) {BaseDirectory = new DirectoryInfo(Path.GetTempPath())}; DownloadUrlResolver.FindHighestAudioQualityDownloadUrlAsync(yc).Wait(); var highest2task = DownloadUrlResolver.GetHighestAudioQualityDownloadUrlAsync(Url); var highest = DownloadUrlResolver.GetHighestAudioQualityDownloadUrl(Url); var highest2 = highest2task.Result; Assert.AreEqual(yc.VideoInfo, highest); Assert.AreEqual(yc.VideoInfo, highest2); Assert.AreEqual(highest, highest2); Debug.WriteLine(yc.VideoInfo); }
public void GetHighestVideoQualiyBothAsyncTest() { var yc = new YoutubeContext("https://www.youtube.com/watch?v=WlozEc6BxsE") {BaseDirectory = new DirectoryInfo(Path.GetTempPath())}; DownloadUrlResolver.FindHighestVideoQualityDownloadUrlAsync(yc).Wait(); var highest2task = DownloadUrlResolver.GetHighestVideoQualityDownloadUrlAsync("https://www.youtube.com/watch?v=WlozEc6BxsE"); var highest = DownloadUrlResolver.GetHighestVideoQualityDownloadUrl("https://www.youtube.com/watch?v=WlozEc6BxsE"); var highest2 = highest2task.Result; Assert.AreEqual(yc.VideoInfo, highest); Assert.AreEqual(yc.VideoInfo, highest2); Assert.AreEqual(highest, highest2); Debug.WriteLine(yc.VideoInfo); }
public YoutubeService(YoutubeContext ctx) { _context = ctx; }