aboutsummaryrefslogtreecommitdiff
path: root/src/manager.py
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2016-10-06 14:16:58 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2016-10-06 14:16:58 +0200
commit0a7f69cc1fc0e068c66ca34b3f4a44067cfe9761 (patch)
tree5212bc56c32c7f307ae642f877ab01aa70d43230 /src/manager.py
parentUpdated CHANGELOG. (diff)
downloadnewspipe-0a7f69cc1fc0e068c66ca34b3f4a44067cfe9761.tar.gz
newspipe-0a7f69cc1fc0e068c66ca34b3f4a44067cfe9761.tar.bz2
newspipe-0a7f69cc1fc0e068c66ca34b3f4a44067cfe9761.zip
Fetch feeds only if the user do not want to use its own crawler.
Diffstat (limited to 'src/manager.py')
-rwxr-xr-xsrc/manager.py22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/manager.py b/src/manager.py
index a256684f..cd656226 100755
--- a/src/manager.py
+++ b/src/manager.py
@@ -49,21 +49,18 @@ def fetch(limit=100, retreive_all=False):
@manager.command
-def fetch_asyncio(user_id, feed_id):
+def fetch_asyncio(user_id=None, feed_id=None):
"Crawl the feeds with asyncio."
import asyncio
with application.app_context():
from crawler import classic_crawler
- ucontr = UserController()
- users = []
- try:
- users = ucontr.read(id=int(user_id)).all()
- except Exception as e:
- users = ucontr.read().all()
- finally:
- if users == []:
- users = ucontr.read().all()
+ filters = {}
+ filters['is_active'] = True
+ filters['automatic_crawling'] = True
+ if None is not user_id:
+ filters['id'] = user_id
+ users = UserController().read(**filters).all()
try:
feed_id = int(feed_id)
@@ -72,9 +69,8 @@ def fetch_asyncio(user_id, feed_id):
loop = asyncio.get_event_loop()
for user in users:
- if user.is_active:
- logger.info("Fetching articles for " + user.nickname)
- classic_crawler.retrieve_feed(loop, user, feed_id)
+ logger.info("Fetching articles for " + user.nickname)
+ classic_crawler.retrieve_feed(loop, user, feed_id)
loop.close()
bgstack15