Skip to content

Commit

Permalink
cleaning up files
Browse files Browse the repository at this point in the history
  • Loading branch information
ClarityCoders committed Nov 20, 2021
1 parent 2e45d7e commit 91df03a
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 23 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
__pycache__
client_secrets.json
*.json
*.mp4
*.mp4
video.mp4
11 changes: 3 additions & 8 deletions CreateMovie.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def CreateMP4(cls, post_data):

clips = []
for post in post_data:
print(post['image_path'])
if "gif" not in post['image_path']:
clip = ImageSequenceClip([post['image_path']], durations=[12])
clips.append(clip)
Expand All @@ -49,7 +48,6 @@ def CreateMP4(cls, post_data):
text_clips = []
notification_sounds = []
for i, post in enumerate(post_data):
print(post['Best_comment'])
return_comment, return_count = add_return_comment(post['Best_comment'])
txt = TextClip(return_comment, font='Courier',
fontsize=38, color=colors.pop(), bg_color='black')
Expand All @@ -62,20 +60,18 @@ def CreateMP4(cls, post_data):
return_comment, _ = add_return_comment(post['best_reply'])
txt = TextClip(return_comment, font='Courier',
fontsize=38, color=colors.pop(), bg_color='black')
#print(TextClip.list('color'))

txt = txt.set_position((15,585 + (return_count * 50)))
txt = txt.set_start((0, 5 + (i * 12))) # (min, s)
txt = txt.set_duration(7)
txt = txt.crossfadein(0.5)
txt = txt.crossfadeout(0.5)
text_clips.append(txt)
notification = AudioFileClip("notification.mp3")
notification = AudioFileClip(os.path.join(music_path, f"notification.mp3"))
notification = notification.set_start((0, 3 + (i * 12)))
#notification = notification.set_duration(2)
notification_sounds.append(notification)
notification = AudioFileClip("notification.mp3")
notification = AudioFileClip(os.path.join(music_path, f"notification.mp3"))
notification = notification.set_start((0, 5 + (i * 12)))
#notification = notification.set_duration(2)
notification_sounds.append(notification)

music_file = os.path.join(music_path, f"music{random.randint(0,4)}.mp3")
Expand All @@ -84,7 +80,6 @@ def CreateMP4(cls, post_data):
music = music.volumex(.4)
music = music.set_duration(59)

notification = AudioFileClip("notification.mp3")
new_audioclip = CompositeAudioClip([music]+notification_sounds)

clip = CompositeVideoClip([clip] + text_clips)
Expand Down
File renamed without changes.
25 changes: 15 additions & 10 deletions RedditBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ def __init__(self):
self.data_path = os.path.join(dir_path, "data/")
self.post_data = []
self.already_posted = []
if os.path.isfile("posted_already.json"):
with open("posted_already.json", "r") as file:

# Check for a posted_already.json file
self.posted_already_path = os.path.join(self.data_path, "posted_already.json")
if os.path.isfile(self.posted_already_path):
print("Loading posted_already.json from data folder.")
with open(self.posted_already_path, "r") as file:
self.already_posted = json.load(file)
#print(self.already_posted)

def get_posts(self):
self.post_data = []
Expand Down Expand Up @@ -82,12 +85,19 @@ def save_image(self, submission):
best_comment.refresh()
replies = best_comment.replies

best_reply = None
for top_level_comment in replies:
# Here you can fetch data off the comment.
# For the sake of example, we're just printing the comment body.
best_reply = top_level_comment
if len(best_reply.body) <= 140 and "http" not in best_reply.body:
break

"incase no best reply"
if best_reply is not None:
best_reply = best_reply.body
else:
best_reply = "MIA"

data_file = {
"image_path": image_path,
Expand All @@ -96,21 +106,17 @@ def save_image(self, submission):
"score": submission.score,
"18": submission.over_18,
"Best_comment": best_comment.body,
"best_reply": best_reply.body
"best_reply": best_reply
}

self.post_data.append(data_file)
self.already_posted.append(submission.id)
with open(f"{data_folder_path}{submission.id}.json", "w") as outfile:
json.dump(data_file, outfile)
with open("posted_already.json", "w") as outfile:
with open(self.posted_already_path, "w") as outfile:
json.dump(self.already_posted, outfile)
else:
return None

#except Exception as e:
# print(f"Image failed. {submission.url.lower()}")
# print(e)

if __name__ == "__main__":
redditbot = RedditBot()
Expand All @@ -120,7 +126,6 @@ def save_image(self, submission):
redditbot.create_data_folder()

for post in posts:
#print(post.title, post.url, post.permalink)
redditbot.save_image(post)

#redditbot.create_movie()
2 changes: 0 additions & 2 deletions Scalegif.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ def scale_gif(path, scale, new_path=None):
'extension': gif.info.get('extension', (b'NETSCAPE2.0')),
'transparency': gif.info.get('transparency', 223)
}
print(path)
print(old_gif_information)
new_frames = get_new_frames(gif, scale)
save_new_gif(new_frames, old_gif_information, new_path)
else:
Expand Down
6 changes: 4 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def GetDaySuffix(day):
"privacyStatus":"public"
}
print(video_data["title"])
print("Printing in 60 seconds...")
time.sleep(60)
print("Posting Video in 5 minutes...")
time.sleep(60 * 5)
#update_video(video_data)

# Sleep until ready to post another video!
time.sleep(60 * 60 * 24 - 1)

0 comments on commit 91df03a

Please sign in to comment.