forked from seru1us/DownCloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
downcloud.py
41 lines (31 loc) · 1.08 KB
/
downcloud.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import os
import praw
import subprocess
import sys
import youtube_dl
reddit = praw.Reddit(client_id='YOUR_CLIENT ID',
client_secret='YOUR_SECRET',
password='YOUR_PASS',
user_agent='/u/will_work_for_twerk is a sexy b',
username='YOUR_USER')
subarg = reddit.subreddit(sys.argv[1])
slash = "/"
for submission in reddit.subreddit(str(subarg)).search('site:soundcloud.com', limit=None):
dalink = slash.join(submission.url.split(slash)[:4])
print(dalink)
try:
directory = submission.secure_media['oembed']['author_name']
except Exception:
directory = dalink.split(slash)[-1]
odirectory = directory.strip() + '/%(title)s.%(ext)s'
ydl_opts = {
'format': 'bestaudio/best',
'outtmpl': odirectory,
'ignoreerrors': True
}
if not os.path.exists(directory):
os.makedirs(directory)
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([dalink])
else:
print('Artist ' + directory + ' already exists, skipping...')