diff --git a/src/SwitchTubeDl/Api/Api.fs b/src/SwitchTubeDl/Api/Api.fs index 3b7bbc5..c20c42a 100644 --- a/src/SwitchTubeDl/Api/Api.fs +++ b/src/SwitchTubeDl/Api/Api.fs @@ -1,7 +1,6 @@ module TubeDl.Api open FsHttp -open FsHttp.DslCE open FsToolkit.ErrorHandling open Microsoft.FSharpLu @@ -29,18 +28,20 @@ let private apiPrefix = $"%s{baseUrl}/api/v1" let private tokenHeader (Token token) = $"Token %s{token}" let private videoDetails token videoId = - httpAsync { + http { GET $"%s{apiPrefix}/browse/videos/%s{videoId}" CacheControl "no-cache" Authorization (tokenHeader token) } + |> Request.sendAsync let private videoPaths token videoId = - httpAsync { + http { GET $"%s{apiPrefix}/browse/videos/%s{videoId}/video_variants" CacheControl "no-cache" Authorization (tokenHeader token) } + |> Request.sendAsync /// The asset path should contain the whole relative path let private downloadVideo _token relativeAssetPath = @@ -48,18 +49,20 @@ let private downloadVideo _token relativeAssetPath = Uri.initRelative baseUrl relativeAssetPath |> Uri.absoluteUri - httpAsync { + http { GET uri CacheControl "no-cache" } + |> Request.sendAsync let private channelDetails token channelId = - httpAsync { + http { GET $"%s{apiPrefix}/browse/channels/%s{channelId}" CacheControl "no-cache" Authorization (tokenHeader token) } + |> Request.sendAsync let private handleResult (response : Response) = match response.statusCode with @@ -72,11 +75,12 @@ let private handleResult (response : Response) = | _ -> Error ApiError let private channelVideos token url = - httpAsync { + http { GET url CacheControl "no-cache" Authorization (tokenHeader token) } + |> Request.sendAsync let allChannelVideos token channelId = let rec collectAllPages accResults nextUrl = diff --git a/src/SwitchTubeDl/Api/Paging.fs b/src/SwitchTubeDl/Api/Paging.fs index 7fd1af4..4b98c1c 100644 --- a/src/SwitchTubeDl/Api/Paging.fs +++ b/src/SwitchTubeDl/Api/Paging.fs @@ -1,6 +1,5 @@ module TubeDl.Paging -open FSharp.Data open Microsoft.FSharpLu open TubeDl @@ -17,7 +16,8 @@ let tryParseLinkHeader (header : string) = let tryGetNextPageUri (headers : System.Net.Http.Headers.HttpResponseHeaders) = let headerOpt = - match headers.TryGetValues HttpResponseHeaders.Link with + let linkHeader = "Link" + match headers.TryGetValues linkHeader with | true, value -> value |> Seq.head |> Some | _ -> None diff --git a/src/SwitchTubeDl/SwitchTubeDl.fsproj b/src/SwitchTubeDl/SwitchTubeDl.fsproj index acd6e49..cd2d795 100644 --- a/src/SwitchTubeDl/SwitchTubeDl.fsproj +++ b/src/SwitchTubeDl/SwitchTubeDl.fsproj @@ -55,7 +55,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -70,11 +70,12 @@ - + - + + diff --git a/src/Tests/Tests.fsproj b/src/Tests/Tests.fsproj index 62cb9d0..bfd49b7 100644 --- a/src/Tests/Tests.fsproj +++ b/src/Tests/Tests.fsproj @@ -23,6 +23,7 @@ +