-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now we're downloading the video, the audio, merging them and uploading to telegram
- Loading branch information
Showing
8 changed files
with
287 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import gleam/list | ||
import gleam/dynamic | ||
import gleam/bytes_builder.{type BytesBuilder} | ||
|
||
@external(erlang, "hackney_multipart", "encode_form") | ||
fn encode_form( | ||
parts: List(dynamic.Dynamic), | ||
boundary: String, | ||
) -> #(BytesBuilder, Int) | ||
|
||
@external(erlang, "hackney_multipart", "boundary") | ||
fn generate_boundary() -> String | ||
|
||
pub type Entry { | ||
File(path: String, name: String, extra_headers: List(#(String, String))) | ||
Text(name: String, value: String) | ||
} | ||
|
||
pub type FormData { | ||
FormData(body: BytesBuilder, length: Int, boundary: String) | ||
} | ||
|
||
pub fn new(parts: List(Entry)) -> FormData { | ||
let boundary = generate_boundary() | ||
|
||
let #(body, length) = | ||
parts | ||
|> list.map(fn(part) { | ||
case part { | ||
File(path, name, extra_headers) -> | ||
dynamic.from(File(path: path, name: name, extra_headers: extra_headers, | ||
)) | ||
Text(name, value) -> dynamic.from(#(name, value)) | ||
} | ||
}) | ||
|> encode_form(boundary) | ||
|
||
FormData(body: body, length: length, boundary: boundary) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.