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

reorganized the code #21

Merged
merged 2 commits into from Feb 3, 2022
Merged

reorganized the code #21

merged 2 commits into from Feb 3, 2022

Conversation

iaacornus
Copy link
Contributor

  • The spinner in download function were put back again, since it does not cause any error. During my testing before putting the spinner, the program is already returning only 143 or only 140's episode, not 300+, so I think it is rather a source problem. But I still didn't touched the Play function, only the download function.
  • The code were also reorganized, the one prominent changes made is the function were passed onto each other instead of putting the returned value to another variable that will be used by another function. So instead of this :
...
source = VideoSource(episodes[x+1])
Download(source)
print(f"Episode {x+1} downloaded!", end="")
...

This was done instead :

...
Download(VideoSource(episodes[x+1]))
...
  • raise SystemExit(ERROR_MESSAGE) was also used instead of :
...
print(ERROR_MESSAGE)
sys.exit()
...

since this one is more efficient.

  • Duplicates of except KeyboardInterrupt were also removed.
  • the output of subprocess calling youtube-dl were also redirected back into subprocess.DEVNULL and its STDERROR were also redirected back into subprocess.STDOUT
  • else block were also used instead of try/except in some cases.
  • Also, instead of specifying the number of episodes in list function, len(episodes) were used instead to avoid error.

@iaacornus
Copy link
Contributor Author

iaacornus commented Feb 3, 2022

I limited the use of other functions to optimize the memory usage of the application, I also removed duplication as much as I can.

It is also good to note that I also called os.system("clear") and the list function every continue or repeat in while True block, since the program is under verbose mode especially the Play function.

spongebob-cli Show resolved Hide resolved
Copy link
Owner

@trakBan trakBan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing to spongebob-cli. Approved

@trakBan trakBan merged commit 68526aa into trakBan:main Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants