prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Lutris shortcuts broken
  See: https://forums.lutris.net/t/desktop-shortcut-not-work-for-any-game/456
  
  </issue>
  <code>
  [start of lutris/util/resources.py]
  1 import os
  2 import re
  3 import concurrent.futures
  4 from urllib.parse import urlparse, parse_qsl
  5 
  6 from lutris import settings
  7 from lutris import api
  8 from lutris.util.log import logger
  9 from lutris.util.http import Request
  10 
  11 BANNER = "banner"
  12 ICON = "icon"
  13 
  14 
  15 def get_icon_path(game, icon_type):
  16     if icon_type == BANNER:
  17         return os.path.join(settings.BANNER_PATH, "%s.jpg" % game)
  18     if icon_type == ICON:
  19         return os.path.join(settings.ICON_PATH, "lutris_%s.png" % game)
  20 
  21 
  22 def has_icon(game, icon_type):
  23     if icon_type == BANNER:
  24         icon_path = get_icon_path(game, BANNER)
  25         return os.path.exists(icon_path)
  26     elif icon_type == ICON:
  27         icon_path = get_icon_path(game, ICON)
  28         return os.path.exists(icon_path)
  29 
  30 
  31 def fetch_icons(game_slugs, callback=None):
  32     no_banners = [slug for slug in game_slugs if not has_icon(slug, BANNER)]
  33     no_icons = [slug for slug in game_slugs if not has_icon(slug, ICON)]
  34 
  35     # Remove duplicate slugs
  36     missing_media_slugs = list(set(no_banners) | set(no_icons))
  37     if not missing_media_slugs:
  38         return
  39 
  40     response = api.get_games(game_slugs=missing_media_slugs)
  41     if not response:
  42         logger.warning('Unable to get games from API')
  43         return
  44     results = response['results']
  45     while response.get('next'):
  46         page_match = re.search(r'page=(\d+)', response['next'])
  47         if page_match:
  48             page = page_match.group(1)
  49         else:
  50             logger.error("No page found in %s", response['next'])
  51             break
  52         response = api.get_games(game_slugs=missing_media_slugs, page=page)
  53         if not response:
  54             logger.warning("Unable to get response for page %s", page)
  55             break
  56         else:
  57             results += response.get('results', [])
  58 
  59     banner_downloads = []
  60     icon_downloads = []
  61     updated_slugs = []
  62     for game in results:
  63         if game['slug'] in no_banners:
  64             banner_url = game['banner_url']
  65             if banner_url:
  66                 dest_path = get_icon_path(game['slug'], BANNER)
  67                 banner_downloads.append((game['banner_url'], dest_path))
  68                 updated_slugs.append(game['slug'])
  69         if game['slug'] in no_icons:
  70             icon_url = game['icon_url']
  71             if icon_url:
  72                 dest_path = get_icon_path(game['slug'], ICON)
  73                 icon_downloads.append((game['icon_url'], dest_path))
  74                 updated_slugs.append(game['slug'])
  75 
  76     updated_slugs = list(set(updated_slugs))  # Deduplicate slugs
  77 
  78     downloads = banner_downloads + icon_downloads
  79     with concurrent.futures.ThreadPoolExecutor(max_workers=16) as executor:
  80         for url, dest_path in downloads:
  81             executor.submit(download_media, url, dest_path)
  82 
  83     if updated_slugs and callback:
  84         callback(updated_slugs)
  85 
  86 
  87 def download_media(url, dest, overwrite=False):
  88     if os.path.exists(dest):
  89         if overwrite:
  90             os.remove(dest)
  91         else:
  92             return
  93     request = Request(url).get()
  94     request.write_to_file(dest)
  95 
  96 
  97 def parse_installer_url(url):
  98     """
  99     Parses `lutris:` urls, extracting any info necessary to install or run a game.
  100     """
  101     try:
  102         parsed_url = urlparse(url, scheme="lutris")
  103     except:
  104         return False
  105     if parsed_url.scheme != "lutris":
  106         return False
  107     game_slug = parsed_url.path
  108     if not game_slug:
  109         return False
  110     revision = None
  111     if parsed_url.query:
  112         query = dict(parse_qsl(parsed_url.query))
  113         revision = query.get('revision')
  114     return {
  115         'game_slug': game_slug,
  116         'revision': revision
  117     }
  118
  [end of lutris/util/resources.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/lutris/util/resources.py b/lutris/util/resources.py
  --- a/lutris/util/resources.py
  +++ b/lutris/util/resources.py
  @@ -107,6 +107,8 @@
       game_slug = parsed_url.path
       if not game_slug:
           return False
  +    if game_slug.startswith('lutris:'):
  +        game_slug = game_slug[7:]
       revision = None
       if parsed_url.query:
           query = dict(parse_qsl(parsed_url.query))
  
verification_info: {"golden_diff": "diff --git a/lutris/util/resources.py b/lutris/util/resources.py\n--- a/lutris/util/resources.py\n+++ b/lutris/util/resources.py\n@@ -107,6 +107,8 @@\n     game_slug = parsed_url.path\n     if not game_slug:\n         return False\n+    if game_slug.startswith('lutris:'):\n+        game_slug = game_slug[7:]\n     revision = None\n     if parsed_url.query:\n         query = dict(parse_qsl(parsed_url.query))\n", "issue": "Lutris shortcuts broken\nSee: https://forums.lutris.net/t/desktop-shortcut-not-work-for-any-game/456\n", "before_files": [{"content": "import os\nimport re\nimport concurrent.futures\nfrom urllib.parse import urlparse, parse_qsl\n\nfrom lutris import settings\nfrom lutris import api\nfrom lutris.util.log import logger\nfrom lutris.util.http import Request\n\nBANNER = \"banner\"\nICON = \"icon\"\n\n\ndef get_icon_path(game, icon_type):\n    if icon_type == BANNER:\n        return os.path.join(settings.BANNER_PATH, \"%s.jpg\" % game)\n    if icon_type == ICON:\n        return os.path.join(settings.ICON_PATH, \"lutris_%s.png\" % game)\n\n\ndef has_icon(game, icon_type):\n    if icon_type == BANNER:\n        icon_path = get_icon_path(game, BANNER)\n        return os.path.exists(icon_path)\n    elif icon_type == ICON:\n        icon_path = get_icon_path(game, ICON)\n        return os.path.exists(icon_path)\n\n\ndef fetch_icons(game_slugs, callback=None):\n    no_banners = [slug for slug in game_slugs if not has_icon(slug, BANNER)]\n    no_icons = [slug for slug in game_slugs if not has_icon(slug, ICON)]\n\n    # Remove duplicate slugs\n    missing_media_slugs = list(set(no_banners) | set(no_icons))\n    if not missing_media_slugs:\n        return\n\n    response = api.get_games(game_slugs=missing_media_slugs)\n    if not response:\n        logger.warning('Unable to get games from API')\n        return\n    results = response['results']\n    while response.get('next'):\n        page_match = re.search(r'page=(\\d+)', response['next'])\n        if page_match:\n            page = page_match.group(1)\n        else:\n            logger.error(\"No page found in %s\", response['next'])\n            break\n        response = api.get_games(game_slugs=missing_media_slugs, page=page)\n        if not response:\n            logger.warning(\"Unable to get response for page %s\", page)\n            break\n        else:\n            results += response.get('results', [])\n\n    banner_downloads = []\n    icon_downloads = []\n    updated_slugs = []\n    for game in results:\n        if game['slug'] in no_banners:\n            banner_url = game['banner_url']\n            if banner_url:\n                dest_path = get_icon_path(game['slug'], BANNER)\n                banner_downloads.append((game['banner_url'], dest_path))\n                updated_slugs.append(game['slug'])\n        if game['slug'] in no_icons:\n            icon_url = game['icon_url']\n            if icon_url:\n                dest_path = get_icon_path(game['slug'], ICON)\n                icon_downloads.append((game['icon_url'], dest_path))\n                updated_slugs.append(game['slug'])\n\n    updated_slugs = list(set(updated_slugs))  # Deduplicate slugs\n\n    downloads = banner_downloads + icon_downloads\n    with concurrent.futures.ThreadPoolExecutor(max_workers=16) as executor:\n        for url, dest_path in downloads:\n            executor.submit(download_media, url, dest_path)\n\n    if updated_slugs and callback:\n        callback(updated_slugs)\n\n\ndef download_media(url, dest, overwrite=False):\n    if os.path.exists(dest):\n        if overwrite:\n            os.remove(dest)\n        else:\n            return\n    request = Request(url).get()\n    request.write_to_file(dest)\n\n\ndef parse_installer_url(url):\n    \"\"\"\n    Parses `lutris:` urls, extracting any info necessary to install or run a game.\n    \"\"\"\n    try:\n        parsed_url = urlparse(url, scheme=\"lutris\")\n    except:\n        return False\n    if parsed_url.scheme != \"lutris\":\n        return False\n    game_slug = parsed_url.path\n    if not game_slug:\n        return False\n    revision = None\n    if parsed_url.query:\n        query = dict(parse_qsl(parsed_url.query))\n        revision = query.get('revision')\n    return {\n        'game_slug': game_slug,\n        'revision': revision\n    }\n", "path": "lutris/util/resources.py"}]}