Add file downloader to filler

This commit is contained in:
Klaus-Uwe Mitterer 2017-02-27 00:39:34 +01:00
parent 0856063459
commit 45890fd103

View file

@ -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