Skip to content

Instantly share code, notes, and snippets.

@Miserlou
Created November 7, 2017 19:36
Show Gist options
  • Save Miserlou/da7b7534cf729a488b93337dd6184f57 to your computer and use it in GitHub Desktop.
Save Miserlou/da7b7534cf729a488b93337dd6184f57 to your computer and use it in GitHub Desktop.
def process_submission(submission):
""" """
##
# Filter
##
if submission.over_18:
print("No porno!")
return
# This is too difficult
# need to switch to whitelist-only
banned_subs = [
'celebgifs',
'celebgfys'
'hentai_gif',
'hentai',
'celebs'
]
sub = submission.subreddit.url.split('r/')[1].replace('/', '').lower()
if sub in banned_subs:
print("No porno subs!")
return
##
# Download
##
print("Downloading..")
outfile = "/tmp/" + str(time.time()) + ".mp4"
hls_url = submission.media['reddit_video']['hls_url']
try:
subprocess.check_output(["/usr/bin/python2.7", "./youtube_dl/__main__.py", hls_url, "-o", outfile, "--ffmpeg-location", "ffmpeg-3.4-64bit-static/"])
except subprocess.CalledProcessError as e:
raise RuntimeError("command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output, str(e)))
if not os.path.isfile(outfile):
print ("Fail!")
return
print("Download worked!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment