لینکی که بهتون میده باید حتما با فیلتر شکن بازش کنید .
انواع کیفیت ها + فایل های صوتی رو هم در اختیارتون قرار میده..
در اصل این اسکریپت یه web scraper هست.
import requests as rq, json
r = rq.post('https://y2mate.guru/api/convert',
data={'url':'YouTube Url'})
js = json.loads(r.text)
urls = []
n = 0
for i in js['url']:
try:
total = i['filesize']
if (total / 1024) < 1:
size = '{0:.1f}'.format(total) + ' Bytes'
elif (total / 1024) > 1:
if (total / 1024) < 1024:
size = '{0:.1f}'.format(total / 1024) + ' KB'
elif (total / 1024) >= 1024 and (total / 1024) < 1048576:
size = '{0:.1f}'.format(total / 1048576) + ' MB'
else:
size = '{0:.1f}'.format(total / (1048576 * 1024)) + ' GB'
else: size = '1 KB'
print('[%d] '%n+i['name'] + ' / '+ i['subname'] + ' / ' +size)
urls.append(i['url'])
n += 1
except:
pass
a = input('\n[+] Which one ? ')
print('\n'+urls[int(a)])