Hex-Dragon / PCL2

Plain Craft Launcher(我的世界启动器 PCL)的源代码,为支持社区研究而公开。
https://afdian.com/a/LTCat
Other
2.35k stars 178 forks source link

添加国内 Mod 镜像下载源 #4267

Closed z0z0r4 closed 3 weeks ago

z0z0r4 commented 1 month ago

检查项

描述

依照 BMCLAPI 一样的设计,添加 mcim 作为 Mod 镜像源

该镜像提供 curseforge 和 modrinth 镜像,同时提供基于网盘的文件下载,可以直接替换 url,启动器实现仅需复刻和客户端下载的失败自动切换即可

建议策略:

原因

为了解决无法访问 curseforge 的情况,以及未来 modrinth 同样可能会被阻断,应该也不会太远

curseforge 用的是 aws S3,速度很慢,这种需求应该不少,以下是一些供测试的 curseforge 域名

api.curseforge.com mediafilez.forgecdn.net edge.forgecdn.net media.forgecdn.net

参考:https://github.com/MCLF-CN/docs/issues/3

有需求、疑问可以在该 issue 下方留言,或前往 mcim

虽然知道待实现的新功能不少,但还是希望能认真考虑下,毕竟待实现的新功能中有很多与 Mod 相关,而无法访问则根本无法体验

LTCatt commented 1 month ago

目前可以从 API 访问 CurseForge,但我这里所有 Modrinth 的访问都会超时。 可以正常访问的: https://mod.mcimirror.top/curseforge/v1/mods/search?gameId=432&sortField=2&sortOrder=desc&pageSize=40&classId=6&categoryId=0&index=80 会超时的: https://mod.mcimirror.top/modrinth/search?limit=40&index=relevance&offset=80&facets=[["project_type:mod"]]

LTCatt commented 1 month ago

CurseForge API 中,JourneyMap 丢失了 categories 字段,但官方 API 中必定返回 categories 字段。

{
  "id": 32274,
  "gameId": 432,
  "name": "JourneyMap",
  "slug": "journeymap",
  "links": {
    "websiteUrl": "https://www.curseforge.com/minecraft/mc-mods/journeymap",
    "wikiUrl": "http://journeymap.info",
    "issuesUrl": "https://github.com/TeamJM/journeymap/issues",
    "sourceUrl": null
  },
  "summary": "Real-time mapping in-game or your browser as you explore.",
  "status": 4,
  "downloadCount": 229781129,
  "primaryCategoryId": 423,
  "classId": 6,
  ......
LTCatt commented 1 month ago

https://mod.mcimirror.top/curseforge/v1/fingerprints/432/ https://mod.mcimirror.top/modrinth/version_files 均返回 404。

对应的 API: https://api.curseforge.com/v1/fingerprints/432/ https://api.modrinth.com/v2/version_files

z0z0r4 commented 1 month ago

请仔细阅读替换规则,不要忽略 modrinth 官方的 /v2 path 字段

对照 https://mod.mcimirror.top/docs

z0z0r4 commented 1 month ago

已经补充全部丢失的 Field,数据正在拉取更新

class Mod(Model):
    id: int = Field(primary_field=True, index=True)
    gameId: Optional[int] = None
    name: Optional[str] = None
    slug: str = Field(index=True)
    links: Optional[Links] = None
    summary: Optional[str] = None
    status: Optional[int] = None
    downloadCount: Optional[int] = None
    isFeatured: Optional[bool] = None
    primaryCategoryId: Optional[int] = None
    categories: Optional[List[Category]] = None
    classId: Optional[int] = None
    authors: Optional[List[Author]] = None
    logo: Optional[Logo] = None
    screenshots: Optional[List[ScreenShot]] = None
    mainFileId: Optional[int] = None
    latestFiles: Optional[List[FileInfo]] = None
    latestFilesIndexes: Optional[List[FileIndex]] = None
    dateCreated: Optional[str] = None
    dateModified: Optional[str] = None
    dateReleased: Optional[str] = None
    allowModDistribution: Optional[bool] = None
    gamePopularityRank: Optional[int] = None
    isAvailable: Optional[bool] = None
    thumbsUpCount: Optional[int] = None
    rating: Optional[int] = None
z0z0r4 commented 1 month ago

当前正在测试 webdav...抛弃 rclone,暂时清空数据库

LTCatt commented 1 month ago

请仔细阅读替换规则,不要忽略 modrinth 官方的 /v2 path 字段

对照 https://mod.mcimirror.top/docs

image

属于是我玩扫雷没扫干净了

LTCatt commented 1 month ago

image nope,还是不行

z0z0r4 commented 1 month ago

image nope,还是不行

@LTCatt

/fingerprints/432 已添加

/version_files 请重试,当时我把数据库清空了,应该已经恢复了

如果没别的问题就算告一段落了...有别的问题还是尽早吧...7.31 下午4点跑路

已缓存文档

[
    {
      "mods": 19087,
      "files": 322681,
      "fingerprints": 322448
    },
    {
      "projects": 25540,
      "versions": 286365,
      "files": 319292
    }
]

已缓存文件

>>> 
# curseforge
UpdateResult({'n': 249343, 'nModified': 248892, 'ok': 1.0, 'updatedExisting': True}, acknowledged=True)
# modrinth
UpdateResult({'n': 267344, 'nModified': 267343, 'ok': 1.0, 'updatedExisting': True}, acknowledged=True)
LTCatt commented 1 month ago

https://api.modrinth.com/v2/version_files 原始 API 返回了一个字典,但镜像源返回了一个数组。 无法将类型为“Newtonsoft.Json.Linq.JArray”的对象强制转换为类型“Newtonsoft.Json.Linq.JObject”。

https://mod.mcimirror.top/curseforge/v1/fingerprints/432 与原始 API 的 exactMatches 字段格式不一样。 Accessed JArray values with invalid key value: "exactMatches". Int32 array index expected.

哥们你这 API 和原始 API 就没几个响应格式一样的……

LTCatt commented 1 month ago

Modrinth 文件下载,在第一次尝试时直接给我 Redirect 回源站了,第二次才正常。 image

CurseForge 文件下载,第一次测试 SHA1 错误: SHA1.txt

第二次测试重定向报错:

[19:16:12.227] [Download] Bookshelf-Fabric-1.20.4-23.1.9.jar 1326#:开始,起始点 0,https://mod.mcimirror.top/files/5555/931/Bookshelf-Fabric-1.20.4-23.1.9.jar
引发的异常:“System.Net.WebException”(位于 System.dll 中)
[19:16:12.400] [Download] Bookshelf-Fabric-1.20.4-23.1.9.jar 1326#:出错,无法处理从 HTTP/HTTPS 协议到其他不同协议的重定向。
z0z0r4 commented 1 month ago

api.modrinth.com/v2/version_files 原始 API 返回了一个字典,但镜像源返回了一个数组。 无法将类型为“Newtonsoft.Json.Linq.JArray”的对象强制转换为类型“Newtonsoft.Json.Linq.JObject”。

mod.mcimirror.top/curseforge/v1/fingerprints/432 与原始 API 的 exactMatches 字段格式不一样。 Accessed JArray values with invalid key value: "exactMatches". Int32 array index expected.

哥们你这 API 和原始 API 就没几个响应格式一样的……

fixed

LTCatt commented 1 month ago

SP~%`H80%ZML1D()EIWCRL2 生活调味料:苹果派版,CurseForge 工程信息 ID 有误

LTCatt commented 1 month ago
[23:59:32.383] [Download] 原始整合包.zip 1489#:开始,起始点 0,https://mod.mcimirror.top/files/5560/793/Fabulously.Optimized-6.0.0-beta.5.zip
引发的异常:“System.Net.WebException”(位于 System.dll 中)
[23:59:32.509] [Download] 原始整合包.zip 1489#:出错,无法处理从 HTTP/HTTPS 协议到其他不同协议的重定向。
→ 无效的 URI: 未能分析主机名。

没法提供它在 redirect 到哪 =。=

z0z0r4 commented 1 month ago
[23:59:32.383] [Download] 原始整合包.zip 1489#:开始,起始点 0,https://mod.mcimirror.top/files/5560/793/Fabulously.Optimized-6.0.0-beta.5.zip
引发的异常:“System.Net.WebException”(位于 System.dll 中)
[23:59:32.509] [Download] 原始整合包.zip 1489#:出错,无法处理从 HTTP/HTTPS 协议到其他不同协议的重定向。
→ 无效的 URI: 未能分析主机名。

没法提供它在 redirect 到哪 =。=

未能复现


C:\Users\DELL>curl -v -H "user-agent: PCL22" https://mod.mcimirror.top/files/5560/793/Fabulously.Optimized-6.0.0-beta.5.zip
* Host mod.mcimirror.top:443 was resolved.
* IPv6: 2409:8c54:2000:502:1a::, 2409:8c54:3010:11:38::9, 2409:8c54:5100:4:5e::a, 2409:8c54:3010:7:3e::1, 2409:8c54:5100:4:5e::25, 2409:8c54:5100:4:5e::e, 2409:8754:34a0:0:5e::3c
* IPv4: 120.232.59.55, 111.45.69.140, 120.232.57.133, 120.234.70.211, 183.240.47.186
*   Trying [2409:8c54:2000:502:1a::]:443...
* Connected to mod.mcimirror.top (2409:8c54:2000:502:1a::) port 443
* schannel: disabled automatic use of client certificate
* ALPN: curl offers http/1.1
* ALPN: server accepted http/1.1
* using HTTP/1.x
> GET /files/5560/793/Fabulously.Optimized-6.0.0-beta.5.zip HTTP/1.1
> Host: mod.mcimirror.top
> Accept: */*
> user-agent: PCL22
>
* Request completely sent off
< HTTP/1.1 307 Temporary Redirect
< date: Wed, 31 Jul 2024 04:23:09 GMT
< server: uvicorn
< expires: Wed, 31 Jul 2024 07:10:36 GMT
< location: https://media-bjcy-fy-home.bjoss.ctyunxs.cn/FAMILYCLOUD/3ec47d05-a78d-456e-9768-f96220e537f1?x-amz-CLIENTTYPEIN=PC&AWSAccessKeyId=0Lg7dAq3ZfHvePP8DKEU&x-amz-limitrate=51200&x-amz-UID=688288418&x-amz-APPID=93005&response-content-disposition=attachment%3Bfilename%3D%22a08cadcaae9d090f38542e060e5dca107badbd5e%22%3Bfilename*%3DUTF-8%27%27a08cadcaae9d090f38542e060e5dca107badbd5e&x-amz-OPERID=688287369&x-amz-CLIENTNETWORK=UNKNOWN&x-amz-CLOUDTYPEIN=FAMILY&Signature=U4mXSnLbssT8KJFEB3wQPqffCng%3D&Expires=1722410556&x-amz-FSIZE=294912&x-amz-UFID=525541147751333635
< X-Cache-Lookup: Cache Miss
< Cache-Control: public
< Content-Length: 0
< X-NWS-LOG-UUID: 15181763175338954239
< Connection: keep-alive
< X-Cache-Lookup: Cache Miss
<
* Connection #0 to host mod.mcimirror.top left intact