Skip to content

Instantly share code, notes, and snippets.

@masala-man
Last active July 30, 2021 14:12
Show Gist options
  • Save masala-man/8ef03413319c87b9ac3d6f7cc87a1ae2 to your computer and use it in GitHub Desktop.
Save masala-man/8ef03413319c87b9ac3d6f7cc87a1ae2 to your computer and use it in GitHub Desktop.
Download youtube videos listed in a file to flac format and rename
import os
import re
import string
fileName = ''
vidReg = re.compile(r'youtube\.com')
fileRead = open('./req.txt')
length = len(open('./req.txt').readlines( ))
video = fileRead.readlines()
for x in range(length):
cut = video[x]
cut = cut[:-1]
video[x] = cut
for x in range(length):
vidMatch = vidReg.search(video[x])
if vidMatch != None:
if len(fileName) > 0:
os.system('youtube-dl -x --audio-format flac ' + ' -o \"' + fileName + '.%(ext)s\" ' + video[x] )
else:
os.system('youtube-dl -x --audio-format flac ' + video[x])
else:
fileName = video[x]
#--req.txt--
#Namana Natavara
#https://www.youtube.com/watch?v=enC-zfmvbcs
#Lagi Kalejwa Katar
#https://www.youtube.com/watch?v=Ww6aQe7qqWQ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment