use more-itertools; merge tweets
This commit is contained in:
parent
30b6918a8d
commit
69a1624f8f
1 changed files with 15 additions and 3 deletions
|
@ -1,17 +1,29 @@
|
||||||
"""
|
"""
|
||||||
Unified Twitter data (merged from the archive and periodic updates)
|
Unified Twitter data (merged from the archive and periodic updates)
|
||||||
"""
|
"""
|
||||||
|
from itertools import chain
|
||||||
|
|
||||||
from . import twint
|
from . import twint
|
||||||
from . import archive
|
from . import archive
|
||||||
|
|
||||||
|
|
||||||
|
from more_itertools import unique_everseen
|
||||||
|
|
||||||
|
|
||||||
|
def merge_tweets(*sources):
|
||||||
|
yield from unique_everseen(
|
||||||
|
chain(*sources),
|
||||||
|
key=lambda t: t.id_str,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def tweets():
|
def tweets():
|
||||||
yield from archive.tweets()
|
# NOTE order matters.. twint seems to contain better data
|
||||||
yield from twint.tweets()
|
# todo probably, worthy an investigation..
|
||||||
|
yield from merge_tweets(twint.tweets(), archive.tweets())
|
||||||
|
|
||||||
|
|
||||||
# TODO not sure, likes vs favoites??
|
# TODO not sure, likes vs favoites??
|
||||||
def likes():
|
def likes():
|
||||||
yield from archive.likes()
|
yield from merge_tweets(archive.likes())
|
||||||
# yield from twint
|
# yield from twint
|
||||||
|
|
Loading…
Add table
Reference in a new issue