Skip to content

Commit e418082

Browse files
author
Daniel
authored
Merge pull request #9 from BetaPictoris/feat/latest-version
Added getting of the latest project version
2 parents e48e198 + 0483f81 commit e418082

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

docs/readme.md

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
# Modrinth.py
22
Interact with Modrinth's Labrinth API through Python.
33

4-
## API Version
5-
6-
Service | Version
7-
----------------------|----------
8-
Modrinth.py version | v0.1.3
9-
Labrinth API version | v2.4.4
10-
11-
*Modrinth.py works on the latest Labrinth version!*
12-
134
## To-do
145
- [x] Search for projects
156
- [x] (Un)follow projects
@@ -26,7 +17,7 @@ Interact with Modrinth's Labrinth API through Python.
2617
- [ ] Upload files to version
2718
- [ ] Get a version from `sha1` or `sha512`
2819
- [ ] Delete a file from its hash (DELETE requests to `/version_file`)
29-
- [ ] Get latest project(s) version(s)
20+
- [x] Get latest project(s) version(s)
3021
- [ ] Get project version from hash
3122
- [x] Read user(s) data
3223
- [ ] Delete and modify user data

modrinth/__init__.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,12 @@ def unfollow(self, user: Users.AuthenticatedUser):
150150
headers = {'Authorization': user.token}
151151
requests.delete(url, headers=headers)
152152

153+
def getLatestVersion(self):
154+
'''
155+
Gets the latest version for the current project.
156+
'''
157+
return Versions.getLatestVersion(self)
158+
153159
def getVersion(self, version):
154160
'''
155161
Shorthand for Versions.ModrinthVersion with no project argument.
@@ -160,7 +166,7 @@ def getAllVersions(self):
160166
'''
161167
Get Versions.getVersions() for all versions found for the project.
162168
'''
163-
return Versions.getVersions(self.versions)
169+
return Versions.getVersions(self, self.versions)
164170

165171
def getProjects(ids: list) -> list:
166172
'''
@@ -317,3 +323,9 @@ def getVersions(project: Projects.ModrinthProject, ids: list) -> list:
317323
Get a list of versions, given a list of IDs.
318324
'''
319325
return [Versions.ModrinthVersion(project, id) for id in ids]
326+
327+
def getLatestVersion(project: Projects.ModrinthProject) -> ModrinthVersion:
328+
'''
329+
Gets the latest version, given a project.
330+
'''
331+
return project.getAllVersions()[-1]

0 commit comments

Comments
 (0)