Added tweet-text from database instead of staticly.
This commit is contained in:
@@ -3,10 +3,13 @@
|
|||||||
# @Author: KevinMidboe
|
# @Author: KevinMidboe
|
||||||
# @Date: 2017-03-04 14:06:53
|
# @Date: 2017-03-04 14:06:53
|
||||||
# @Last Modified by: KevinMidboe
|
# @Last Modified by: KevinMidboe
|
||||||
# @Last Modified time: 2017-03-04 22:16:45
|
# @Last Modified time: 2017-03-05 11:48:47
|
||||||
|
|
||||||
import tweepy
|
import tweepy, sqlite3
|
||||||
from pasteee import Paste
|
from pasteee import Paste
|
||||||
|
from pprint import pprint
|
||||||
|
|
||||||
|
dbPath = "shows.db"
|
||||||
|
|
||||||
consumer_key, consumer_secret = 'yvVTrxNtVsLkoHxKWxh4xvgjg', '39OW6Q8fIKDXvTPPCaEJDULcYaHC5XZ3fe7HHCGtdepBKui2jK'
|
consumer_key, consumer_secret = 'yvVTrxNtVsLkoHxKWxh4xvgjg', '39OW6Q8fIKDXvTPPCaEJDULcYaHC5XZ3fe7HHCGtdepBKui2jK'
|
||||||
access_token, access_token_secret = '3214835117-OXVVLYeqUScRAPMqfVw5hS8NI63zPnWOVK63C5I', 'ClcGnF8vW6DbvgRgjwU6YjDc9f2oxMzOvUAN8kzpsmbcL'
|
access_token, access_token_secret = '3214835117-OXVVLYeqUScRAPMqfVw5hS8NI63zPnWOVK63C5I', 'ClcGnF8vW6DbvgRgjwU6YjDc9f2oxMzOvUAN8kzpsmbcL'
|
||||||
@@ -17,17 +20,45 @@ api = tweepy.API(auth)
|
|||||||
apiUser = api.me()
|
apiUser = api.me()
|
||||||
apiUsername, apiUserID = apiUser.screen_name, apiUser.id_str
|
apiUsername, apiUserID = apiUser.screen_name, apiUser.id_str
|
||||||
|
|
||||||
pasteText = '''episode': '18',
|
|
||||||
'full_path': '/Volumes/media/tv/New.Girl.S06E18.720p.HDTV.x264-FLEET',
|
def tweetNewEpisode(episode):
|
||||||
'media_items': [['New.Girl.S06E18.720p.HDTV.x264-FLEET.mkv', '-FLEET']],
|
createPasteee()
|
||||||
'name': 'New Girl',
|
|
||||||
'original': 'New.Girl.S06E18.720p.HDTV.x264-FLEET',
|
def unpackEpisode(episode):
|
||||||
'season': '06',
|
episodeDict = dict.fromkeys(['original', 'full_path', 'name', 'season', 'episode',\
|
||||||
'subtitles': [['New.Girl.S06E18.720p.HDTV.x264-EZTV.srt', '-EZTV', 'nl'],
|
'media_items', 'subtitles', 'trash', 'tweet_id', 'verified'])
|
||||||
['New.Girl.S06E18.720p.HDTV.x264-FLEET.srt', '-FLEET', 'en']],
|
|
||||||
'trash': ['Screens',
|
for i, key in enumerate(episodeDict.keys()):
|
||||||
'new.girl.s06e18.720p.hdtv.x264-fleet.nfo',
|
episodeDict[key] = episode[i]
|
||||||
'Torrent Downloaded From www.torrenting.me.txt']'''
|
|
||||||
|
return episodeDict
|
||||||
|
|
||||||
|
def
|
||||||
|
|
||||||
|
def updateTweetID(episodeDict, id):
|
||||||
|
conn = sqlite3.connect(dbPath)
|
||||||
|
c = conn.cursor()
|
||||||
|
|
||||||
|
c.execute('UPDATE stray_episodes SET tweet_id = ' + id + ' WHERE original is ' + episodeDict['original'])
|
||||||
|
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
def getUntweetedEpisodes():
|
||||||
|
conn = sqlite3.connect(dbPath)
|
||||||
|
c = conn.cursor()
|
||||||
|
|
||||||
|
c.execute('SELECT * FROM stray_episodes WHERE tweet_id is NULL')
|
||||||
|
|
||||||
|
for episode in c.fetchall():
|
||||||
|
tweetNewEpisode(episode)
|
||||||
|
|
||||||
|
conn.close()
|
||||||
|
exit(0)
|
||||||
|
return episode
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def lastTweet(user, count=1):
|
def lastTweet(user, count=1):
|
||||||
return api.user_timeline(screen_name=user,count=count)
|
return api.user_timeline(screen_name=user,count=count)
|
||||||
@@ -36,22 +67,36 @@ def checkReply():
|
|||||||
originalTweet = lastTweet('pi_midboe')[0]
|
originalTweet = lastTweet('pi_midboe')[0]
|
||||||
originalID, lastText = originalTweet.id_str, originalTweet.text
|
originalID, lastText = originalTweet.id_str, originalTweet.text
|
||||||
|
|
||||||
tweets = lastTweet('KevinMidboe', 40)
|
tweets = lastTweet('KevinMidboe', 10)
|
||||||
|
|
||||||
for tweet in tweets:
|
for tweet in tweets:
|
||||||
tweetID = tweet.in_reply_to_status_id_str
|
tweetID = tweet.in_reply_to_status_id_str
|
||||||
if tweetID == originalID:
|
if tweetID == originalID:
|
||||||
print(tweet.text)
|
print(tweet.text)
|
||||||
|
|
||||||
|
def unpackEpisodes():
|
||||||
|
conn = sqlite3.connect(dbPath)
|
||||||
|
c = conn.cursor()
|
||||||
|
|
||||||
|
c.execute('SELECT * FROM stray_episodes WHERE tweet_id IS NULL and verified IS 0')
|
||||||
|
|
||||||
|
content = c.fetchall()
|
||||||
|
conn.close()
|
||||||
|
return content
|
||||||
|
|
||||||
|
|
||||||
def tweet(tweetString):
|
def tweet(tweetString):
|
||||||
if not lastTweet('pi_midboe')[0].text.startswith(tweetString):
|
if not lastTweet('pi_midboe')[0].text.startswith(tweetString):
|
||||||
paste = Paste(pasteText, private=False, desc="My first paste", views=2)
|
paste = Paste(unpackEpisodes(), private=False, desc="My first paste", views=2)
|
||||||
tweetString += paste['raw']
|
tweetString += paste['raw']
|
||||||
response = api.update_status(status=tweetString)
|
response = api.update_status(status=tweetString)
|
||||||
print('\n', response.text)
|
print('\n', response.id_str)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
episode = getUntweetedEpisodes()
|
||||||
|
print(episode)
|
||||||
tweet('@KevinMidboe\nAdded episode: \nNew Girl S06E16\n\nDetails: ')
|
tweet('@KevinMidboe\nAdded episode: \nNew Girl S06E16\n\nDetails: ')
|
||||||
|
# unpackEpisodes()
|
||||||
checkReply()
|
checkReply()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user