//private async void downloadItem(LanguageInfo item, string path) //{ // this.Invoke(new Action(() => // { // btn_DirectDownload.Text = "Stop"; // btn_DirectDownload.ForeColor = Color.Red; // })); // cancelationToken.Reset(); // string url = await item.FetchVideoUrl(downloadInfo); // if (!string.IsNullOrEmpty(url)) // { // this.Invoke(new Action(() => // { // txtB_DirectUrl.Text = url; // txtB_HosterUrl.Text = item.Video_URL; // })); // var filename = await item.CreateFileName(); // await SeriesLoader.DownloadThreaded(path, filename, url, cancelationToken, downloadInfo); // var fpath = Path.GetFullPath(Path.Combine(path, filename)); // var apath = Path.GetFullPath(Path.Combine(path, filename + ".aria2")); // if (File.Exists(fpath) && !File.Exists(apath)) // { // item.FilePath = fpath; // } // else // { // item.FilePath = string.Empty; // } // item.Hoster.Episode.Season.Series.Save(); // } // this.Invoke(new Action(() => // { // btn_DirectDownload.Text = "Download"; // btn_DirectDownload.ForeColor = Color.White; // })); // downloadInfo(); //} private async void FetchNewEpisode(SeriesInfo seriesInfo) { try { var seas = seriesInfo.Seasons[seriesInfo.Seasons.Max(t => t.Key)]; var eps = await SeriesLoader.GetNewestEpisodeInfo(seas, downloadInfo); if (eps.Count > 0) { foreach (var ep in eps) { ep.Season = seas; seas.Episodes.Add(ep); } seas.Series.Save(); this.Invoke(new Action(() => { cBL_Series.SelectedIndex = -1; cBL_Series.SelectedIndex = cBL_Series.Items.Cast<SeriesInfo>().ToList().FindIndex(t => t.URL.Equals(seas.URL)); MessageBox.Show("Added " + eps.Count + "Episode" + (eps.Count == 1 ? "" : "s to ") + seas.Series.Title + "."); })); } } catch (Exception x) { } }
private async void lstB_Series_SelectedIndexChanged_1(object sender, EventArgs e) { try { if (((ListBox)sender).SelectedIndex >= 0) { var item = (SearchResult)((ListBox)sender).SelectedItem; if (string.IsNullOrEmpty(item.Cover)) { item.Cover = await SeriesLoader.GetSeriesCover(item.Link); } btn_Add.Enabled = true; var descr = await item.Description; var html = "<style>a{color: white;} body{background-color: black; color: white;}</style><html><body>" + "<h2>" + Enum.GetName(typeof(SiteType), item.Site).Trim('_') + "</h2>" + "<img src=\"" + item.Cover + "\" height=\"300\" alt=\"Cover\"><br>" + descr.Replace("Watch now!", "").Replace("h1", "h2").Replace("<div class=\"preview\">Preview</div>", "") + "<br>" + "<a href=\"" + item.Link + "\">" + item.Link + "</a>" + "</body></html>"; BrowserSetHtml(html); } else { btn_Add.Enabled = false; } } catch (Exception x) { MessageBox.Show(x.ToString()); } }
private async void bt_Fetch_Click(object sender, EventArgs e) { try { if (txtB_Url.Text.Contains("://s.to") || txtB_Url.Text.Contains("9anime.to")) { var url = new Uri(txtB_Url.Text); var selser = SavedSeries.FirstOrDefault(t => t.Value.URL.Contains(url.AbsolutePath)).Value; var si = await SeriesLoader.GetSeriesInfo(txtB_Url.Text, downloadInfo, selser); dlPercentage = -1; if (SavedSeries.ContainsKey(si.URL)) { SavedSeries[si.URL] = si; } else { SavedSeries.Add(si.URL, si); cBL_Series.Items.Add(si); } si.Save(); cBL_Series.SelectedIndex = -1; cBL_Series.SelectedIndex = cBL_Series.Items.Cast<SeriesInfo>().ToList().FindIndex(t => t.URL.Equals(si.URL)); } } catch (Exception x) { } }
private void downloadInternal(string url, string path, string filename, MultiDownloader multiDownloader) { p = new LixProcess(); p.StartInfo.Arguments = " -d \"" + path + "\"" + (string.IsNullOrEmpty(filename) ? "" : " -o \"" + filename + "\"") + " -c" + //" --enable-rpc=true" + " --file-allocation=none" + //" -j" + Download_Connections + " -x" + multiDownloader.Download_Connections + " -s" + multiDownloader.Download_Connections + " -k10M" + " \"" + url + "\""; p.StartInfo.FileName = "aria2c.exe"; p.StartInfo.CreateNoWindow = true; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; //p.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; p.Start(); while (!p.StandardOutput.EndOfStream) { if (multiDownloader.IsStopped) { SeriesLoader.KillProcessAndChildrens(p.Id); break; } try { var ps = p.StandardOutput.ReadLine(); if (!string.IsNullOrWhiteSpace(ps)) { ps = ps.Trim(); int.TryParse(ps.GetBetweenN("(", "%)"), out int perc); CurrentSize = (long)convert(ps.GetBetweenN(" ", "/")); FullSize = (long)convert(ps.GetBetweenN("/", "(")); Speed = (long)convert(ps.GetBetween("DL", " ")); if (perc > 0) { Percentage = perc; } if (!ps.StartsWith("-")) { DownloadInfo = (ps.Contains("#") ? ("[" + ps.Substring(ps.IndexOf(" ", ps.IndexOf("#")) + 1)) : ps); } } } catch (Exception x) { } } }
public void Stop() { if (IsSuccess) { IsFinished = true; } IsRunning = false; if (p != null) { SeriesLoader.KillProcessAndChildrens(p.Id); } }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { try { foreach (var kvp in SavedSeries) { kvp.Value.Save(); } } catch { } SeriesLoader.Dispose(); }
private async void tSMi_FetchAllEpisodes_Click(object sender, EventArgs e) { try { if (SelectedSeries.SiteType != SiteType._9Anime) { MessageBox.Show("This feature only works with 9Anime.to!"); return; } var items = cBL_Episodes.Items.Cast<EpisodeInfo>(); cancelationToken.Reset(); int i = 1; int length = items.Count(); await Task.Run(() => { cancelationToken.Reset(true); Parallel.ForEach(items, (item, loopstate) => { if (cancelationToken.IsStopped) loopstate.Break(); var lang = item.GetBest().GetBest(); if (lang.HasVideo == VideoType.None) { var url = SeriesLoader.FetchUrl(lang).Result; if (!string.IsNullOrEmpty(url)) { lang.Video_URL = url; item.GetName().Wait(); } } else { item.GetName().Wait(); } downloadInfo(i, i + "/" + length, item.Name, length); i++; }); }); items.First().Season.Series.Save(); downloadInfo(); cBL_Episodes.Refresh(); } catch (Exception x) { } finally { cancelationToken.Reset(); } }
private async void button2_Click(object sender, EventArgs e) { try { if (cancelationToken.IsRunning) { cancelationToken.Stop(); } else if (cBL_Languages.SelectedItem is LanguageInfo lang) { if (lang.HasVideo == VideoType.None) { var url = await SeriesLoader.FetchUrl(lang); if (!string.IsNullOrEmpty(url)) { await lang.Hoster.Episode.GetName(); txtB_HosterUrl.Text = url; txtB_DirectUrl.Text = url; lang.Hoster.Episode.Season.Series.Save(); btn_FetchVideo.ForeColor = Color.LimeGreen; btn_FetchVideo.Text = "Play Video"; cBL_Episodes.Refresh(); cBL_Hoster.Refresh(); cBL_Languages.Refresh(); } else { MessageBox.Show("Couldn't fetch Video-URL, please try another Hoster."); } } else { if (await lang.Play(cancelationToken, downloadInfo)) { cBL_Episodes.Refresh(); } else { MessageBox.Show("Couldn't fetch Video-URL, please try another Hoster."); } } } } catch (Exception x) { MessageBox.Show(x.ToString()); } }
private void CBL_DrawItem(object sender, DrawItemEventArgs e) { try { if (e.Index < 0) return; var lstbox = ((ListBox)sender); var item = (BaseInfo)lstbox.Items[e.Index]; var rect = new Rectangle(0, e.Bounds.Y, lstbox.Width, e.Bounds.Height); using (var sb = new SolidBrush(e.BackColor)) { e.Graphics.FillRectangle(sb, rect); } if (item.Index != null) { var inds = ((int)item.Index).ToString("00") + ": "; var size = TextRenderer.MeasureText(inds, e.Font); TextRenderer.DrawText(e.Graphics, inds, e.Font, new Point(rect.X, rect.Y), e.ForeColor, TextFormatFlags.Left | TextFormatFlags.NoPadding); rect.X += size.Width - 8; } var str = SeriesLoader.GetVideoTypeIcon(item.HasVideo); if (!string.IsNullOrEmpty(str)) { using (var font = new Font(e.Font.FontFamily, 18)) { var size = TextRenderer.MeasureText(str, font); TextRenderer.DrawText(e.Graphics, str, font, new Point(rect.X, rect.Y - 5), e.ForeColor, TextFormatFlags.Left | TextFormatFlags.NoPadding); rect.X += size.Width - 10; } } if (item.IsViewed != null && (bool)item.IsViewed) { using (var font1 = new Font(e.Font.FontFamily, 23)) { var size = TextRenderer.MeasureText("👁", font1); TextRenderer.DrawText(e.Graphics, "👁", font1, new Point(rect.X - 5, rect.Y - 11), e.ForeColor, TextFormatFlags.Left | TextFormatFlags.NoPadding); rect.X += size.Width - 20; } } TextRenderer.DrawText(e.Graphics, item.ToString(), e.Font, new Point(rect.X, rect.Y), e.ForeColor, TextFormatFlags.Left | TextFormatFlags.NoPadding); } catch { } }