input: Write a function to extract titles of all YouTube videos from a given URL. The function should return a list of video titles. If the URL is invalid or no titles are found, it should return an empty list.
  
  import requests
  import re
  
  def extract_youtube_titles(url):
      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:
          return []
  
  assert extract_youtube_titles('https://www.youtube.com/user/Thexvid/videos') != []
  assert extract_youtube_titles('https://www.invalidurl.com') == []
output: def extract_youtube_titles(url):
      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:
          return []