Skip to content

Commit

Permalink
Merge pull request #8 from RB387/debug
Browse files Browse the repository at this point in the history
Fix yt search
  • Loading branch information
RB387 authored Sep 10, 2024
2 parents e8f3879 + f08a95e commit c3b1318
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/players/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,19 @@ async def get_audio(self, meta: AudioMeta) -> FFmpegOpusAudio:
async def get_info(self, url: str) -> AudioMeta:
with YoutubeDL(self.ydl_opts) as ydl:
info = ydl.extract_info(str(url), download=False)
video_info = info['formats'][0]
video_info = _find_video_info(info)

return AudioMeta(
author=info.get('uploader', 'Unknown'),
url=video_info['url'],
name=info['title'],
original_url=url,
)


def _find_video_info(info: dict) -> dict:
for video_format in info['formats']:
if video_format.get('audio_ext', 'none') != 'none':
return video_format

raise ValueError('No audio format found')

0 comments on commit c3b1318

Please sign in to comment.