Ejemplo n.º 1
0
def getInstalledPlugin(localFileName, localFileVersion):
    url = "https://api.spiget.org/v2/search/resources/" + localFileName + "?field=name&sort=-downloads"
    packageName = doAPIRequest(url)
    plugin_match_found = False
    pluginID = None
    for ressource in packageName:
        if plugin_match_found == True:
            break
        pID = ressource["id"]
        url2 = f"https://api.spiget.org/v2/resources/{pID}/versions?size=100&sort=-name"
        packageVersions = doAPIRequest(url2)
        for updates in packageVersions:
            updateVersion = updates["name"]
            if localFileVersion in updateVersion:
                plugin_match_found = True
                pluginID = pID
                updateId = updates["id"]
                plugin_latest_version = getLatestPluginVersion(pID)
                plugin_is_outdated = compareVersions(plugin_latest_version,
                                                     updateVersion)
                addToPluginList(pID, updateId, plugin_latest_version,
                                plugin_is_outdated)
                return pluginID

    else:
        if plugin_match_found != True:
            pID = None
            updateId = None
            plugin_latest_version = None
            plugin_is_outdated = None
            addToPluginList(pID, updateId, plugin_latest_version,
                            plugin_is_outdated)

    return pluginID
Ejemplo n.º 2
0
def getVersionID(packageId, packageVersion):
    if packageVersion == None or packageVersion == 'latest':
        url = f"https://api.spiget.org/v2/resources/{packageId}/versions/latest"
        response = doAPIRequest(url)
        versionId = response["id"]
        return versionId

    url = f"https://api.spiget.org/v2/resources/{packageId}/versions?size=100&sort=-name"
    versionList = doAPIRequest(url)

    for packages in versionList:
        packageUpdate = packages["name"]
        versionId = packages["id"]
        if packageUpdate == packageVersion:
            return versionId
    return versionList[0]["id"]
Ejemplo n.º 3
0
def getSpecificPackage(ressourceId,
                       downloadPath,
                       inputPackageVersion='latest'):
    if checkConfig().localPluginFolder == False:
        downloadPath = createTempPluginFolder()
    url = f"https://api.spiget.org/v2/resources/{ressourceId}"
    packageDetails = doAPIRequest(url)
    packageName = packageDetails["name"]
    packageNameNew = handleRegexPackageName(packageName)
    versionId = getVersionID(ressourceId, inputPackageVersion)
    packageVersion = getVersionName(ressourceId, versionId)
    packageDownloadName = f"{packageNameNew}-{packageVersion}.jar"
    downloadPackagePath = Path(f"{downloadPath}/{packageDownloadName}")
    if checkConfig().localPluginFolder:
        if inputPackageVersion is None or inputPackageVersion == 'latest':
            downloadSpecificVersion(ressourceId=ressourceId,
                                    downloadPath=downloadPackagePath)
        else:
            downloadSpecificVersion(ressourceId, downloadPackagePath,
                                    versionId)

    if not checkConfig().localPluginFolder:
        if inputPackageVersion is None or inputPackageVersion == 'latest':
            downloadSpecificVersion(ressourceId=ressourceId,
                                    downloadPath=downloadPackagePath)
            deleteTempPluginFolder(downloadPath)
        else:
            downloadSpecificVersion(ressourceId, downloadPackagePath,
                                    versionId)
            deleteTempPluginFolder(downloadPath)
Ejemplo n.º 4
0
def findBuildVersion(wantedPaperBuild):
    versionGroups = ['1.16', '1.15']
    paperBuildFound = False
    for versionGroup in versionGroups:
        if paperBuildFound is True:
            break
        url = f"https://papermc.io/api/v2/projects/paper/version_group/{versionGroup}/builds"
        papermcdetails = doAPIRequest(url)
        paperMcBuilds = papermcdetails["builds"]
        for build in paperMcBuilds:
            paperBuild = str(build["build"])
            if paperBuild == wantedPaperBuild:
                paperBuildFound = True
                paperVersionGroup = build["version"]
                break
    return paperVersionGroup
Ejemplo n.º 5
0
def findVersionGroup(mcVersion):
    versionGroups = ['1.16', '1.15']
    versionGroupFound = False
    for versionGroup in versionGroups:
        if versionGroupFound == True:
            break
        url = f"https://papermc.io/api/v2/projects/paper/version_group/{versionGroup}/builds"
        papermcdetails = doAPIRequest(url)
        papermcVersionForMc = papermcdetails["versions"]
        for versions in papermcVersionForMc:
            if versions == mcVersion:
                versionGroupFound = True
                paperVersionGroup = versionGroup
                break
            if versionGroup == mcVersion:
                versionGroupFound = True
                paperVersionGroup = versionGroup
                break

    return paperVersionGroup
Ejemplo n.º 6
0
def searchPackage(ressourceName):
    url = f"https://api.spiget.org/v2/search/resources/{ressourceName}?field=name&sort=-downloads"
    packageName = doAPIRequest(url)
    i = 1
    print(oColors.brightBlack + f"Searching: {ressourceName}" +
          oColors.standardWhite)
    print(
        "Index | Name                        | Description                                                                                                          |  Downloads"
    )
    for ressource in packageName:
        pName = ressource["name"]
        newName = handleRegexPackageName(pName)
        pTag = ressource["tag"]
        pDownloads = ressource["downloads"]
        print(f" [{i}]".ljust(8), end='')
        print(f"{newName}".ljust(30), end='')
        print(f"{pTag}".ljust(120), end='')
        print(f"{pDownloads}".ljust(7))
        i = i + 1

    ressourceSelected = int(
        input("Select your wanted Ressource (Index)(0 to exit): "))
    if ressourceSelected != 0:
        ressourceSelected = ressourceSelected - 1
        ressourceId = packageName[ressourceSelected]["id"]
        if not checkConfig().localPluginFolder:
            try:
                getSpecificPackage(ressourceId, checkConfig().sftp_folderPath)
            except HTTPError as err:
                print(oColors.brightRed + f"Error: {err.code} - {err.reason}" +
                      oColors.standardWhite)
        else:
            try:
                getSpecificPackage(ressourceId,
                                   checkConfig().pathToPluginFolder)
            except HTTPError as err:
                print(oColors.brightRed + f"Error: {err.code} - {err.reason}" +
                      oColors.standardWhite)
Ejemplo n.º 7
0
def getVersionName(packageId, versionId):
    url = f"https://api.spiget.org/v2/resources/{packageId}/versions/{versionId}"
    response = doAPIRequest(url)
    versionName = response["name"]
    return versionName
Ejemplo n.º 8
0
def getDownloadFileName(paperMcVersion, paperBuild):
    url = f"https://papermc.io/api/v2/projects/paper/versions/{paperMcVersion}/builds/{paperBuild}"
    buildDetails = doAPIRequest(url)
    downloadName = buildDetails["downloads"]["application"]["name"]
    return downloadName
Ejemplo n.º 9
0
def findLatestBuildForVersion(mcVersion):
    url = f"https://papermc.io/api/v2/projects/paper/versions/{mcVersion}"
    papermcbuilds = doAPIRequest(url)
    latestPaperBuild = papermcbuilds["builds"][-1]
    return latestPaperBuild
Ejemplo n.º 10
0
def findLatestBuild(paperVersionGroup):
    url = f"https://papermc.io/api/v2/projects/paper/version_group/{paperVersionGroup}/builds"
    papermcbuilds = doAPIRequest(url)
    latestPaperBuild = papermcbuilds["builds"][-1]["build"]
    return latestPaperBuild
Ejemplo n.º 11
0
def getLatestPluginVersion(pluginId):
    url = f"https://api.spiget.org/v2/resources/{pluginId}/versions/latest"
    latestUpdateSearch = doAPIRequest(url)
    versionLatestUpdate = latestUpdateSearch["name"]
    return versionLatestUpdate