public List <CloudStreamCore.BasicLink> GetBasicLinks() { var val = CloudStreamCore.GetCachedLink(IMDBEpisodeId); if (val == null) { return(new List <CloudStreamCore.BasicLink>()); } if (val.Value.links.Count == 0) { return(new List <CloudStreamCore.BasicLink>()); } return(val.Value.links.OrderBy(t => - t.priority).ToList()); }
[HttpGet] //use or not works same //[ValidateAntiForgeryToken] public async Task <string> GetLoadLinks(int episode, int season, int delay, string guid, bool isDub, bool reloadAllLinks) { try { error("TRYLOAD"); var core = CoreHolder.GetCore(guid); if (core == null) { return(""); } const int maxDelay = 60000; if (delay > maxDelay) { delay = maxDelay; } int normalEpisode = episode == -1 ? 0 : episode - 1; bool isMovie = core.activeMovie.title.IsMovie; string id = isMovie ? core.activeMovie.title.id : core.activeMovie.episodes[normalEpisode].id; if (delay > 0) { if (reloadAllLinks) { CloudStreamCore.ClearCachedLink(id); } core.GetEpisodeLink(episode, season, isDub: isDub); await Task.Delay(delay); } if (core.activeMovie.episodes == null && !isMovie) { return(""); } var _link = CloudStreamCore.GetCachedLink(id).Copy(); if (_link.HasValue) { var json = JsonConvert.SerializeObject(_link); return(json); } else { return("no links"); } } catch { return(""); } }
public async Task <string> LoadPlayer(int episode, string player, string guid) { try { await Task.Delay(100); if (!CloudStreamElectron.Startup.isElectron) { return("is not electron"); } var core = CoreHolder.GetCore(guid); if (core == null) { return("invalid core"); } int normalEpisode = episode == -1 ? 0 : episode - 1; bool isMovie = core.activeMovie.title.IsMovie; var cEpisode = core.activeMovie.episodes[normalEpisode]; string id = isMovie ? core.activeMovie.title.id : cEpisode.id; var _link = CloudStreamCore.GetCachedLink(id).Copy(); if (_link == null) { return("no links"); } var endPath = Path.Combine(Directory.GetCurrentDirectory(), baseM3u8Name); if (System.IO.File.Exists(endPath)) { System.IO.File.Delete(endPath); } var links = _link.Value.links.Where(t => !t.isAdvancedLink); System.IO.File.WriteAllText(endPath, ConvertPathAndNameToM3U8(links.Select(t => t.baseUrl).ToList(), links.Select(t => t.PublicName).ToList())); string argu = ""; if (player == "vlc") { argu = $"--fullscreen --no-loop vlc://quit"; } else if (player == "mpv") { argu = $"--title=\"{(isMovie ? core.activeMovie.title.name : cEpisode.name)}\""; } if (IsLinux) { $"{player} \"{endPath}\" {argu}".Bash(false); } else if (IsWindows) { if (player == "mpv") { //$"{player} \"{endPath}\" {argu}".Cmd(); $"\"{endPath}\" {argu}".CmdCommand(@"mpv.exe"); } else if (player == "vlc") { $"\"{endPath}\" {argu}".CmdCommand(@"C:\Program Files\VideoLAN\VLC\vlc.exe"); } } return("true"); } catch (Exception _ex) { error(_ex); return(_ex.Message); } }