input: Write a function to extract titles of all YouTube videos from a given URL using Python. If the URL is invalid or the title extraction fails, the function should return an empty list.
  
  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'))
          titles = [title[1] for title in titles]
          return titles
      except:
          return []
  
  assert extract_youtube_titles("https://www.youtube.com/user/Thexvid/videos")==True
  assert extract_youtube_titles("https://www.youtube.com/user/invaliduser/videos")==False
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'))
          titles = [title[1] for title in titles]
          return titles
      except:
          return []