Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add verbose parameter #23

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 28 additions & 12 deletions spongebob-cli
Expand Up @@ -58,13 +58,17 @@ def Play(DirectLink):
print(colored("\nAn error occured while tying to play the video! Make sure you have mpv or youtube-dl installed.", "red"))


@Halo(text="Downloading episode.", spinner="shark", color="green")
def Download(source):
def Download(source, args3=False):
try:
subprocess.run(["youtube-dl", source],
stdout=subprocess.DEVNULL,
stderr=subprocess.STDOUT)

if args3 is False:
with Halo(text="Downloading episode.", spinner="shark", color="green"):
subprocess.run(["youtube-dl", source],
stdout=subprocess.DEVNULL,
stderr=subprocess.STDOUT)
else:
subprocess.run(["youtube-dl", source])


print(colored("\nDownload complete!", "green"))

except ImportError or subprocess.CalledProcessError:
Expand Down Expand Up @@ -101,13 +105,19 @@ except:
pass


# Download Function
try:
# Download Function
if args.replace(' ', '') in ["--download", "-d"]:
try:
args2 = int(args2)
try:
args3 = sys.argv[3]
except:
args3 = False
else:
args3 = True

print(f"Downloading episode {colored(args2, 'cyan')}")
Download(VideoSource(episodes[args2 - 1]))
Download(VideoSource(episodes[int(args2) - 1]), args3)

except IndexError or ValueError:
print(colored("No arguments passed with download function or the index is out of range, aborting...!", "red"))
Expand All @@ -116,11 +126,18 @@ try:
elif args.replace(' ', '') in ["--download-all", "-da"]:
dled = 0
try:
try:
args3 = sys.argv[2]
except:
args3 = False
else:
args3 = True

print(colored(f"Downloading all fetched episodes : {len(episodes)}", "green"))

for x in range(len(episodes)):
print(f"Downloading episode {colored(x+1, 'cyan')}")
Download(VideoSource(episodes[x+1]))
Download(VideoSource(episodes[x+1]), args3)
print(f"Episode {x+1} downloaded!", end="") ; time.sleep(2) ; print("\r", end="")
dled += 1
continue
Expand Down Expand Up @@ -159,8 +176,7 @@ try:
# Play function
elif args.replace(' ', '') in ["--play", "-p"]:
try:
args2 = int(args2)
Play(VideoSource(episodes[args2 - 1]))
Play(VideoSource(episodes[int(args2) - 1]))

except ValueError or IndexError:
print(colored("No arguments were passed with the play function or the index is out of range, aborting...", "red"))
Expand Down