Exemplo n.º 1
0
    def create(self):
        name = self.item.title
        slug = slugify.slugify(name)

        existing = MatchedFile.get_by_slug(slug)
        if existing:
            logging.debug("the file " + name + " already exists")
            return False

        url = None
        content = None

        if self.source.zipped == False and self.source.authorizationRequired == False:
            url = self.item.url
        else:
            content = self.getContentForFile()
            if content is None:
                logging.warn("no content found when looking for " + name +
                             ", no matching file will be created")
                return False
            url = settings.SITE_URL + MatchedFile.get_url_for_slug(
                slug) + "/content"

        logging.info("Adding the new matched file " + name)
        newFile = MatchedFile(name=name,
                              slug=slug,
                              date=datetime.now(),
                              fileUrl=url,
                              content=content,
                              source=self.source,
                              series=self.show)
        newFile.put()

        return True
Exemplo n.º 2
0
    def create(self):
        name = self.item.title
        slug = slugify.slugify(name)

        existing = MatchedFile.get_by_slug(slug)
        if existing:
            logging.debug("the file " + name + " already exists")
            return False

        url = None
        content = None

        if self.source.zipped == False and self.source.authorizationRequired == False:
            url = self.item.url
        else:
            content = self.getContentForFile()
            if content is None:
                logging.warn("no content found when looking for " + name + ", no matching file will be created")
                return False
            url = settings.SITE_URL + MatchedFile.get_url_for_slug(slug) + "/content"

        logging.info("Adding the new matched file " + name)
        newFile = MatchedFile( name=name, slug=slug, date=datetime.now(), fileUrl=url, content=content,
            source=self.source, series=self.show )
        newFile.put()

        return True
Exemplo n.º 3
0
 def get(self,slug):
     existing = MatchedFile.get_by_slug(slug)
     if existing:
         self.response.headers['Content-Type'] = 'application/x-nzb'
         self.response.headers['Content-Disposition'] = 'attachment; filename=' + slug + ".nzb"
         self.response.out.write(existing.content)
     else:
         self.not_found()
Exemplo n.º 4
0
 def get(self,slug):
     existing = MatchedFile.get_by_slug(slug)
     if existing:
         td = default_template_data()
         td["file"] = existing
         self.render(td, "file.html")
     else:
         self.not_found()
Exemplo n.º 5
0
    def get(self, slug):
        existing = MatchedFile.get_by_slug(slug)
        if not existing:
            self.not_found()
            return

        existing.delete()
        invalidate_cache("matchedfiles")

        self.redirect("/admin/files")
Exemplo n.º 6
0
    def get(self, slug):
        existing = MatchedFile.get_by_slug(slug)
        if not existing:
            self.not_found()
            return

        existing.delete()
        invalidate_cache("matchedfiles")

        self.redirect("/admin/files")
Exemplo n.º 7
0
 def get(self,slug):
     existing = MatchedFile.get_by_slug(slug)
     if existing:
         td = default_template_data()
         td["files_selected"] = True
         td["mf"] = existing
         td["hasContent"] = (existing.content is not None)
         
         self.render(td, 'admin/files_instance.html')
     else:
         self.not_found()
Exemplo n.º 8
0
    def get(self, slug):
        existing = MatchedFile.get_by_slug(slug)
        if existing:
            td = default_template_data()
            td["files_selected"] = True
            td["mf"] = existing
            td["hasContent"] = existing.content is not None

            self.render(td, "admin/files_instance.html")
        else:
            self.not_found()