i haven’t posted in a while, here’s a nifty script

tech — commander flatus @ 9:02 pm October 13, 2017

there are lots of queries everywhere about how to script PRAW and youtube-dl to download videos off Reddit subs (i use this to load my Plex server with relevant music videos). here it is (it’ll take a CLI of the sub you want to scrape and get the “Hot” 10 links:

import praw
import youtube_dl
import sys
#import urllib

r = praw.Reddit(client_id='
insert your info here',
                     client_secret='insert your info here',
insert your info here',
                     user_agent='insert your info here',
                     username='insert your info here')

urls = []

def yt() :
for submission in r.subreddit(sys.argv[1]).hot(limit=10):
return urls

yt_urls = yt()
ydl_opts = {'ignoreerrors': 'False'}
ydl = youtube_dl.YoutubeDL(ydl_opts)

for item in yt_urls:
#print([item, ])
ydl.download([item, ])

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2021 polydipsia | powered by WordPress with Barecity