public static bool RefreshLink(DownloadItemBase item, IRefreshLinkDialog dialog) { try { if (item.DownloadType != "Http" && item.DownloadType != "Dash") { return(false); } string?referer = null; if (item.DownloadType == "Http") { var state = DownloadStateIO.LoadSingleSourceHTTPDownloaderState(item.Id); referer = GetReferer(state.Headers); } else if (item.DownloadType == "Dash") { var state = DownloadStateIO.LoadDualSourceHTTPDownloaderState(item.Id); referer = GetReferer(state.Headers1); } else { return(false); } Log.Debug("Referer: " + referer); if (referer != null) { dialog.WatchingStopped += (a, b) => { ApplicationContext.LinkRefresher.ClearWatchList(); }; OpenBrowser(referer); if (item.DownloadType == "Http") { var downloader = new SingleSourceHTTPDownloader(item.Id); downloader.RestoreState(); ApplicationContext.LinkRefresher.RefreshedLinkReceived += (_, _) => dialog.LinkReceived(); ApplicationContext.LinkRefresher.AddToWatchList(downloader); } else if (item.DownloadType == "Dash") { var downloader = new DualSourceHTTPDownloader(item.Id); downloader.RestoreState(); ApplicationContext.LinkRefresher.RefreshedLinkReceived += (_, _) => dialog.LinkReceived(); ApplicationContext.LinkRefresher.AddToWatchList(downloader); } dialog.ShowWindow(); return(true); } } catch (Exception e) { Log.Debug(e, e.Message); } return(false); }
protected override void SaveState() { DownloadStateIO.Save((MultiSourceDASHDownloadState)_state); //TransactedIO.WriteBytes(DownloadStateStore.Save((MultiSourceDASHDownloadState)_state), Id + ".state", Config.DataDir); //TransactedIO.Write(JsonConvert.SerializeObject(_state as MultiSourceDASHDownloadState), // Id + ".state", Config.DataDir); //File.WriteAllText(Path.Combine(Config.DataDir, Id + ".state"), // JsonConvert.SerializeObject(_state as MultiSourceDASHDownloadState)); SaveChunkState(); }
protected override void SaveState() { DownloadStateIO.Save(state);// TransactedIO.WriteBytes(DownloadStateStore.Save(state), Id + ".state", Config.DataDir); }
protected override void SaveState() { DownloadStateIO.Save((MultiSourceHLSDownloadState)this._state); }
public static void ShowSeletectedItemProperties() { DownloadItemBase?ent = null; if (ApplicationContext.MainWindow.IsInProgressViewSelected) { var rows = ApplicationContext.MainWindow.SelectedInProgressRows; if (rows.Count > 0) { ent = rows[0].DownloadEntry; } } else { var rows = ApplicationContext.MainWindow.SelectedFinishedRows; if (rows.Count > 0) { ent = rows[0].DownloadEntry; } } if (ent == null) { return; } ShortState?state = null; try { switch (ent.DownloadType) { case "Http": var s = DownloadStateIO.LoadSingleSourceHTTPDownloaderState(ent.Id); state = new() { Headers = s.Headers, Cookies = s.Cookies }; break; case "Dash": var d = DownloadStateIO.LoadDualSourceHTTPDownloaderState(ent.Id); state = new() { Headers1 = d.Headers1, Headers2 = d.Headers2, Cookies2 = d.Cookies2, Cookies1 = d.Cookies1 }; break; case "Hls": var h = DownloadStateIO.LoadMultiSourceHLSDownloadState(ent.Id); state = new() { Headers = h.Headers, Cookies = h.Cookies }; break; case "Mpd-Dash": var m = DownloadStateIO.LoadMultiSourceDASHDownloadState(ent.Id); state = new() { Headers = m.Headers, Cookies = m.Cookies }; break; } } catch { } ApplicationContext.PlatformUIService.ShowPropertiesDialog(ent, state); }