Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: mod list supports Gitee #13034

Open
2 tasks done
AutumnPizazz opened this issue Mar 6, 2025 · 10 comments
Open
2 tasks done

Feature request: mod list supports Gitee #13034

AutumnPizazz opened this issue Mar 6, 2025 · 10 comments
Labels

Comments

@AutumnPizazz
Copy link
Contributor

Before creating

  • This is NOT a gameplay feature from Civ VI, BNW, or outside - see Roadmap
  • This is NOT a gameplay feature from Vanilla Civ V or from G&K - If so, it should be a comment in Missing features from Civ V - G&K #4697

Problem Description

You know,players from Mainland China have difficulty accessing GitHub to obtain mods,but they can access Gitee.I hope the game can pull mods that meet the tag requirements from Gitee.If you think this might offend GitHub,it would also be a good choice to make this feature available only in Simplified Chinese.Thank you.

Related Issue Links

No response

Desired Solution

see above

Alternative Approaches

see above

Additional Context

No response

@yairm210
Copy link
Owner

yairm210 commented Mar 6, 2025

It's not about offending Github, it's about how we search
Currently we use the Github API to search for all repos with certain tags, we'll need to add the Gitee API to support that as well
There will be secondary issues of ordering by stars but that really doesn't worry me

@yairm210
Copy link
Owner

yairm210 commented Mar 6, 2025

This is probably the API call we want, but I don't read chinese
If you can get an http call to find your mod (coehar2) using this API then we can start to integrate it 👍🏿

@AutumnPizazz
Copy link
Contributor Author

To phrase it in a manner that might be considered less tactful and potentially offensive to some: Gitee is essentially GitHub, merely a so-called domestic version within our country, akin to Baidu versus Google, or Huawei versus Apple. Although I am not well-versed in these APIs, I am certain that they must be identical to those of GitHub. Additionally, Gitee also features a star-marking functionality.

@AutumnPizazz
Copy link
Contributor Author

AutumnPizazz commented Mar 6, 2025

I conducted a test and found that directly using the URL from Gitee to access the mod I placed there allows Unciv to download it without any issues. That URL is: https://gitee.com/AutumnPizazz/CoeHarMod_2

@yairm210
Copy link
Owner

yairm210 commented Mar 6, 2025

I get that, but that does not help me whatsoever in finding mods by an API request.
For example, this is the Github API request:
https://api.github.com/search/repositories?q=topic:unciv-mod

If you take that and convert "github" into "gitee" it does not work.
For baseline usage, I need an example of a URL that queries gitee for repositories. You can read chinese, so can read their docs; I cannot.

@AutumnPizazz
Copy link
Contributor Author

It's really frustrating that Gitee doesn't natively support searching by tags.You can only search by keywords,which makes it impossible to accurately filter out mod repositories.The good news is that I found the correct URL that doesn't support tags:https://gitee.com/api/v5/search/repositories?q=unciv&access_token=your_token&page=1&per_page=20
The search criteria can be flexibly changed and replaced according to the URL you provided above.

@AutumnPizazz
Copy link
Contributor Author

However, we need a token to get URL. Like AI's reply:

How to Obtain a Gitee Access Token (for API Use)


Step 1: Log in to Your Gitee Account

  1. Go to Gitee.com and sign in.
  2. Click your profile icon in the top-right corner and select "Settings".

Step 2: Navigate to the "Personal Access Tokens" Page

  1. In the left sidebar, select "Security Settings".
  2. Find the "Personal Access Tokens" section and click to enter.

Step 3: Generate a New Token

  1. Click the "Generate New Token" button.
  2. Fill in the following details:
    • Token Name: Assign a descriptive name (e.g., API_Integration).
    • Scopes: Select permissions based on your needs (see Scope Details below).
    • Expiration Time: Choose a validity period (default is permanent, but periodic renewal is recommended).

Scope Details

Select permissions required for your use case:

  • repo: Access repositories (read/write code, issues, etc.).
  • user_info: Read basic user information.
  • projects: Manage repositories (create, delete, etc.).
  • hooks: Manage webhooks.

Example:
For searching public repositories via API, enable user_info and projects (read-only permissions).


Step 4: Save the Token

  1. After clicking "Submit", a token string (e.g., gitee_1234567890abcdef) will be generated.
  2. Copy and save the token immediately—it will not be visible again once you leave the page.

Step 5: Use the Token in Your Code

Include the token in API requests via the access_token parameter. For example:

import requests

token = "your_token_here"
url = f"https://gitee.com/api/v5/user?access_token={token}"
response = requests.get(url)
print(response.json())  # Returns user data

Important Notes

  1. Security:

    • Treat the token like a password. Never expose it publicly or commit it to code repositories.
    • Store it securely (e.g., environment variables or encrypted config files).
  2. Minimal Permissions:

    • Only enable scopes necessary for your task to reduce security risks.
  3. Revoking Tokens:

    • If compromised, delete the token on the "Personal Access Tokens" page to invalidate it.

API Example: Search Repositories

To search repositories programmatically:

GET https://gitee.com/api/v5/search/repositories?q=关键词&access_token=your_token

Replace 关键词 with your search keyword (e.g., machine_learning).

@FlapyPan
Copy link

FlapyPan commented Mar 7, 2025

Now Chinese players can download mods from gitee. If players cannot see the mod list in the game due to network problems, I think it would be better to make a mod list website for these players. The website will display the mod's github address and gitee address.

@yairm210
Copy link
Owner

yairm210 commented Mar 7, 2025

The token thing is Not Great
They limit to 30 searches per minute which means if I provide this built-in we'll reach rate limiting real fast (we have 17K daily active users on Google Play alone)
I'd rather not provide this as an option rather than have it as an option that will actually work for only a small % of players

@FlapyPan 's idea has merit though. If we only have a small number of 'external mods', we could provide them as just a file within the game, and that can accomodate other sources like Gitlab as well. But they'll be star-less 🤔

@SomeTroglodyte
Copy link
Collaborator

SomeTroglodyte commented Mar 10, 2025

The token thing is Not Great

Remember my GraphQL offer a year ago... Same thing. That one had the user enter their own token into Unciv (optionally, to enable mod autoupdates), solving both the API requirements and getting each user their own rate limit... And since GraphQL is a nice open standard (despite having been developed by criminals a privacy-disrespecting corporation), maybe, if they're to be taken seriously, they support it too.

And any website or similar would have to be manually curated - that should better happen outside this project?

Edit: And didn't I do an abstract interface thingy in that branch so adding more sources would become easy by just adding another implementation, plugin-style?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants