@@ -15,9 +15,6 @@ import cfcore, http
1515const
1616 # # base url of the cfproxy endpoint
1717 addonsBaseUrl = " https://cfproxy.bmpm.workers.dev"
18- # # base url of the curse metadata api endpoint
19- # # used for retrieving mods by their slug, which isn't possible with the curse api
20- addonsSlugBaseUrl = " https://curse.nikky.moe/graphql"
2118
2219type
2320 CfApiError * = object of HttpRequestError
@@ -52,15 +49,13 @@ proc fetchAddons*(projectIds: seq[int]): Future[seq[CfAddon]] {.async.} =
5249
5350proc fetchAddon * (slug: string ): Future [CfAddon ] {.async .} =
5451 # # get the addon matching the `slug`.
55- let reqBody = %* {
56- " query" : " { addons(slug: \" " & slug & " \" ) { id }}"
57- }
58- let curseProxyInfo = await post (addonsSlugBaseUrl.Url , body = $ reqBody)
59- let addons = curseProxyInfo.parseJson[" data" ][" addons" ]
60- if addons.len == 0 :
61- raise newException (CfApiError , " addon with slug '" & slug & " ' not found" )
62- let projectId = addons[0 ][" id" ].getInt ()
63- return await fetchAddon (projectId)
52+ let url = addonsBaseUrl & " /v1/mods/search?gameId=432&pageSize=50&sortField=6&sortOrder=desc&slug=" & slug
53+ try :
54+ return get (url.Url ).await.parseJson[" data" ][0 ].addonFromForgeSvc
55+ except HttpRequestError :
56+ raise newException (CfApiError , " addon with slug '" & $ slug & " ' not found." )
57+ except IndexDefect :
58+ raise newException (CfApiError , " addon with slug '" & $ slug & " ' not found. Please add the addon using the project id instead." )
6459
6560proc fetchAddonFiles * (projectId: int ): Future [seq [CfAddonFile ]] {.async .} =
6661 # # get all addon files associated with the given `projectId`.
0 commit comments