mirror of
https://github.com/tcsenpai/TransTerm.git
synced 2025-06-04 10:20:19 +00:00
Playlist resume support + playlist auto organization in folders support
This commit is contained in:
parent
05c4393ba1
commit
1740bca6e3
@ -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.
|
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
|
## Features
|
||||||
|
|
||||||
- Download any youtube video at the highest resolution by default in mp4 format
|
- 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
|
- 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
|
- 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:
|
- Transcribe a ssingle downloaded video using either:
|
||||||
• Google Audio to Text
|
• Google Audio to Text
|
||||||
• Google Audio to Text + Silence detection
|
• Google Audio to Text + Silence detection
|
||||||
|
@ -1 +0,0 @@
|
|||||||
why are you looking at me, my only purpose is to create my parent folder
|
|
29
term.py
29
term.py
@ -14,6 +14,17 @@ forceQuit = False
|
|||||||
r = sr.Recognizer()
|
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
|
# NOTE: Taken from https://stackoverflow.com/questions/295135/turn-a-string-into-a-valid-filename
|
||||||
def slugify(value, allow_unicode=False):
|
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:
|
if not to_download:
|
||||||
return playlist
|
return playlist
|
||||||
counter = 0
|
counter = 0
|
||||||
|
normalized_title = slugify(playlist.title)
|
||||||
path_to_download_folder = (
|
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:
|
for url in playlist:
|
||||||
counter += 1
|
counter += 1
|
||||||
print("Downloading video", counter, "of", len(playlist))
|
print("Downloading video", counter, "of", len(playlist))
|
||||||
ytvideo = YouTube(url)
|
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()
|
video = ytvideo.streams.get_highest_resolution()
|
||||||
filename = "video_" + str(counter)
|
|
||||||
# Experimental name support
|
|
||||||
if named:
|
|
||||||
filename = slugify(ytvideo.title + "_" + ytvideo.author)
|
|
||||||
print("Downloading : ", filename)
|
print("Downloading : ", filename)
|
||||||
video.download(path_to_download_folder, filename=filename + ".mp4")
|
video.download(path_to_download_folder, filename=filename + ".mp4")
|
||||||
if to_convert:
|
if to_convert:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user