Created
August 11, 2016 21:11
-
-
Save Ishibasystems/512dc8ff5a95fa441fb4215455bba0b8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python3 | |
# -*- coding: utf-8 -*- | |
import tweepy | |
import datetime | |
from os import mkdir | |
from sys import exit, path | |
from time import sleep | |
from time import mktime | |
from os.path import exists | |
from modules import text, machine, log | |
#from calendar import timegm | |
from traceback import format_exc | |
from itertools import zip_longest | |
from urllib.request import urlopen | |
#!/usr/local/bin/python3 | |
# -*- coding: utf-8 -*- | |
import tweepy | |
import datetime | |
from sys import exit | |
from time import sleep | |
from os.path import exists | |
from modules import pushbullet, text, machine | |
from traceback import format_exc | |
conf = machine.set() | |
base = conf['machine']['basedir'] | |
list_name = 'tweepy-list' | |
acc_name = conf[list_name]['own'] | |
AC_lst = conf[list_name]['list'] | |
CS_key = conf[acc_name]['app_key'] | |
CS_sec = conf[acc_name]['app_sec'] | |
AC_key = conf[acc_name]['usr_key'] | |
AC_sec = conf[acc_name]['usr_sec'] | |
list_tweets = base + 'tweets+.txt' | |
download_photo = "/mnt/download/twitter/" | |
download_video = "/mnt/download/video/vine/" | |
extensions = { | |
'image/gif' : 'gif', | |
'image/jpg' : 'jpg', | |
'image/jpeg' : 'jpg', | |
'image/pjpeg' : 'jpg', | |
'image/x-png' : 'png', | |
'image/png' : 'png', | |
} | |
times = [ | |
datetime.datetime(2016, 8, 9, 5, 40, 0, 0), | |
datetime.datetime(2016, 8, 9, 8, 40, 0, 0), | |
datetime.datetime(2016, 8, 9, 10, 20, 0, 0), | |
datetime.datetime(2016, 8, 9, 12, 10, 0, 0), | |
datetime.datetime(2016, 8, 9, 12, 40, 0, 0), | |
datetime.datetime(2016, 8, 9, 15, 10, 0, 0), | |
] | |
def main(): | |
auth = tweepy.OAuthHandler(CS_key, CS_sec) | |
auth.set_access_token(AC_key, AC_sec) | |
api = tweepy.API(auth_handler = auth) | |
statuses_url = dict() | |
max = times[0] | |
since = max - datetime.timedelta(minutes = 25) | |
since_id = int(mktime(since.timetuple()) * 1000 - 1288834974657) << 22 | |
max_id = int(mktime(max.timetuple()) * 1000 - 1288834974657) << 22 | |
#since_id = (timegm(since.timetuple()) * 1000 - 1288834974657) << 22 | |
#max_id = (timegm(max.timetuple()) * 1000 - 1288834974657) << 22) | |
mini = 800000000000000000 | |
maxi = 0 | |
try: | |
#statuses_list = tweepy.Cursor(api.list_timeline, list_id = int(AC_lst), since_id = since_id, include_rts = True, count = 200) | |
members_list = tweepy.Cursor(api.list_members, list_id = int(AC_lst), count = 5000) | |
except: | |
print(format_exc() + 'API.list_timeline Error!\n') | |
exit(1) | |
note = '' | |
for members in members_list.pages(): | |
sleep(5) | |
for member in members: | |
print(member.screen_name) | |
note += str(len(members)) + '+' | |
print(note) | |
exit(0) | |
pages = 0 | |
for statuses in statuses_list.pages(): | |
sleep(5) | |
if len(statuses) == 0: | |
break | |
for status in statuses: | |
statuses_url[status.id_str] = 'user: ' + status.author.screen_name + '/status/' + status.id_str | |
list_tweets | |
pages += 1 | |
if pages > 15: | |
print('WARNING: PAGE OVER') | |
break | |
#print(datetime.datetime.fromtimestamp(((mini >> 22) + 1288834974657) / 1000)) | |
#print(datetime.datetime.fromtimestamp(((maxi >> 22) + 1288834974657) / 1000)) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment