Exemple #1
0
        [HttpGet]           //use or not works same
        //[ValidateAntiForgeryToken]
        public async Task <string> GetSeasons(int season, string guid, bool isDub)
        {
            var core = CoreHolder.GetCore(guid);

            if (core == null)
            {
                return("");
            }
Exemple #2
0
        [HttpGet]           //use or not works same
        //[ValidateAntiForgeryToken]
        public IActionResult Setup(string guid)
        {
            return(Json(CoreHolder.CheckGuid(guid)));

            /*
             * Guid guid = Guid.NewGuid();
             * cores.Add(guid, new CloudStreamCore());
             * return Json(guid);*/
        }
Exemple #3
0
        [HttpGet]           //use or not works same
        //[ValidateAntiForgeryToken]
        public async Task <string> Search(string search, string guid)
        {
            if (search == null || search == "")
            {
                return("");
            }

            var core = CoreHolder.GetCore(guid);
            await core.QuickSearch(search, blocking : true);

            return(JsonConvert.SerializeObject(core.activeSearchResults.ToArray()));
        }
Exemple #4
0
        [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("");
            }
        }
Exemple #5
0
        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);
            }
        }