input: Write a function to extract titles of all YouTube videos from a given URL. The URL should be provided as an input string. If no titles are found, the function should return an empty list. If the input URL is invalid, the function should raise an exception.
  
  def extract_youtube_titles(url):
      import requests
      import re
      
      try:
          r = requests.get(url)
          titles = re.findall('<a href="/watch\?v=([^"]+)">(.+?)<\/a>', r.content.decode('utf-8'))
          return [title[1] for title in titles]
      except Exception as e:
          raise e
  
  assert extract_youtube_titles("https://www.youtube.com/user/Thexvid/videos") != []
  assert extract_youtube_titles("https://invalidurl.com")
  assert extract_youtube_titles("https://www.youtube.com/user/videos") == []
output: def extract_youtube_titles(url):
      import requests
      import re
      
      try:
          r = requests.get(url)
          titles = re.findall('<a href="/watch\?v=([^"]+)">(.+?)<\/a>', r.content.decode('utf-8'))
          return [title[1] for title in titles]
      except Exception as e:
          raise e