File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121import math
2222import time
2323import random
24+ import yt_dlp
2425import aiohttp
2526import asyncio
2627import aiofiles
2728from config import config
2829from core .song import Song
2930from pyrogram import enums
30- from pytube import Playlist
3131from spotipy import Spotify
3232from core .groups import get_group
3333from pyrogram .types import Message
@@ -297,11 +297,21 @@ async def special_to_normal(ctitle):
297297
298298
299299async 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
307317async def get_spotify_playlist (pl_url : str , message : Message ) -> AsyncIterator [Song ]:
Original file line number Diff line number Diff line change 11yt-dlp == 2026.1.31
2- pytube == 15.0.0
32pillow == 12.1.0
43aiohttp == 3.13.3
54aiofiles == 25.1.0
You can’t perform that action at this time.
0 commit comments