import os
path = './videos'
videos_dir = ['240', '360', '480', '720']
def write_file(name_file, text):
with open(name_file, 'a') as file:
file.write(text)
def read_file(name_file):
with open(name_file, 'r') as lines:
for line in lines:
write_file(path+'/'+line.split('.')[-2]+'/'+'links.txt', line)
for dir in videos_dir:
try:
os.makedirs(path+'/'+dir)
except FileExistsError:
continue
read_file('link.txt')