Skip to content

Commit

Permalink
random fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mytja committed Jun 14, 2023
1 parent 6434dee commit 147d344
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
7 changes: 4 additions & 3 deletions commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ async def update():
''' Track Playback '''
track = server.queue[server.queueIndex]
print(f"Playing track {track}")
url = await youtube.fetch_url(track, 251)
print(f"Fetched URL {track}")
url = track["requested_formats"][-1]["url"]
print(f"Fetched URL {url}")
try:
server.voiceConnection.play(
discord.FFmpegOpusAudio(url, **FFMPEG_OPTS),
Expand Down Expand Up @@ -95,7 +95,8 @@ async def update():
''' Displaying Metadata '''
try:
await Embed().nowPlaying(server.context, track)
except:
except Exception as e:
print(e)
await Embed().exception(
server.context,
'Now Playing',
Expand Down
8 changes: 5 additions & 3 deletions scripts/youtube.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import yt_dlp
from youtubesearchpython.__future__ import VideosSearch, Video, StreamURLFetcher

from typing import List, Union
Expand Down Expand Up @@ -42,9 +43,10 @@ async def download(self, videoName: str) -> dict:
videoId = video['id']
else:
videoId = self.__getVideoId(videoName)
video = await Video.get(videoId)
print(video)
return video
with yt_dlp.YoutubeDL() as ytd:
video = ytd.extract_info(f'https://youtu.be/{videoId}', download=False)
print(video)
return video

def __getVideoId(self, videoLink: str) -> str:
if 'youtu.be' in videoLink:
Expand Down
6 changes: 3 additions & 3 deletions source/embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ async def nowPlaying(self, context, track):
await self.__createEmbed(
context,
'Now Playing',
f'**[{video["title"]}]({video["link"]})**',
f'**[{video["title"]}](https://youtu.be/{video["id"]})**',
video['thumbnails'][-1]['url'],
[
EmbedField('Channel', video['channel']['name'], False),
EmbedField('Duration', Method.formatDuration(video["duration"]["secondsText"]), True),
EmbedField('Channel', video['uploader'], False),
EmbedField('Duration', f'{video["duration"]//60}:{video["duration"]%60}', True),
],
'🎶',
True,
Expand Down

0 comments on commit 147d344

Please sign in to comment.