store original url for nowplaying, fix ytsearch due to yt-dlp api changes
This commit is contained in:
parent
6a7ec8eef7
commit
eb6ed9e784
|
@ -46,6 +46,7 @@ class Track:
|
||||||
source: str,
|
source: str,
|
||||||
requester: discord.User,
|
requester: discord.User,
|
||||||
title: str = None,
|
title: str = None,
|
||||||
|
original_url: str = None,
|
||||||
duration = None,
|
duration = None,
|
||||||
author: str = None,
|
author: str = None,
|
||||||
author_icon: str = None,
|
author_icon: str = None,
|
||||||
|
@ -54,6 +55,7 @@ class Track:
|
||||||
self.source = source
|
self.source = source
|
||||||
self.requester = requester
|
self.requester = requester
|
||||||
self.title = title
|
self.title = title
|
||||||
|
self.original_url = original_url
|
||||||
self.duration = duration
|
self.duration = duration
|
||||||
self.author = author
|
self.author = author
|
||||||
self.data = data
|
self.data = data
|
||||||
|
@ -251,7 +253,7 @@ class Music(Cog):
|
||||||
# Create Track objects
|
# Create Track objects
|
||||||
tracks = []
|
tracks = []
|
||||||
for entry in entries:
|
for entry in entries:
|
||||||
url = entry["url"]
|
source = entry["url"]
|
||||||
title = entry["title"]
|
title = entry["title"]
|
||||||
duration = None
|
duration = None
|
||||||
data = entry
|
data = entry
|
||||||
|
@ -273,9 +275,10 @@ class Music(Cog):
|
||||||
duration = s + 60*m + 3600*h
|
duration = s + 60*m + 3600*h
|
||||||
tracks.append(
|
tracks.append(
|
||||||
Track(
|
Track(
|
||||||
source=url,
|
source=source,
|
||||||
requester=ctx.message.author,
|
requester=ctx.message.author,
|
||||||
title=title,
|
title=title,
|
||||||
|
original_url=url,
|
||||||
duration=duration,
|
duration=duration,
|
||||||
data=data
|
data=data
|
||||||
)
|
)
|
||||||
|
@ -367,13 +370,15 @@ class Music(Cog):
|
||||||
|
|
||||||
for i, result in enumerate(self.search_results['entries']):
|
for i, result in enumerate(self.search_results['entries']):
|
||||||
|
|
||||||
if result['live_status'] == "is_upcoming":
|
result: dict
|
||||||
|
|
||||||
|
if result.get('live_status') == "is_upcoming":
|
||||||
continue # skip YT Premieres
|
continue # skip YT Premieres
|
||||||
|
|
||||||
title = result['title']
|
title = result.get('title', '<no title found>')
|
||||||
duration = format_time(int(result['duration']))
|
duration = format_time(int(result.get('duration'))) if ('duration' in result) else '?:??'
|
||||||
uploader = result['uploader']
|
uploader = result.get('channel', '<no uploader found>')
|
||||||
views = "{:,}".format(result['view_count'])
|
views = "{:,}".format(result.get('view_count')) if ('view_count' in result) else '<no view count found>'
|
||||||
image = result['thumbnails'][-1]['url']
|
image = result['thumbnails'][-1]['url']
|
||||||
height = result['thumbnails'][-1]['height']
|
height = result['thumbnails'][-1]['height']
|
||||||
width = result['thumbnails'][-1]['width']
|
width = result['thumbnails'][-1]['width']
|
||||||
|
@ -665,7 +670,7 @@ class Music(Cog):
|
||||||
source: Player = ctx.voice_client.source
|
source: Player = ctx.voice_client.source
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
title=f"{self.track.title}",
|
title=f"{self.track.title}",
|
||||||
url=f"{self.track.source}" if self.track.source.startswith('http') else None,
|
url=f"{self.track.original_url}" if self.track.original_url else None,
|
||||||
).add_field(
|
).add_field(
|
||||||
name="Progress",
|
name="Progress",
|
||||||
value=f"{source.progress}",
|
value=f"{source.progress}",
|
||||||
|
|
Loading…
Reference in a new issue