Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantBirki committed Dec 6, 2021
1 parent ad1d05c commit c7bccd3
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions app/plugins/play/play.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ def play_next(self, msg, args):
Note: This command uses the exact same syntax as the .play command
"""
Sentry().user(msg)

# Run the play_main() function with the queue_postition set to 1 (next song)
for message in self.play_main(msg, args, queue_position=1):
yield message
return
return

@botcmd
def play(self, msg, args):
Expand All @@ -127,10 +127,10 @@ def play(self, msg, args):
Note: Use the --channel flag if you are not in a voice channel or want to play in a specific channel
"""
Sentry().user(msg)

for message in self.play_main(msg, args):
yield message
return
return

@botcmd
def play_queue(self, msg, args):
Expand Down Expand Up @@ -426,10 +426,12 @@ def play_main(self, msg, args, queue_position=None):
response_message = f"🎵 Now playing: `{video_metadata['title']}`"
# If the queue is 1 item, let the user know their song is up next
elif len(queue_items) == 1:
response_message = f"💃🕺💃 Added to queue: `{video_metadata['title']}` - Up next!"
response_message = (
f"💃🕺💃 Added to queue: `{video_metadata['title']}` - Up next!"
)
# If the queue is not empty, change the response message to 'added'
else:
# If there is no queue position provided, add the song to the end of the queue
# If there is no queue position provided, add the song to the end of the queue
if queue_position is None:
response_message = f"💃🕺💃 Added to queue: `{video_metadata['title']}`"
# If the user provided a queue position, give details about its position
Expand All @@ -440,7 +442,13 @@ def play_main(self, msg, args, queue_position=None):

# If the queue file is ready, we can add the song to the queue
add_result = self.add_to_queue(
msg, channel, video_metadata, file_path, song_uuid, regex_result, queue_position=queue_position
msg,
channel,
video_metadata,
file_path,
song_uuid,
regex_result,
queue_position=queue_position,
)

# If something went wrong, we can't add the song to the queue and send an error message
Expand Down Expand Up @@ -558,7 +566,14 @@ def scan_queue_dir(self):
return queue_files

def add_to_queue(
self, msg, channel, video_metadata, file_name, song_uuid, regex_result, queue_position=None
self,
msg,
channel,
video_metadata,
file_name,
song_uuid,
regex_result,
queue_position=None,
):
"""
Helper function - Add a song to the .play queue
Expand Down Expand Up @@ -606,7 +621,7 @@ def add_to_queue(
else:
queue = json.loads(queue_file.read())
queue.insert(queue_position, queue_item)

# Seek to the start of the file and nuke the contents
queue_file.seek(0)
queue_file.truncate(0)
Expand Down Expand Up @@ -707,7 +722,9 @@ def play_regex(self, args):
# The queue_position is a list starting at 0 but humans start counting at 1 so we subtract 1 so they line up
regex_result["queue_position"] = int(match.group(2).strip()) - 1
# Replace the 'args' with the original value of 'args' without the --queue flag and its value
args = args.replace(f"--queue {regex_result['queue_position'] + 1}", "")
args = args.replace(
f"--queue {regex_result['queue_position'] + 1}", ""
)
# If queue is present and we still cannot get its value, return None (failed)
else:
return None
Expand Down

0 comments on commit c7bccd3

Please sign in to comment.