async def main(config: Config, loop): token = await Wallabag.get_token(host=config.hostname, client_id=config.client_id, client_secret=config.client_secret, username=config.username, password=config.password) async with aiohttp.ClientSession(loop=loop) as session: wallabag = Wallabag(host=config.hostname, client_secret=config.client_secret, client_id=config.client_id, token=token, extension="json", aio_sess=session) all_article = await get_articles(wallabag) for article in all_article: is_processed = has_processed_tag(article) if not is_processed: print(f"processing {article['id']}") d = {'tags': get_tags_with_processed(article)} for enhancer in enhancers: if enhancer.should(article): result = await enhancer.patch(article, session=session) d = {**d, **result} await patch_article(wallabag, article, **d) else: print(f"skiping {article['id']}")
async def main(loop, sites): token = await Wallabag.get_token(**config["wallabag"]) async with aiohttp.ClientSession(loop=loop) as session: wall = Wallabag(host=config["wallabag"]["host"], client_secret=config["wallabag"]["client_secret"], client_id=config["wallabag"]["client_id"], token=token, aio_sess=session) await asyncio.gather(*[handle_feed(session, wall, sitetitle, site) for sitetitle, site in sites.items()])
def __init__(self, token=None): super(ServiceWallabag, self).__init__(token) self.token = token if token: self.wall = Wallabag( host=settings.TH_WALLABAG['host'], client_secret=settings.TH_WALLABAG['client_secret'], client_id=settings.TH_WALLABAG['client_id'], token=token)
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']))
import requests import yaml from wallabag_api.wallabag import Wallabag 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:
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)