Playlist resume support + playlist auto organization in folders support

This commit is contained in:
thecookingsenpai 2023-12-27 23:40:23 +01:00
parent 05c4393ba1
commit 1740bca6e3
3 changed files with 30 additions and 6 deletions

View File

@ -36,11 +36,17 @@ TransTerm is an highly experimental text based graphical user interface to act o
Being text based, this program runs even in the terminal.
## Latest changelog
Added experimental playlist folder support and playlist resume support.
Please report any issues.
## Features
- Download any youtube video at the highest resolution by default in mp4 format
- Is able to automatically convert the downloaded video both in mp3 or wav format
- Playlist support for the above features including automatically rename the files using the video title and the channel name
- Playlists organization in folders with resume support (aka check if files are already there with the same title and channel)
- Transcribe a ssingle downloaded video using either:
• Google Audio to Text
• Google Audio to Text + Silence detection

View File

@ -1 +0,0 @@
why are you looking at me, my only purpose is to create my parent folder

29
term.py
View File

@ -14,6 +14,17 @@ forceQuit = False
r = sr.Recognizer()
# NOTE: WIP This method is intended to be called to check for the same file (by using slugified name)
def existing(filename):
path_to_download_folder = (
str(os.path.dirname(os.path.realpath(__file__))) + "/downloads"
)
for file in os.listdir(path_to_download_folder):
if filename is file:
return True
return False
# NOTE: Taken from https://stackoverflow.com/questions/295135/turn-a-string-into-a-valid-filename
def slugify(value, allow_unicode=False):
"""
@ -142,18 +153,26 @@ def managePlaylist(playlist, to_download=False, to_convert=False, named=True):
if not to_download:
return playlist
counter = 0
normalized_title = slugify(playlist.title)
path_to_download_folder = (
str(os.path.dirname(os.path.realpath(__file__))) + "/downloads"
str(os.path.dirname(os.path.realpath(__file__)))
+ "/downloads/"
+ normalized_title
)
# Creating a folder for the playlist if it doesn't exist
if not os.path.isdir(path_to_download_folder):
os.mkdir(path_to_download_folder)
# Iterating and doing our job(s)
for url in playlist:
counter += 1
print("Downloading video", counter, "of", len(playlist))
ytvideo = YouTube(url)
filename = slugify(ytvideo.title + "_" + ytvideo.author)
# EXPERIMENTAL Skip if file already exists (aka resume playlist download)
if existing(filename):
print("File already exists: [" + filename + "]\nskipping...")
continue
video = ytvideo.streams.get_highest_resolution()
filename = "video_" + str(counter)
# Experimental name support
if named:
filename = slugify(ytvideo.title + "_" + ytvideo.author)
print("Downloading : ", filename)
video.download(path_to_download_folder, filename=filename + ".mp4")
if to_convert: