Created
April 25, 2017 14:22
-
-
Save quanon/f63f2635427bf7930f13b67b16abdf32 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import re | |
import sys | |
import time | |
from urllib.request import urlretrieve | |
channel = sys.argv[1] | |
with open(f'{channel}.txt', 'rt') as f: | |
lines = f.readlines() | |
if not os.path.exists(channel): | |
os.makedirs(channel) | |
for url in lines: | |
name = re.findall(r'(?<=vi/).*(?=/hqdefault)', url)[0] | |
path = os.path.join(channel, f'{name}.jpg') | |
if os.path.exists(path): | |
print(f'{path} already exists') | |
continue | |
print(f'download {path}') | |
urlretrieve(url, path) | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment