<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def parse_query(self, query, index, stop_current, shuffle):
 """ Parses a query and adds it to the queue Args: query (str):
 Either a search term or a link index (int):
 The index to enqueue at (None for end) stop_current (bool):
 Whether to stop the current song after the songs are queued shuffle (bool):
 Whether to shuffle the added songs """


        if index is not None and len(self.queue) > 0:
            if index < 0 or index >= len(self.queue):
                if len(self.queue) == 1:
                    self.statuslog.error("Play index must be 1 (1 song in queue)")
                    return
                else:
                    self.statuslog.error("Play index must be between 1 and {}".format(len(self.queue)))
                    return

        try:
            yt_videos = api_music.parse_query(query, self.statuslog)
            if shuffle:
                random.shuffle(yt_videos)

            if len(yt_videos) == 0:
                self.statuslog.error("No results for: {}".format(query))
                return

            if index is None:
                self.queue = self.queue + yt_videos
            else:
                if len(self.queue) > 0:
                    self.queue = self.queue[:index] + yt_videos + self.queue[index:]
                else:
                    self.queue = yt_videos

            self.update_queue()

            if stop_current:
                if self.streamer:
                    self.streamer.stop()
        except Exception as e:
            logger.exception(e)