Exyt (exyt_dlp v0.1.5)

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

Summary

Functions

check_setup

Downloads a media file from a valid YouTube URL.

Downloads asyncronously 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.

Retrieves the list of available formats of a media file from the given URL.

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 \\ [])

Downloads a media file from a valid YouTube URL.

Parameters

`url` (string): A valid YouTube URL.
`opts` (list): YT-DLP default arguments.

Examples

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

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.
Link to this function

download(url, opts, atom)

Downloads asyncronously a media file from a valid YouTube URL.

Parameters

`url` (string): A valid YouTube URL.
`opts` (list): YT-DLP default arguments.
`:async`(atom): Asynchronous downloading

Examples

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

Returns

A tuple with two elements:
- `:status_request` (atom): The status of the request (:ok or :error).
- `PID` (PID): The 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)

Retrieves the list of available formats of a media file from the given URL.

## Parameters

 `url` (string): A valid YouTube URL.

## Returns

 A tuple with two elements:
 - `:status_request` (atom): The status of the request (:ok or :error).
 - `:list_of_formats` (list): Formatted stdout  from `yt-dlp --list-formats` into a list. 
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")