7171DATA_URL = f'{ BASE_DATA_URL } /source-python-data.zip'
7272
7373BASE_DOWNLOAD_URL = 'http://downloads.sourcepython.com'
74- ARTIFACTS_URL = f'{ BASE_DOWNLOAD_URL } /artifacts.txt'
74+
75+ LATEST_RELEASE_URL = "https://api.github.com/repos/Source-Python-Dev-Team/Source.Python/releases/latest"
7576
7677DEFAULT_TIMEOUT = 3
7778
@@ -144,8 +145,10 @@ def get_build_artifacts(timeout=DEFAULT_TIMEOUT):
144145 Number of seconds that need to pass until a timeout occurs.
145146 """
146147 update_logger .log_debug ('Getting artifacts...' )
147- with urlopen (ARTIFACTS_URL , timeout = timeout ) as url :
148- return url .read ().decode ('utf-8' ).split ('\n ' )
148+ with urlopen (LATEST_RELEASE_URL , timeout = timeout ) as url :
149+ data = json .load (url )
150+
151+ return [asset ['browser_download_url' ] for asset in data .get ('assets' , [])]
149152
150153def get_download_url (game = SOURCE_ENGINE_BRANCH , timeout = DEFAULT_TIMEOUT ):
151154 """Get the latest Source.Python download URL for a specific game.
@@ -158,9 +161,9 @@ def get_download_url(game=SOURCE_ENGINE_BRANCH, timeout=DEFAULT_TIMEOUT):
158161 :raise ValueError:
159162 Raised if the game wasn't found.
160163 """
161- for relative_path in get_build_artifacts (timeout ):
162- if f'-{ game } -' in relative_path :
163- return f' { BASE_DOWNLOAD_URL } / { relative_path } '
164+ for download_url in get_build_artifacts (timeout ):
165+ if f'-{ game } -' in download_url :
166+ return download_url
164167
165168 raise ValueError (f'Unable to find a download URL for game "{ game } ".' )
166169
0 commit comments