diff --git a/filler.py b/filler.py index 999c893..1c69e52 100755 --- a/filler.py +++ b/filler.py @@ -1,6 +1,16 @@ #!/usr/bin/env python3 -import argparse, dbtools, dbtools.fillerfilter, setuptools, time, twitools +import argparse, dbtools, dbtools.fillerfilter, requests, setuptools, time, twitools + +def downloadMedia(url, tid, mid): + remote = requests.get(url, stream=True) + filename = "media/%i_%i.%s" % (tid, mid, url.split(".")[-1]) + + with open(filename, 'wb') as outfile: + for chunk in remote.iter_content(chunk_size=1024): + if chunk: + outfile.write(chunk) + outfile.flush() def getTweets(db=dbtools.dbHelper(), user=twitools.twObject().whoami(), two=twitools.twObject()): query = "from:" + user