Exyt (exyt_dlp v0.1.4)

Documentation for Exyt. Wrapper / helper to download media from YT

Summary

Functions

check_setup

Downloads a media file from a valid YouTube URL.

Retrieves the description of a media file from the given URL.

Retrieves the duration of a media file from the given URL.

Retrieves the filename of a media file from the given URL.

Retrieves the format of a media file from the given URL.

Retrieves the ID of a media file from the given URL.

Retrieves the thumbnail URL of a media file from the given URL.

Retrieves the title of a media file from the given URL.

Retrieves the media URL from the given URL.

Checks if a URL string is valid.

Validates a URL string to check if it's a valid YouTube URL.

call ytdlp with custom params

Functions

check_setup

Examples

iex> Exyt.check_setup()
Link to this function

download(url, opts \\ [], async \\ false)

Downloads a media file from a valid YouTube URL.

Parameters

`url` (string): A valid YouTube URL.
`opts` (list): YT-DLP default arguments.
`async` (boolean): If true, download will be executed in background. Default is false.

Examples

iex> url = "https://www.youtube.com/watch?v=BaW_jenozKc"
iex> options = ["format=mp4", "output=video.mp4"]
iex> Exyt.download(url, options, true)
iex> {:ok, _pid} = Exyt.download(url, options, true)
iex> {:ok, _filename} = Exyt.download(url, options, false)

Returns

A tuple with two elements:
- `:status_request` (atom): The status of the request (:ok or :error).
- `:string_media_filename` (string): The filename of the media file. |  PID of async downloading task
Link to this function

get_description(url)

Retrieves the description of a media file from the given URL.

Parameters

`url` (string): A URL string pointing to a media file.

Returns

A tuple with two elements:
- `:status_request` (atom): The status of the request (:ok or :error).
- `:string_media_description` (string): The description of the media file.

Examples

iex> url = "https://www.youtube.com/watch?v=BaW_jenozKc"
iex> Exyt.get_description(url)
Link to this function

get_duration(url)

Retrieves the duration of a media file from the given URL.

Parameters

`url` (string): A URL string pointing to a media file.

Returns

A tuple with two elements:
- `:status_request` (atom): The status of the request (:ok or :error).
- `:duration_in_seconds` (number): The duration of the media file in seconds.

Examples

iex> url = "https://www.youtube.com/watch?v=BaW_jenozKc"
iex> Exyt.get_duration(url)
Link to this function

get_filename(url)

Retrieves the filename of a media file from the given URL.

Parameters

`url` (string): A URL string pointing to a media file.

Returns

A tuple with two elements:
- `:status_request` (atom): The status of the request (:ok or :error).
- `:string_media_filename` (string): The filename of the media file.

Examples

iex> url = "https://www.youtube.com/watch?v=BaW_jenozKc"
iex> Exyt.get_filename(url)
Link to this function

get_format(url)

Retrieves the format of a media file from the given URL.

Parameters

`url` (string): A URL string pointing to a media file.

Returns

A tuple with two elements:
- `:status_request` (atom): The status of the request (:ok or :error).
- `:string_media_format` (string): The format of the media file.

Examples

iex> url = "https://www.youtube.com/watch?v=BaW_jenozKc"
iex> Exyt.get_format(url)

Retrieves the ID of a media file from the given URL.

Parameters

`url` (string): A URL string pointing to a media file.

Returns

A tuple with two elements:
- `:status_request` (atom): The status of the request (:ok or :error).
- `:string_media_id` (string): The ID of the media file.

Examples

iex> url = "https://www.youtube.com/watch?v=BaW_jenozKc"
iex> Exyt.get_id(url)
Link to this function

get_thumbnail(url)

Retrieves the thumbnail URL of a media file from the given URL.

Parameters

`url` (string): A URL string pointing to a media file.

Returns

A tuple with two elements:
- `:status_request` (atom): The status of the request (:ok or :error).
- `:string_thumbnail_url` (string): The URL of the media file's thumbnail.

Examples

iex> url = "https://www.youtube.com/watch?v=BaW_jenozKc"
iex> Exyt.get_thumbnail(url)

Retrieves the title of a media file from the given URL.

Parameters

`url` (string): A URL string pointing to a media file.

Returns

A tuple with two elements:
- `:status_request` (atom): The status of the request (:ok or :error).
- `:string_media_title` (string): The title of the media file.

Examples

iex> url = "https://www.youtube.com/watch?v=BaW_jenozKc"
iex> Exyt.get_title(url)

Retrieves the media URL from the given URL.

Parameters

`url` (string): A URL string pointing to a media file.

Returns

A tuple with two elements:
- `:status_request` (atom): The status of the request (:ok or :error).
- `:string_media_url` (string): The URL of the media file.

Examples

iex> url = "https://www.youtube.com/watch?v=BaW_jenozKc"
iex> Exyt.get_url(url)
Link to this function

is_valid_url?(url)

Checks if a URL string is valid.

Parameters

`url` (string): A URL string to be checked for validity.

Returns

A boolean indicating whether the URL is valid (true) or not (false).

Examples

iex> valid_url = "https://www.youtube.com/watch?v=BaW_jenozKc"
iex> Exyt.is_valid_url?(valid_url)
true
Link to this function

list_formats(url)

Link to this function

validate_url(url)

Validates a URL string to check if it's a valid YouTube URL.

Parameters

-`url` (string): A URL string to be validated.

Returns

A tuple representing the validation result:
  • {:ok, valid_url} (tuple): If the URL is a valid YouTube URL.
  • {:error, :invalid_youtube_url} (tuple): If the URL is not a valid YouTube URL.

Examples

iex> url = "https://www.youtube.com/watch?v=BaW_jenozKc"
iex> Exyt.validate_url(url)
Link to this function

ytdlp(params, url)

call ytdlp with custom params

Examples

iex> Exyt.ytdlp(["--get-filename"], "https://www.youtube.com/watch?v=BaW_jenozKc")