Exemplo n.º 1
0
	def asyncGet(self):
		output = ""
		try:
			# Get data by beatmap id or beatmapset id
			if "b" in self.request.arguments:
				id = self.get_argument("b")
				data = cheesegull.getBeatmap(id)
			elif "s" in self.request.arguments:
				id = self.get_argument("s")
				data = cheesegull.getBeatmapSet(id)
			else:
				raise exceptions.invalidArgumentsException(MODULE_NAME)

			log.info("Requested osu!direct np: {}/{}".format("b" if "b" in self.request.arguments else "s", id))

			# Make sure cheesegull returned some valid data
			if data is None or len(data) == 0:
				raise exceptions.osuApiFailException(MODULE_NAME)

			# Write the response
			output = cheesegull.toDirectNp(data) + "\r\n"
		except (exceptions.invalidArgumentsException, exceptions.osuApiFailException, KeyError):
			output = ""
		finally:
			self.write(output)
Exemplo n.º 2
0
    def asyncGet(self):
        output = ""
        try:
            # Get data by beatmap id or beatmapset id
            if "b" in self.request.arguments:
                _id = self.get_argument("b")
                data = cheesegull.getBeatmap(_id)
            elif "s" in self.request.arguments:
                _id = self.get_argument("s")
                data = cheesegull.getBeatmapSet(_id)
            elif "c" in self.request.arguments:
                md5 = self.get_argument("c")
                response = glob.db.fetch(
                    "SELECT beatmap_id FROM beatmaps WHERE beatmap_md5 = %s LIMIT 1",
                    [md5])
                if not response:
                    raise exceptions.invalidArgumentsException(MODULE_NAME)

                data = cheesegull.getBeatmap(response['beatmap_id'])
                _id = response['beatmap_id']
            else:
                raise exceptions.invalidArgumentsException(MODULE_NAME)

            log.info("Requested osu!direct np: {}/{}".format(
                "b" if "b" in self.request.arguments else "s", _id))

            # Make sure cheesegull returned some valid data
            if data is None or len(data) == 0:
                raise exceptions.osuApiFailException(MODULE_NAME)

            # Write the response
            output = cheesegull.toDirectNp(data) + "\r\n"
        except (exceptions.invalidArgumentsException,
                exceptions.osuApiFailException, KeyError):
            output = ""
        finally:
            self.write(output)
Exemplo n.º 3
0
    def asyncGet(self):
        output = ""
        try:
            username = self.get_argument("u")
            password = self.get_argument("h")
            user_id = userUtils.getID(username)

            if not verify_password(user_id, password):
                raise exceptions.loginFailedException(MODULE_NAME, username)

            # Get data by beatmap id or beatmapset id
            if "b" in self.request.arguments:
                _id = self.get_argument("b")
                data = cheesegull.getBeatmap(_id)
            elif "s" in self.request.arguments:
                _id = self.get_argument("s")
                data = cheesegull.getBeatmapSet(_id)
            else:
                raise exceptions.invalidArgumentsException(MODULE_NAME)

            log.info("Requested osu!direct np: {}/{}".format(
                "b" if "b" in self.request.arguments else "s", _id))

            # Make sure cheesegull returned some valid data
            if data is None or len(data) == 0:
                raise exceptions.osuApiFailException(MODULE_NAME)

            # Write the response
            output = cheesegull.toDirectNp(data) + "\r\n"
        except (exceptions.invalidArgumentsException,
                exceptions.osuApiFailException, KeyError):
            output = ""
        except exceptions.loginFailedException:
            output = "error: pass"
        finally:
            self.write(output)