take() {
    local -r directory=$1
    mkdir -p "${directory}"
    cd "${directory}"
}

# downloading from youtube
yt-dlp() {
    local -a -r args=(
        --cookies-from-browser "chromium:${HOME}/.local/share/qutebrowser"
        --extractor-args "youtube:player_client=default,web_safari;player_js_version=actual"
        --fragment-retries infinite
    )
    command yt-dlp "${args[@]}" "$@"
}

yt_dl_mp3() {
    yt-dlp -t mp3 --embed-thumbnail "$@"
}

yt_dl_channel() {
    local -a -r args=(
        --download-archive "archive.txt"
        --output "%(upload_date)s.%(title)s.%(id)s.%(ext)s"
        --merge-output-format mkv
        --ignore-errors
        --write-sub
        --sub-langs "en,pl"
        --cookies-from-browser "chromium:${HOME}/.local/share/qutebrowser"
        --write-description
        --write-info-json
        --write-thumbnail
    )
    yt-dlp "${args[@]}" "$@"
}
