コード例 #1
0
ファイル: syncer.py プロジェクト: mcutshaw/ttrss-syncer
    def feedCycle(self, article_dict, downloader, db):
        url = self.config['Main']['Url']
        username = self.config['Main']['Username']
        password = self.config['Main']['Password']
        client = TTRClient(url, username, password)
        client.login()

        db = rss_db(self.config)

        articles = self.get_unread_articles(
            client, article_dict['feed_name'])  # grab all unread articles

        if articles is None:
            articles = []
        article_ids = [article.id for article in articles]

        for db_article in db.getItemByFeed(article_dict['feed_name']):
            if db_article[0] not in article_ids:
                db.removeItem(db_article[0])

        articles = self.sort_articles(client, articles,
                                      article_dict['release_type'],
                                      int(article_dict['count']))

        # has to create  new database object because of threads
        for article in articles:
            self.download_articles(rss_db(self.config), article, article_dict,
                                   downloader, client)
コード例 #2
0
ファイル: syncer.py プロジェクト: mcutshaw/ttrss-syncer
    def run(self):
        #os.chdir(self.config['Main']['Data'])
        feeds = self.get_feeds_from_config(self.config)
        threads = []
        url = self.config['Main']['Url']
        username = self.config['Main']['Username']
        password = self.config['Main']['Password']
        client = TTRClient(url, username, password)
        client.login()
        db = rss_db(self.config)

        self.ifRemovedMarkRead(
            client,
            db)  # first mark articles as read if they have been removed

        for article_dict in feeds:
            print(article_dict)

            p = Process(target=self.feedCycle,
                        args=(article_dict, self.downloader, db))
            p.start()
            threads.append(p)
        for thread in threads:
            thread.join()
        self.downloader.stop()
コード例 #3
0
ファイル: newsdedup.py プロジェクト: reuteras/newsdedup
def init_ttrss(config):
    """Init Tiny tiny RSS API."""
    hostname = config.get('ttrss', 'hostname')
    username = config.get('ttrss', 'username')
    password = config.get('ttrss', 'password')
    client =  TTRClient(hostname, username, password, auto_login=False)
    client.login()
    return client
コード例 #4
0
ファイル: newsdedup.py プロジェクト: lexelby/newsdedup
def init_ttrss(config):
    """Init Tiny tiny RSS API."""
    hostname = config.get('ttrss', 'hostname')
    username = config.get('ttrss', 'username')
    password = config.get('ttrss', 'password')

    htusername = config.get('ttrss', 'htusername')
    htpassword = config.get('ttrss', 'htpassword')
    http_auth = ()
    if htusername or htpassword:
        http_auth = (htusername, htpassword)

    client = TTRClient(hostname, username, password, http_auth=http_auth)
    client.login()

    return client
コード例 #5
0
def get_client():
    ttrss_url = os.getenv("TTRSS_URL")
    ttrss_user = os.getenv("TTRSS_USER")
    ttrss_passwd = os.getenv("TTRSS_PASSWORD")
    # ttrss_url = 'http://URL'
    # ttrss_user = '******'
    # ttrss_passwd = 'PASSWORD'
    client = TTRClient(ttrss_url, ttrss_user, ttrss_passwd)
    return client
コード例 #6
0
 def __init__(self):
     cf = configparser.ConfigParser()
     cf.read('./config.ini', encoding='UTF-8')
     ttrss_url = cf.get('TinyTinyRssServer', 'TinyTinyRssUrl')
     ttrss_account = cf.get('TinyTinyRssServer', 'TinyTinyAccount')
     ttrss_password = cf.get('TinyTinyRssServer', 'TinyTinyPassword')
     client = TTRClient(ttrss_url,
                        ttrss_account,
                        ttrss_password,
                        auto_login=True)
     self.client = client
コード例 #7
0
    def __init__(self):

        logging.basicConfig(
            format='%(asctime)s \t %(levelname)s \t %(message)s',
            level=logging.DEBUG)

        self.settings = yaml.safe_load(open('settings.yml'))

        self.r = praw.Reddit(
            username=self.settings['reddit']['username'],
            password=self.settings['reddit']['password'],
            client_id=self.settings['reddit']['client_id'],
            client_secret=self.settings['reddit']['client_secret'],
            user_agent=self.settings['reddit']['user_agent'])

        self.pb = pinboard.Pinboard(self.settings['pinboard']['apikey'])
        self.gh = github3.login(self.settings['github']['username'],
                                self.settings['github']['password'])
        self.ttrss = TTRClient(self.settings['ttrss']['url'],
                               self.settings['ttrss']['username'],
                               self.settings['ttrss']['password']).login()
コード例 #8
0
from ttrss.client import TTRClient  # https://github.com/Vassius/ttrss-python
import RPi.GPIO as GPIO
import time

client = TTRClient('http://raspberry.local', 'YOUR_USERNAME', 'YOUR_PASSWORD')
client.login()

RGB = [17, 27, 22]
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

for pin in RGB:
    GPIO.setup(pin, GPIO.OUT)
    GPIO.output(pin, GPIO.LOW)

try:
    while True:
        count = client.get_unread_count()
        if count > 0:
            print count
            GPIO.output(17, True)  # Red On
            GPIO.output(27, False)  # Green Off
        else:
            print 'Nothing to read.'
            GPIO.output(17, False)  # Red Off
            GPIO.output(27, True)  # Green On
        time.sleep(3)

except KeyboardInterrupt:
    GPIO.cleanup()
コード例 #9
0
ファイル: tests.py プロジェクト: darodi/ttrss-python
def get_ttr_client_nologin():
    s = TTRClient(TTR_URL)
    s.user = TTR_USER
    s.password = TTR_PASSWORD
    return s
コード例 #10
0
from ttrss.client import TTRClient      # https://github.com/Vassius/ttrss-python
import RPi.GPIO as GPIO
import time

client = TTRClient('http://raspberry.local', 'YOUR_USERNAME', 'YOUR_PASSWORD')
client.login()

RGB = [17, 27, 22]
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

for pin in RGB:
        GPIO.setup(pin, GPIO.OUT)
        GPIO.output(pin, GPIO.LOW)

try:
    while True:
        count   = client.get_unread_count()
        if count > 0:
            print count
            GPIO.output(17, True)   # Red On
            GPIO.output(27, False)  # Green Off
        else:
            print 'Nothing to read.'
            GPIO.output(17, False)   # Red Off
            GPIO.output(27, True)    # Green On
        time.sleep(3)

except KeyboardInterrupt:
    GPIO.cleanup()
コード例 #11
0
def get_ttr_client_nologin():
    s = TTRClient(TTR_URL)
    s.user = TTR_USER
    s.password = TTR_PASSWORD
    return s
コード例 #12
0
def get_ttr_client():
    return TTRClient(TTR_URL,
                     user=TTR_USER,
                     password=TTR_PASSWORD,
                     auto_login=True)
コード例 #13
0
class ReadingList:

    settings = None

    def __init__(self):

        logging.basicConfig(
            format='%(asctime)s \t %(levelname)s \t %(message)s',
            level=logging.DEBUG)

        self.settings = yaml.safe_load(open('settings.yml'))

        self.r = praw.Reddit(
            username=self.settings['reddit']['username'],
            password=self.settings['reddit']['password'],
            client_id=self.settings['reddit']['client_id'],
            client_secret=self.settings['reddit']['client_secret'],
            user_agent=self.settings['reddit']['user_agent'])

        self.pb = pinboard.Pinboard(self.settings['pinboard']['apikey'])
        self.gh = github3.login(self.settings['github']['username'],
                                self.settings['github']['password'])
        self.ttrss = TTRClient(self.settings['ttrss']['url'],
                               self.settings['ttrss']['username'],
                               self.settings['ttrss']['password']).login()

    def get_tag_by_subreddit(self, subreddit):

        sub = subreddit.lower()

        if sub in self.settings['reddit']['subs']:
            return self.settings['reddit']['subs'][sub]['tags']
        else:
            return []

    def get_tag_by_domain(self, domain):

        if domain in self.settings['domain_tags']:
            return self.settings['domain_tags'][domain]['tags']
        else:
            return False

    def get_tag_by_description(self, description):

        # for string in self.settings['tags']:
        #     pprint(string)

        pprint(self.settings['tags'])

    def star_github_repo(self, url):

        info = url.path.split('/')
        username = info[1]
        repo = info[2]

        if not self.gh.is_starred(username, repo):
            return self.gh.star(username, repo)

    def process_saved_reddit_posts(self):

        for saved in self.r.user.me().saved(limit=1000):

            if isinstance(saved, praw.models.Submission):

                tags = self.get_tag_by_subreddit(saved.subreddit.display_name)

                if self.save_link(saved.url, saved.title, tags):
                    saved.unsave()

    def ttrss_unstar(self, article_id, mode, field, data=""):

        self.ttrss.update_article(article_id, mode, field, data)

    def process_ttrss_stars(self):

        for headline in self.ttrss.get_headlines(feed_id=-1, limit=1000):
            logging.info('Saving url to pinboard')
            tags = []

            if self.save_link(headline.link, headline.title, tags):
                logging.info('Link saved successfully')
                self.ttrss_unstar(headline.id, 0, 0)

    def save_link(self, url, title, tags):

        logging.info('Processing URL: {}'.format(url))

        parsed_url = urlparse.urlparse(url)

        if parsed_url.netloc == 'github.com':
            logging.info('URL is github repo, attempting to star repo.')
            if self.star_github_repo(parsed_url):
                logging.info('Repo starred successfully.')
                return True
        else:
            if len(tags) == 0:
                domain = parsed_url = urlparse.urlparse(saved.url).netloc
                tags = self.get_tag_by_domain(domain)

            if len(tags) > 0:
                logging.info('Saving url to pinboard with tags: {}'.format(
                    ','.join(tags)))
            else:
                logging.info('Saving url to pinboard with no tags.')

            if self.pb.posts.add(url=url,
                                 description=unidecode(title),
                                 toread=True,
                                 tags=tags):
                return True

    # def main(self):
    #
    #     self.process_saved_reddit_posts()
    #     self.process_ttrss_stars()

    def main(self):

        for sub in self.r.user.subreddits(limit=1000):
            print(sub.display_name)