private bool DownloadVidstream(HentaiVideo video) { if (ao.stream) { startStreamServer(); } WebClient webC = new WebClient(); webC.Headers = headersCollection; if (video.slug.IsMp4() == true) { updateStatus(taskIndex, $"Downloading MP4 {video.slug}"); webC.DownloadProgressChanged += WebC_DownloadProgressChanged; webC.DownloadFile(video.slug, $"{downloadTo}\\{video.name}.mp4"); updateStatus(taskIndex, $"Finished Downloading: {video.slug}, [##########] 100%"); return(true); } else { M3U m3 = new M3U(webC.DownloadString(video.slug), headersCollection, video.slug.TrimToSlash()); int l = m3.Size; double prg = (double)m3.location / (double)l; Byte[] b; while ((b = m3.getNext()) != null) { if (ao.stream) { publishToStream(b); } updateStatus(taskIndex, $"{video.name} {Strings.calculateProgress('#', m3.location, l)}"); mergeToMain($"{downloadTo}\\{video.name}.mp4", b); } } return(true); }
public override bool Download(string path, bool mt, bool continuos) { GetDownloadUri(videoInfo == null ? new HentaiVideo { slug = path } : videoInfo.hentai_video); if (!ao.l) { downloadTo = $"{Directory.GetCurrentDirectory()}{Path.DirectorySeparatorChar}HAnime{Path.DirectorySeparatorChar}{videoInfo.hentai_video.name.TrimIntegrals()}{Path.DirectorySeparatorChar}"; } else if (ao.android) { downloadTo = Path.Combine(ao.export, "HAnime", videoInfo.hentai_video.name.TrimIntegrals()); } else { downloadTo = Path.Combine(ao.export, videoInfo.hentai_video.brand); } Directory.CreateDirectory(downloadTo); M3U m3 = new M3U(webClient.DownloadString(rootObj.linkToManifest)); Byte[] b; int l = m3.Size; double prg; updateStatus?.Invoke(taskIndex, $"Beginning download of {videoInfo.hentai_video.name}"); ADLUpdates.CallLogUpdate($"Beginning download of {videoInfo.hentai_video.name}"); if (ao.stream) { startStreamServer(); while ((b = m3.getNext()) != null) { if (allStop) { invoker(); return(false); } updateStatus?.Invoke(taskIndex, $"{videoInfo.hentai_video.name} {Strings.calculateProgress('#', m3.location, l)}"); ADLUpdates.CallLogUpdate($"{videoInfo.hentai_video.name} {Strings.calculateProgress('#', m3.location, l)}"); publishToStream(b); mergeToMain(downloadTo + Path.DirectorySeparatorChar + videoInfo.hentai_video.name + ".mp4", b); } } else { while ((b = m3.getNext()) != null) { if (allStop) { invoker(); return(false); } prg = (double)m3.location / (double)l; updateStatus?.Invoke(taskIndex, $"{videoInfo.hentai_video.name} {Strings.calculateProgress('#', m3.location, l)}"); ADLUpdates.CallLogUpdate($"{videoInfo.hentai_video.name} {Strings.calculateProgress('#', m3.location, l)}"); mergeToMain(downloadTo + Path.DirectorySeparatorChar + videoInfo.hentai_video.name + ".mp4", b); } } if (continuos && videoInfo.next_hentai_video.name.RemoveSpecialCharacters().TrimIntegrals() == videoInfo.hentai_video.name.TrimIntegrals()) { HAnime h = new HAnime(new argumentList { term = $"https://hanime.tv/videos/hentai/{videoInfo.next_hentai_video.slug}", mt = mt, export = downloadTo, cc = continuos }, taskIndex, updateStatus); h.Begin(); } return(true); }
private bool DownloadVidstream(HentaiVideo video) { if (ao.stream) { startStreamServer(); } WebClient webC = new WebClient(); webC.Headers = headersCollection; if (video.slug.IsMp4() == true) { M3UMP4_SETTINGS m3set = new M3UMP4_SETTINGS { Host = string.Empty, Headers = headersCollection, Referer = string.Empty }; headersCollection.Add("Accept-Encoding", "gzip, deflate, br"); if (File.Exists($"{downloadTo}\\{video.name}.mp4")) { m3set.location = File.ReadAllBytes($"{downloadTo}\\{video.name}.mp4").Length; } M3U m3 = new M3U(video.slug, null, null, true, m3set); int l = m3.Size; double prg = (double)m3.location / (double)l; Byte[] b; while ((b = m3.getNext()) != null) { if (ao.stream) { publishToStream(b); } updateStatus?.Invoke(taskIndex, $"{video.name} {Strings.calculateProgress('#', m3.location, l)}"); mergeToMain($"{downloadTo}{Path.DirectorySeparatorChar}{video.name}.mp4", b); } return(true); } else { MatchCollection mc = Regex.Matches(webC.DownloadString(video.slug), @"(sub\..*?\..*?\.m3u8)|(ep\..*?\..*?\.m3u8)"); video.slug = $"{video.slug.TrimToSlash()}{GetHighestRes(mc.GetEnumerator())}"; if (ao.c && File.Exists($"{downloadTo}\\{video.name}.mp4")) { return(true); } M3U m3 = new M3U(webC.DownloadString(video.slug), headersCollection, video.slug.TrimToSlash()); int l = m3.Size; double prg = (double)m3.location / (double)l; Byte[] b; while ((b = m3.getNext()) != null) { if (ao.stream) { publishToStream(b); } updateStatus?.Invoke(taskIndex, $"{video.name} {Strings.calculateProgress('#', m3.location, l)}"); mergeToMain($"{downloadTo}{Path.DirectorySeparatorChar}{video.name}.mp4", b); } } return(true); }