I am making a Discord music bot with Python, discord.py and yt-dl. Currently I am trying to switch from yt-dl to yt-dlp because of downloading and age restriction issues. With yt-dl, I used to extract an audio files from the playlist this way:
with YoutubeDL(YDL_OPTIONS) as ydl:
info = ydl.extract_info(link, download=False)
if 'entries' in info:
for i in info['entries']:
URL = {'source': i['formats'][0]['url'], 'title': i['title']}
However, with yt-dlp, doing analogically, instead of .m4a audio file links I get .png ones. The code:
with yt_dlp.YoutubeDL(YDL_OPTIONS) as ydl:
info = ydl.extract_info(link, download=False)
if 'entries' in info:
for i in info['entries']:
URL = {'source': i['formats'][0]['url'], 'title': i['title']}
The example of responses:
{'source': 'https://i.ytimg.com/sb/OAJxPrblJVM/storyboard3_L0/default.jpg?sqp=-oaymwENSDfyq4qpAwVwAcABBqLzl_8DBgiliZD6BA==&sigh=rs$AOn4CLBvGbBD6K5s-QiVDyRxUvag_OIPjA', 'title': "La filière technologique: une voie d'avenir pour le ly cée"} {'source': 'https://i.ytimg.com/sb/gOWP6cbdKLk/storyboard3_L0/default.jpg?sqp=-oaymwENSDfyq4qpAwVwAcABBqLzl_8DBgiT2436BA==&sigh=rs$AOn4CLAgYfXSQ0jWHKjwExmWdt1wdP-YUg', 'title': "L'orientation sera au coeur de la réforme du lycée"} {'source': 'https://i.ytimg.com/sb/og4yqREh62c/storyboard3_L0/default.jpg?sqp=-oaymwENSDfyq4qpAwVwAcABBqLzl_8DBgiwkpf6BA==&sigh=rs$AOn4CLBnJodnuCqLQG7iR9pgYsZ5V6S4Qg', 'title': "La réforme du lycée repart de l'écoute des lycéens"}
Also, if I try to extract all the information, I can see the needed audio file link, but I can't understand how to get it. Here's a part of response (the full one is very massive), the necessary link to audio file is marked with bold text:
{'url': 'https:/ /i.ytimg.com/sb/gHqYAn2L24Q/storyboard3_L2/M2.jpg?sqp=-oaymwENSDfyq4qpAwVwAcABBqLzl_8DBgj02_j5BA==&sigh=rs$AOn4CLBkcDmLTu7EN56_U2UM9EQauDaJ-Q', 'duration': 29.307692307692307}], 'audio_ext': 'none', 'video_ext': 'none', 'format': 's b0 - 159x90 (storyboard)', 'resolution': '159x90', 'http_headers': {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.74 Safari/537.36', 'Accept': 'text/html,application /xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': 'en-us,en;q=0.5', 'Sec-Fetch-Mode': 'navigate'}}, {'asr': 22050, 'filesize': 773851, 'format_id': '139', 'format_note': 'low', 'source_preference': -1, 'fps': None, 'au dio_channels': 2, 'height': None, 'quality': 2, 'has_drm': False, 'tbr': 48.831,
'url': 'https://rr2---sn-gvnuxaxjvh-2x1e.googlevideo.com/videoplayback?expire=1667233204&ei=VKFfY5-LDqGZv_IP6Ky5qAk&ip=95.152.62.109&id=o-AEdgltBbtFpm9
toahiKy96P4LXxaNMUl_W3jUcP_TpYP&itag=139&source=youtube&requiressl=yes&mh=jG&mm=31%2C29&mn=sn-gvnuxaxjvh-2x1e%2Csn-gvnuxaxjvh-bvwz&ms=au%2Crdu&mv=m&mvi=2&pl=23&initcwndbps=873750&spc=yR2vp0NTlOub5mskvyfR0I9C6-kv-2A&vprv=1&svpuc=1&mi
me=audio%2Fmp4&gir=yes&clen=773851&otfp=1&dur=126.780&lmt=1580393148840606&mt=1667211200&fvip=15&keepalive=yes&fexp=24001373%2C24007246&c=ANDROID&txp=1311222&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cspc%2Cvprv%2C
svpuc%2Cmime%2Cgir%2Cclen%2Cotfp%2Cdur%2Clmt&sig=AOq0QJ8wRgIhAPC7fHdvLuR_k0wI0v95P6mm8SbYd8hRbGqPhI_GKoP2AiEAoDeEmSq6tUQS74CbcbiONt_emQ8s-7bgiK3tYLqBxJs%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIhAL
Mkx-elSRZ35L4pFDZbsisyh6oUK1FdUZprii24CThuAiBVmFyj1WHj7BRK0iWm_ynTyqioAFfJ7uO50VVbTuz7sg%3D%3D', 'width': None, 'language': '', 'language_preference': -1, 'preference': None, 'ext': 'm4a', 'vcodec': 'none', 'acodec': 'mp4a.40.5', 'd ynamic_range': None, 'abr': 48.831},
How can I solve this? Thanks in advance!