Skip to content

Commit 0654f83

Browse files
committed
fix: playlist parsing
1 parent 86706ad commit 0654f83

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

core/funcs.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
import math
2222
import time
2323
import random
24+
import yt_dlp
2425
import aiohttp
2526
import asyncio
2627
import aiofiles
2728
from config import config
2829
from core.song import Song
2930
from pyrogram import enums
30-
from pytube import Playlist
3131
from spotipy import Spotify
3232
from core.groups import get_group
3333
from pyrogram.types import Message
@@ -297,11 +297,21 @@ async def special_to_normal(ctitle):
297297

298298

299299
async def get_youtube_playlist(pl_url: str, message: Message) -> AsyncIterator[Song]:
300-
pl = Playlist(pl_url)
301-
for i in range(len(list(pl))):
302-
song = Song(pl[i], message)
303-
song.title = pl.videos[i].title
304-
yield song
300+
ydl_opts = {
301+
'extract_flat': True,
302+
'skip_download': True,
303+
'quiet': True,
304+
'ignoreerrors': True,
305+
}
306+
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
307+
info = ydl.extract_info(pl_url, download=False)
308+
309+
if info and 'entries' in info:
310+
for entry in info['entries']:
311+
if entry and entry.get('url'):
312+
song = Song(entry['url'], message)
313+
song.title = entry.get('title', 'Unknown Title')
314+
yield song
305315

306316

307317
async def get_spotify_playlist(pl_url: str, message: Message) -> AsyncIterator[Song]:

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
yt-dlp==2026.1.31
2-
pytube==15.0.0
32
pillow==12.1.0
43
aiohttp==3.13.3
54
aiofiles==25.1.0

0 commit comments

Comments
 (0)