[twitter] fix problem of pagination while using list command without configured user.

The process retrieved all tweets from each account.
The command was then unusable.
This commit is contained in:
Bezleputh 2014-06-19 18:14:27 +02:00
commit 49a665303b

View file

@ -26,7 +26,7 @@ from weboob.capabilities.collection import ICapCollection, CollectionNotFound, C
from weboob.capabilities.base import find_object from weboob.capabilities.base import find_object
from weboob.tools.exceptions import BrowserForbidden from weboob.tools.exceptions import BrowserForbidden
from .browser import TwitterBrowser from .browser import TwitterBrowser
import itertools
__all__ = ['TwitterBackend'] __all__ = ['TwitterBackend']
@ -66,17 +66,17 @@ class TwitterBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapCollection
tweets = [] tweets = []
if profils: if profils:
for profil in profils.split(','): for profil in profils.split(','):
for tweet in self.browser.get_tweets_from_profil(profil): for tweet in itertools.islice(self.browser.get_tweets_from_profil(profil), 0, 20):
tweets.append(tweet) tweets.append(tweet)
if hashtags: if hashtags:
for hashtag in hashtags.split(','): for hashtag in hashtags.split(','):
for tweet in self.browser.get_tweets_from_hashtag(hashtag): for tweet in itertools.islice(self.browser.get_tweets_from_hashtag(hashtag), 0, 20):
tweets.append(tweet) tweets.append(tweet)
if searchs: if searchs:
for search in searchs.split(','): for search in searchs.split(','):
for tweet in self.browser.get_tweets_from_search(search): for tweet in itertools.islice(self.browser.get_tweets_from_search(search), 0 ,20):
tweets.append(tweet) tweets.append(tweet)
tweets.sort(key=lambda o: o.date, reverse=True) tweets.sort(key=lambda o: o.date, reverse=True)