예제 #1
0
    def check_wallabag(self):
        params = {
            'username': self.config['w_username'],
            'password': self.config['w_password'],
            'client_id': self.config['w_client_id'],
            'client_secret': self.config['w_client_secret']
        }
        # get token
        token = Wallabag.get_token(host=self.config['w_host'], **params)

        wall = Wallabag(host=self.config['w_host'],
                        client_secret=self.config['w_client_secret'],
                        client_id=self.config['w_client_id'],
                        token=token)

        params = {
            'archive': 0,
            'star': 0,
            'delete': 0,
            'sort': 'created',
            'order': 'desc',
            'page': 1,
            'perPage': 30,
            'tags': []
        }

        data = wall.get_entries(**params)
        for post in data['_embedded']['items']:
            if 'domain_name' in post:
                if post['domain_name'] is not None:
                    if 'boards.4chan.org' in post['domain_name']:
                        if not db.session.query(
                                exists().where(db.UrlsTable.url == unicode(
                                    post['url']))).scalar():
                            self.logger.info("adding {}".format(post['url']))
                            u = db.UrlsTable()
                            u.url = unicode(post['url'])
                            db.session.add(u)
                            db.session.commit()
                            wall.delete_entries(post['id'])
            else:
                self.logger.warning("no domain_name in {}".format(post['url']))
예제 #2
0
with open("config.yaml", 'r') as stream:
    try:
        config = yaml.load(stream)
    except (yaml.YAMLError, FileNotFoundError) as exception:
        print(exception)
        config = None
        exit(1)

token = Wallabag.get_token(**config["wallabag"])

wall = Wallabag(host=config["wallabag"]["host"],
                client_secret=config["wallabag"]["client_secret"],
                client_id=config["wallabag"]["client_id"],
                token=token)

a = wall.get_entries(tags=["Golem"])
print(a)
b = a["_embedded"]
c = b["items"]
print(c)
exit()

try:
    for i in c[1:]:
        print(i["id"])
        wall.delete_entries(i["id"])
        print(i["id"])
except requests.exceptions.HTTPError as a:
    print(a)
    pass
예제 #3
0
from wallabag_api.wallabag import Wallabag
from pocket import Pocket, PocketException
import os

params = {
    'username': os.environ['WALLABAG_USER'],
    'password': os.environ['WALLABAG_PASS'],
    'client_id': os.environ['WALLABAG_CLIENT'],
    'client_secret': os.environ['WALLABAG_SECRET'],
    'host': os.environ['WALLABAG_HOST']
}

token = Wallabag.get_token(**params)
wb = Wallabag(params['host'], token, params['client_id'],
              params['client_secret'])
entries = wb.get_entries()

urls = []
while entries['page'] <= entries['pages']:
    for item in entries['_embedded']['items']:
        urls.append(item['url'])
    entries = wb.get_entries(page=entries['page'] + 1)

print(len(urls), "urls fetched from wallabag")

p = Pocket(consumer_key=os.environ['POCKET_KEY'],
           access_token=os.environ['POCKET_TOKEN'])

for i, url in enumerate(urls):
    print(i, url)
    p.add(url)