Git Product home page Git Product logo

zwoaschlogzeiln's Introduction

ZwoaSchlogzeiln

Installation

  • Code herunterladen: git clone https://github.com/abaumg/zwoaschlogzeiln
  • Python-Module laden: pip3 install -r requirements.txt
  • deutsches SpaCy-Sprachmodell laden: python3 -m spacy download de_core_news_sm
  • Konfigurationsdatei kopieren: cp zwoaschlogzeiln.ini.example zwoaschlogzeiln.ini
  • Twitter-Zugangsdaten konfigurieren
  • Mastodon-App erstellen (https://<namederinstanz>/settings/applications) und Zugangstoken konfigurieren
  • Feeds konfigurieren: im Abschnitt [sources] eine Zeile pro Feed eintragen: feedname=feedurl (feedname ist frei wählbar)
  • eventuelle feedspezifische Anpassungen programmieren, wobei xxx identisch sein muss mitfeedname= in zwoaschlogzeiln.ini:
  • cp feedspezifika.py.example feedspezifika.py
  • Funktion zur Manipulation des gesamten Feeds: filter_items_xxx
  • Funktion zur Manipulation eines einzelnen Feedeintrags: filter_content_xxx

Beispiel für Anpassungen:

Die Nachrichtenseite nachrichten.it bietet keinen RSS-Feed an und steht somit als Quelle für ZwoaSchlogzeilen nicht zur Verfügung. Allerdings gibt es ein proprietäres JSON-File, das die Nachrichten enthält. Mit einem Filter filter_content_nachrichtenit kann das JSON-File ganz einfach ausgelesen und in einen RSS-Feed umgewandelt werden:

import json
import rfeed

def filter_items_nachrichtenit(entry):
    """ Nur Nachrichten aus den Kategorien Lokal und National berücksichtigen """
    if entry.author in ('Lokal', 'National'):
        return entry
    return None

def filter_content_nachrichtenit(content):
    """ Proprietäres JSON-File zu RSS konvertieren """
    itemlist = []
    for item in json.loads(content):
        itemlist.append(
            rfeed.Item(
                title = item.get('titel'),
                link = item.get('plink'),
                description = item.get('text'),
                guid = rfeed.Guid(item.get('uid')),
                author = item.get('verortung'),
            )
        )

feed = rfeed.Feed(
    title = 'nachrichten.it',
    items = itemlist,
    link = 'http://www.suedtirolnews.it',
    description = 'Bogus',
)

return feed.rss()

zwoaschlogzeiln's People

Contributors

abaumg avatar splattne avatar

Watchers

 avatar  avatar  avatar

Forkers

splattne

zwoaschlogzeiln's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.