コード例 #1
0
ファイル: upload.py プロジェクト: vasc/couchee
    def post(self):
        upload = self.get_uploads()[0]
        imdbid = self.request.get("imdbid")
        hexhash = self.request.get("hexhash")
        if not imdbid or not hexhash:
            logging.error("CoverUpload: imdbid('%s') or hexhash('%s') not present in request" % (imdbid, hexhash))
            self.set_status(500)
            return

        info = ImdbInfo.get_by_key_name(imdbid)
        if not info:
            logging.error("CoverUpload: imdbinfo for id '%s' does not exist" % imdbid)
            blobstore.delete(upload.key())
            self.redirect("/api/dummy/")
            return

        i = Cover.get_by_key_name(hexhash)
        if i:
            logging.warning(
                "CoverUpload: hash('%s') of new upload with imdb id('%s') already present" % (hexhash, imdbid)
            )
            blobstore.delete(upload.key())
            self.redirect("/api/dummy/")
            return

        i = Cover(key_name=hexhash, imdbinfo=info)
        i.blobkey = upload.key()
        i.imdbid = imdbid

        i.put()
        logging.info("CoverUpload: uploaded cover with imdbid: %s" % imdbid)

        self.redirect("/api/dummy/")
コード例 #2
0
ファイル: upload.py プロジェクト: vasc/couchee
    def post(self):

        if self.request.get("secret") == "e8aAqE7pFcKjuTnAoTe4":
            m = Movie(key_name=self.request.get("nzblink"))
            m.rlsname = self.request.get("rlsname")
            m.imdblink = self.request.get("imdblink")
            m.imdbid = re.search("tt\d{7}", m.imdblink).group(0)
            m.nzblink = self.request.get("nzblink")
            m.nzbdate = datetime.strptime(self.request.get("nzbdate"), "%Y-%m-%d %H:%M:%S")

            info = ImdbInfo.get_by_key_name(m.imdbid)
            if info:
                m.imdbinfo = info
            m.put()
            self.redirect("/api/dummy/")
        else:
            self.response.set_status(403)
            self.response.out.write("Password is not correct")