diff --git a/mps_youtube/pafy.py b/mps_youtube/pafy.py index 9ae66d80..c4551131 100644 --- a/mps_youtube/pafy.py +++ b/mps_youtube/pafy.py @@ -1,8 +1,27 @@ -from youtubesearchpython import VideosSearch, StreamURLFetcher, Video +from youtubesearchpython import VideosSearch import yt_dlp +class MyLogger: + def debug(self, msg): + # For compatibility with youtube-dl, both debug and info are passed into debug + # You can distinguish them by the prefix '[debug] ' + if msg.startswith('[debug] '): + pass + else: + self.info(msg) + + def info(self, msg): + pass + + def warning(self, msg): + pass + + def error(self, msg): + print(msg) + + def get_video_streams(ytid): - with yt_dlp.YoutubeDL() as ydl: + with yt_dlp.YoutubeDL({'logger':MyLogger()}) as ydl: info_dict = ydl.extract_info(ytid, download=False) return [i for i in info_dict['formats'] if i['format_note'] != 'storyboard'] def video_search(query):