asyncyt.utils module

async asyncyt.utils.call_callback(callback, *args, **kwargs)[source]

Call a callback, supporting both coroutine and regular functions.

Parameters:
  • callback – The callback function to call.

  • args – Positional arguments for the callback.

  • kwargs – Keyword arguments for the callback.

asyncyt.utils.clean_youtube_url(url: str) str[source]

Clean any YouTube URL (watch, youtu.be, shorts, embed) into its core form.

Parameters:

url (str) – The youtube URL

Returns:

Cleaned YouTube URL.

asyncyt.utils.get_id(url: str, config: DownloadConfig)[source]

Generate a unique ID for a download based on URL and config.

Parameters:
  • url (str) – Download URL.

  • config (DownloadConfig) – Download configuration.

Returns:

SHA256 hash string.

Return type:

str

asyncyt.utils.get_unique_filename(file: Path, title: str) Path[source]

Generate a unique filename in the same directory, avoiding overwrites.

Parameters:
  • file (Path) – Original file path.

  • title (str) – Desired title for the file.

Returns:

Unique file path.

Return type:

Path

asyncyt.utils.get_unique_path(dir: Path, name: str) Path[source]

Get Unique Path if path exists

Parameters:
  • dir (Path) – The dir of the file

  • name (str) – the Original File name

Returns:

The Unique Path for that dir, for example Videos/Unique Video (2).mp4

Return type:

Path