def parse_entry(self, entry): p = Pasty() p.text = self.strip(entry['summary_detail']['value']) p.date = self.to_date(entry['published_parsed']) if not p.date: p.date = self.source.sync_date p.source = self.source.url return p
def parse_entry(self, entry): text = entry.find(class_='Text').text.replace('\r\n', '<br/>') if len(text) > self.MAX_LENGTH: return None pasty = Pasty() pasty.text = text pasty.date = to_date(entry.find(class_='date').text) pasty.published = True pasty.source = self.source.url return pasty
def parse_entry(self, entry): text = self.process_text(entry['summary_detail']['value']) if len(text) > self.MAX_LENGTH or \ not remove_html_tags(text): return None pasty = Pasty() pasty.text = text pasty.date = to_date(entry['published_parsed']) or self.last_update pasty.published = True pasty.source = self.source.url return pasty
def parse_entry(self, entry): # fake sync_date to remove duplicates text, date = entry p = Pasty() p.text = self.strip(text) # set latest time possible for proper sync date = datetime.strptime(date, '%d.%m.%Y') date = date.replace(hour=23, minute=59, second=59) p.date = date p.source = self.source.url return p
def sync_rss_source(source): entries = [] if source.parser() in globals(): entries = globals()[source.parser()](source) else: entries = default_parser(source) for entry in entries: if not Pasty.objects.filter(unique_key=entry.get('id')): print(entry.get('id')) p = Pasty(text=entry.get('text'), date=entry.get('date'), source=entry.get('source'), unique_key=entry.get('id')) p.save()
def one(request): p = Pasty.rnd() if p: context = {'text': p.text, 'source': p.source, 'title': p.source_title()} return render(request, 'core/pasty.html', context) else: return HttpResponse(u'<div class="box pasty">Нету пирожков :-(</div>')
def one(request): """Returns one pastry, used from javascript for page updates""" p = Pasty.rnd() if p: context = {'text': p.text, 'source': p.source, 'title': p.source_title()} return render(request, 'core/pasty.html', context) else: return HttpResponse(u'<div class="box pasty">Нету пирожков :-(</div>')
def one(request): p = Pasty.rnd() if p: context = { 'text': p.text, 'source': p.source, 'title': p.source_title() } return render(request, 'core/pasty.html', context) else: return HttpResponse(u'<div class="box pasty">Нету пирожков :-(</div>')
def stishkipirozhki_ru(sync_date, source, entry): p = Pasty() p.text = strip(entry['content'][0]['value']) p.date = to_date(entry['published_parsed']) if not p.date: p.date = sync_date p.source = source.url return p
def pirozhki_ru_livejournal_com(sync_date, source, entry): p = Pasty() p.text = strip(entry['summary_detail']['value']) p.date = to_date(entry['published_parsed']) if not p.date: p.date = sync_date p.source = source.url if len(p.text) > 255: return None return p
def parse_entry(self, entry): p = Pasty() p.text = self.strip(entry['summary_detail']['value']) p.votes = int(entry['lj_reply-count']) p.date = self.to_date(entry['published_parsed']) if not p.date: p.date = self.source.sync_date p.source = self.source.url if len(p.text) > 255: return None return p