private IResourceAccessor GetResolvedAccessor(ResourcePath resourcePath) { // Parse slotindex from path and cut the prefix off. int slotIndex; string path = resourcePath.BasePathSegment.Path; if (!Int32.TryParse(path.Substring(0, 1), out slotIndex)) { _logger.Error("SlimTvHandler: Error resolving accessor for path {0}", path); return(null); } path = path.Substring(2, path.Length - 2); //Resolve host first because ffprobe can hang when resolving host var resolvedUrl = UrlHelper.ResolveHostToIPv4Url(path); return(SlimTvResourceProvider.GetResourceAccessor(slotIndex, resolvedUrl)); }
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 }); }