예제 #1
0
    def callApi(self, **kwargs):
        """ Dispatch a call to the api, see https://mega.co.nz/#developers """
        # generate a session id, no idea where to obtain elsewhere
        uid = random.randint(10 << 9, 10 ** 10)

        resp = self.load(self.API_URL % uid, post=json.dumps([kwargs]))
        self.logDebug("Api Response: " + resp)
        return json.loads(resp)
예제 #2
0
 def loadValues(self, user, section):
     if (user, section) not in self.values:
         conf = self.db.loadConfig(section, user)
         try:
             self.values[user, section] = json.loads(conf) if conf else {}
         except ValueError: # Something did go wrong when parsing
             self.values[user, section] = {}
             self.core.print_exc()
예제 #3
0
파일: MegaNz.py 프로젝트: sebmaynard/pyload
    def callApi(self, **kwargs):
        """ Dispatch a call to the api, see https://mega.co.nz/#developers """
        # generate a session id, no idea where to obtain elsewhere
        uid = random.randint(10 << 9, 10**10)

        resp = self.load(self.API_URL % uid, post=json.dumps([kwargs]))
        self.logDebug("Api Response: " + resp)
        return json.loads(resp)
예제 #4
0
파일: MegaNz.py 프로젝트: sebmaynard/pyload
    def decryptAttr(self, data, key):

        cbc = AES.new(self.getCipherKey(key), AES.MODE_CBC, "\0" * 16)
        attr = cbc.decrypt(self.b64_decode(data))
        self.logDebug("Decrypted Attr: " + attr)
        if not attr.startswith("MEGA"):
            self.fail(_("Decryption failed"))

        # Data is padded, 0-bytes must be stripped
        return json.loads(attr.replace("MEGA", "").rstrip("\0").strip())
예제 #5
0
    def loadValues(self, user, section):
        if (user, section) not in self.values:
            conf = self.db.loadConfig(section, user)
            try:
                self.values[user, section] = json.loads(conf) if conf else {}
            except ValueError: # Something did go wrong when parsing
                self.values[user, section] = {}
                self.core.print_exc()

        return self.values[user, section]
예제 #6
0
    def decryptAttr(self, data, key):

        cbc = AES.new(self.getCipherKey(key), AES.MODE_CBC, "\0" * 16)
        attr = cbc.decrypt(self.b64_decode(data))
        self.logDebug("Decrypted Attr: " + attr)
        if not attr.startswith("MEGA"):
            self.fail(_("Decryption failed"))

        # Data is padded, 0-bytes must be stripped
        return json.loads(attr.replace("MEGA", "").rstrip("\0").strip())
예제 #7
0
    def loadAccounts(self):
        """loads all accounts available"""

        self.accounts = {}

        for plugin, loginname, activated, password, options in self.core.db.loadAccounts():
            # put into options as used in other context
            options = json.loads(options) if options else {}
            options["activated"] = activated

            self.createAccount(plugin, loginname, password, options)
예제 #8
0
    def loadAccounts(self):
        """loads all accounts available"""

        self.accounts = {}

        for plugin, loginname, activated, password, options in self.core.db.loadAccounts(
        ):
            # put into options as used in other context
            options = json.loads(options) if options else {}
            options["activated"] = activated

            self.createAccount(plugin, loginname, password, options)
예제 #9
0
    def iterSections(self, user=None):
        """ Yields: section, metadata, values """
        values = self.db.loadConfigsForUser(user)

        # Every section needs to be json decoded
        for section, data in values.items():
            try:
                values[section] = json.loads(data) if data else {}
            except ValueError:
                values[section] = {}
                self.core.print_exc()

        for name, config in self.config.iteritems():
            yield name, config, values[name] if name in values else {}
예제 #10
0
def loads(*args, **kwargs):
    kwargs['object_hook'] = convert_obj
    return json.loads(*args, **kwargs)
예제 #11
0
 def callApi(self, **kwargs):
     """ Dispatch a call to the api, see megacrypter.com/api_doc """
     self.logDebug("JSON request: " + json.dumps(kwargs))
     resp = self.load(self.API_URL, post=json.dumps(kwargs))
     self.logDebug("API Response: " + resp)
     return json.loads(resp)