Skip to content

Commit

Permalink
Showing 4 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@
requirements.append('sphinxcontrib-websupport')
requirements.append('Pygments')

version = '0.1.90'
version = '0.1.21'

readme = ''
with open('README.rst') as f:
4 changes: 2 additions & 2 deletions wavelink/__init__.py
Original file line number Diff line number Diff line change
@@ -2,11 +2,11 @@
__author__ = 'EvieePy'
__license__ = 'MIT'
__copyright__ = 'Copyright 2019 (c) EvieePy'
__version__ = '0.1.90a'
__version__ = '0.1.21a'

from .client import Client
from .errors import *
from .events import *
from .player import Player, Track
from .player import Player, Track, TrackPlaylist
from .node import Node
from .websocket import WebSocket
6 changes: 4 additions & 2 deletions wavelink/node.py
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@
from urllib.parse import quote

from .errors import *
from .player import Player, Track
from .player import Player, Track, TrackPlaylist
from .websocket import WebSocket


@@ -95,7 +95,7 @@ async def connect(self, bot: Union[commands.Bot, commands.AutoShardedBot]):

__log__.info(f'NODE | {self.identifier} connected:: {self.__repr__()}')

async def get_tracks(self, query: str) -> Optional[list]:
async def get_tracks(self, query: str) -> Union[list, TrackPlaylist, None]:
"""|coro|
Search for and return a list of Tracks for the given query.
@@ -120,6 +120,8 @@ async def get_tracks(self, query: str) -> Optional[list]:
return None

tracks = []
if data['playlistInfo']:
return TrackPlaylist(data=data)
for track in data['tracks']:
tracks.append(Track(id_=track['track'], info=track['info']))

20 changes: 19 additions & 1 deletion wavelink/player.py
Original file line number Diff line number Diff line change
@@ -43,9 +43,10 @@ class Track:
:ivar duration: The duration of the track.
:ivar uri: The track URI. Could be None.
:ivar is_stream: Bool indicating whether the track is a stream.
:ivar thumb: The thumbnail associated with this track. Could be None.
"""

__slots__ = ('id', 'info', 'query', 'title', 'ytid', 'length', 'duration', 'uri', 'is_stream', 'dead')
__slots__ = ('id', 'info', 'query', 'title', 'ytid', 'length', 'duration', 'uri', 'is_stream', 'dead', 'thumb')

def __init__(self, id_, info, query=None):
self.id = id_
@@ -61,6 +62,11 @@ def __init__(self, id_, info, query=None):
self.is_stream = info.get('isStream')
self.dead = False

if self.ytid:
self.thumb = f"https://img.youtube.com/vi/{self.ytid}/default.jpg"
else:
self.thumb = None

def __str__(self):
return self.title

@@ -69,6 +75,18 @@ def is_dead(self):
return self.dead


class TrackPlaylist:
"""Track Playlist object.
:ivar data: The raw playlist info data dict.
:ivar tracks: The individual :class:`Track` objects from the playlist.
"""

def __init__(self, data: dict):
self.data = data
self.tracks = [Track(id_=track['track'], info=track['info']) for track in data['tracks']]


class Player:

def __init__(self, bot: Union[commands.Bot, commands.AutoShardedBot], guild_id: int, node):

0 comments on commit b60b7ac

Please sign in to comment.