示例#1
0
        public static async Task <WebBoolResult> ProcessAsync(IOwinContext context, string userName)
        {
            if (!ServiceRegistration.IsRegistered <ITvProvider>())
            {
                throw new BadRequestException("CancelCurrentTimeShifting: ITvProvider not found");
            }

            if (userName == null)
            {
                throw new BadRequestException("CancelCurrentTimeShifting: userName is null");
            }

            int channelId = -1;

            if (userName.Contains("-"))
            {
                string channel = userName.Substring(userName.LastIndexOf("-") + 1);
                if (int.TryParse(channel, out channelId))
                {
                    userName = userName.Substring(0, userName.LastIndexOf("-")); //Channel needs to be removed
                }
            }

            bool result = await TVAccess.StopTimeshiftAsync(context, channelId, userName);

            return(new WebBoolResult {
                Result = result
            });
        }
        public static async Task <WebStringResult> ProcessAsync(IOwinContext context, string userName, string channelId)
        {
            if (!ServiceRegistration.IsRegistered <ITvProvider>())
            {
                throw new BadRequestException("SwitchTVServerToChannelAndGetTimeshiftFilename: ITvProvider not found");
            }

            if (userName == null)
            {
                throw new BadRequestException("SwitchTVServerToChannelAndGetTimeshiftFilename: userName is null");
            }

            var item = await TVAccess.StartTimeshiftAsync(context, int.Parse(channelId), userName);

            if (item == null)
            {
                throw new BadRequestException("SwitchTVServerToChannelAndGetTimeshiftFilename: Couldn't start timeshifting");
            }

            string resourcePathStr = item.PrimaryProviderResourcePath();
            var    resourcePath    = ResourcePath.Deserialize(resourcePathStr);
            var    stra            = SlimTvResourceProvider.GetResourceAccessor(resourcePath.BasePathSegment.Path);
            string url             = "";

            if (stra is ILocalFsResourceAccessor)
            {
                url = ((ILocalFsResourceAccessor)stra).LocalFileSystemPath;
            }
            else
            {
                await TVAccess.StopTimeshiftAsync(context, int.Parse(channelId), userName);
            }

            return(new WebStringResult {
                Result = url
            });
        }