Last active
February 22, 2023 06:25
-
-
Save StevenRCE0/574a8fa35c7ab27e1376622e2e9f9189 to your computer and use it in GitHub Desktop.
I love StreetVoice and Accusefive the band!
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 time | |
import wget | |
from urllib.error import HTTPError | |
import re | |
url = input("URL: ") | |
url = re.sub(r'(\-[0-9]+)\.ts', '', url) | |
try: | |
if not os.path.exists('./ts'): | |
os.mkdir('./ts') | |
for i in range(1, 100): | |
fiveDigit = str(i).zfill(5) | |
downloadUrl = url + "-" + fiveDigit + ".ts" | |
print(downloadUrl) | |
wget.download(downloadUrl, "ts/" + fiveDigit + ".ts") | |
time.sleep(0.5) | |
except HTTPError as error: | |
if error.code == 404: | |
print("Download complete") | |
else: | |
raise | |
except: | |
raise | |
with open('merge.txt', 'w') as merge: | |
# list files in the directory | |
directory = './ts' | |
files = os.listdir(directory) | |
files.sort() | |
for file in files: | |
merge.write('file ./ts/' + str(file) + '\n') | |
filename = input("Filename: ") | |
# use ffmpeg to merge the ts files | |
os.system('ffmpeg -f concat -safe 0 -i merge.txt -c copy \'' + | |
filename + '.mp3\'') | |
os.system('rm ./ts/*') | |
os.system('rm ./merge.txt') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment