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
Esempio n. 2
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()
Esempio n. 3
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()
Esempio n. 4
0
 def retrieve(self, key):
     item = memcache.get(key)
     if item is not None:
         return item
     else:
         item = self.convertToRssItems( MatchedFile.all().order("-date").fetch(25) )
         if item is not None and not memcache.add(key, item):
             logging.error("Memcache set failed on %s" % key)
     return item
Esempio n. 5
0
 def retrieve(self, key):
     item = memcache.get(key)
     if item is not None:
         return item
     else:
         item = self.convertToRssItems(
             MatchedFile.all().order("-date").fetch(25))
         if item is not None and not memcache.add(key, item):
             logging.error("Memcache set failed on %s" % key)
     return item
Esempio 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")
Esempio n. 7
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")
Esempio 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()
Esempio n. 9
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()
Esempio n. 10
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
Esempio n. 11
0
 def data(self):
     return MatchedFile.all().order("-date").fetch(1000)
Esempio n. 12
0
 def data(self):
     return MatchedFile.all().order("-date").fetch(1000)