#ifndef YTMDL_DOWNLOADER_H
#define YTMDL_DOWNLOADER_H
#include <stddef.h>
#define DL_ERROR_CAP 1024
typedef void (*entry_cb_t)(void *user_data, const char *url, const char *title);
typedef void (*progress_cb_t)(void *user_data, float percent, const char *speed, const char *eta);
/* Expands a video/playlist/album URL. Calls on_entry once per downloadable
* item (in order) and, if it's a playlist/album, writes its title into
* playlist_title (playlist_title[0] == '\0' for a single video).
* Returns 0 on success, -1 on failure (err filled with a message). */
int downloader_resolve(const char *url, entry_cb_t on_entry, void *user_data,
char *playlist_title, size_t playlist_title_cap,
char *err, size_t err_cap);
/* Downloads a single URL as an audio file with embedded thumbnail/metadata
* into output_dir (created if needed). Calls cb with progress updates.
* Returns 0 on success, -1 on failure (err filled with a message). */
int downloader_download(const char *url, const char *output_dir, const char *audio_format,
progress_cb_t cb, void *user_data,
char *err, size_t err_cap);
#endif