Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
Don't allow people to /play YouTube URLs (#160)
Browse files Browse the repository at this point in the history
Fixes #156

Co-authored-by: oldmud0 <[email protected]>
  • Loading branch information
caleb-mabry and oldmud0 authored Feb 21, 2021
1 parent 90150cd commit 3174bf1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions server/commands/music.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import re

from server import database
from server.constants import TargetType
from server.exceptions import ClientError, ServerError, ArgumentError
Expand All @@ -14,6 +16,7 @@
'ooc_cmd_unblockdj'
]

YOUTUBE_RE = re.compile(r'^(https?\:\/\/)?(www\.)?(youtube\.\w*|youtu\.\w*)')

def ooc_cmd_currentmusic(client, arg):
"""
Expand Down Expand Up @@ -138,6 +141,8 @@ def ooc_cmd_play(client, arg):
"""
if len(arg) == 0:
raise ArgumentError('You must specify a song.')
if YOUTUBE_RE.search(arg):
raise ArgumentError('You cannot use YouTube links. You may use direct links to MP3, Ogg, or M3U streams.')
client.area.play_music(arg, client.char_id, 0) #don't loop it
client.area.add_music_playing(client, arg)
database.log_room('play', client, client.area, message=arg)
Expand Down

0 comments on commit 3174bf1

Please sign in to comment.