const getDownloadLink = async () => {
$('#result').hide()
const vid_url = $('#link').val()
$('#download').val('Grabbing Link ...')
$('#download').attr('disabled', 'disabled')
$('#bar').show()
const formData = new FormData()
formData.append('url', vid_url)
const response = await fetch('app/main.php', {
method: 'POST',
body: formData
})
const res = await response.json()
if (res.success) {
$('#bar').hide()
$('#result').show()
$('#title').html(res.title)
$('#source').html(`${vid_url}`)
$('#links').html('')
const links = res.links
links !== undefined && Object.keys(links).forEach(function (key) {
$('#links').append(`${key}`)
})
} else {
$('#bar').hide()
alert(res.message)
}
$('#download').val('Download!')
$('#download').removeAttr('disabled')
}