Repository: Cog-Creators/Red-DiscordBot

Issue:
[V2] Unable to repeat queue on latest commit
Hey, a new error that occurs on the audio cog has appeared recently, blocking the repeat function of the queue. Let me explain what the problem is:
1. I make my queue, using `[p]play` or `[p]queue`
2. I toggle the repeat function 

As of now, the queue show normally, but when the first song will be finished/skipped, the next song will be playing as usual __but__ the queue won't work, showing an error, and it won't repeat. After the last song, the status will be reset (no queue, no current playing song).
Here is the error that shows when typing the `[p]queue` command after the first song was skipped: 
```Py
Exception in command 'queue'
Traceback (most recent call last):
  File "lib/discord/ext/commands/core.py", line 50, in wrapped
    ret = yield from coro(*args, **kwargs)
  File "/home/laggron/Coding/Red/cogs/audio.py", line 1734, in _queue
    return await self._queue_list(ctx)
  File "/home/laggron/Coding/Red/cogs/audio.py", line 1799, in _queue_list
    queue_song_list = await self._download_all(queued_song_list, channel)
  File "/home/laggron/Coding/Red/cogs/audio.py", line 491, in _download_all
    d = Downloader(queued_song.url)
AttributeError: 'str' object has no attribute 'url'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "lib/discord/ext/commands/bot.py", line 846, in process_commands
    yield from command.invoke(ctx)
  File "lib/discord/ext/commands/core.py", line 374, in invoke
    yield from injected(*ctx.args, **ctx.kwargs)
  File "lib/discord/ext/commands/core.py", line 54, in wrapped
    raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'str' object has no attribute 'url'
```

I talked to the members of the server many times of that bug but no one seems to care of that, and the staff wasn't aware of the situation, so here is the issue.
Note that (as weird as this can be) the bug only occurs on __freshly installed instances__ (as of now this show be for those younger than a month). Don't tell me how, as all of the bots are on the same commits, this don't happen on older bots.


Discussion:
@Markolie Do you happen to have any insight into this? It looks like it was introduced during #887 as audio commits from before that don't seem to have this issue. I was able to reproduce this with the current audio and am wondering if toggling the repeat function somehow clears the queue as line 589 throws the IndexError.
@aikaterna Does the issue occur as well if you only revert https://github.com/Cog-Creators/Red-DiscordBot/pull/919? That pull request makes some changes to the URL searching, and it's possible that it's causing these URL issues in the queue.
Yes, I tested audio at #866, #887, #919, and present, with the error occurring at #887 and later.

Resolving patch:
diff --git a/cogs/audio.py b/cogs/audio.py
--- a/cogs/audio.py
+++ b/cogs/audio.py
@@ -2177,7 +2177,7 @@ async def queue_manager(self, sid):
                     return
                 if repeat and last_song:
                     queued_last_song = QueuedSong(last_song.webpage_url, last_song_channel)
-                    queue.append(last_song.webpage_url)
+                    queue.append(queued_last_song)
             else:
                 song = None
             self._set_queue_nowplaying(server, song, channel)


Test patch: