-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from paramt/refactor
Refactor code
- Loading branch information
Showing
10 changed files
with
68 additions
and
59 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [[ ! $@ ]]; then | ||
python -m videocloud -h | ||
else | ||
python -m videocloud $@ | ||
fi |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import setuptools | ||
|
||
with open("README.md") as f: | ||
long_description = f.read() | ||
|
||
setuptools.setup( | ||
name="VideoCloud", | ||
version="1.1", | ||
url="https://github.com/paramt/VideoCloud", | ||
license="MIT", | ||
author="Param Thakkar", | ||
author_email="contact@param.me", | ||
description="A command line tool that generates word clouds from YouTube video captions", | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
scripts=["./scripts/videocloud"], | ||
packages=["videocloud"], | ||
install_requires=[ | ||
"setuptools", | ||
"pillow==6.0.0", | ||
"wordcloud==1.5.0", | ||
"youtube-transcript-api==0.1.4" | ||
], | ||
python_requires=">= 3.6" | ||
) |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import os | ||
import sys | ||
from videocloud.utilities import get_video_id, generate_word_cloud as word_cloud, get_captions as get_cc | ||
from youtube_transcript_api import YouTubeTranscriptApi as ytcc | ||
|
||
|
||
def main(url: str, filepath): | ||
try: | ||
video_id = get_video_id(url) | ||
captions = get_cc(video_id) | ||
image = word_cloud(captions) | ||
image.save(filepath) | ||
except ytcc.CouldNotRetrieveTranscript: | ||
print("The specified video either doesn't exist or doesn't have captions enabled. Please try again") | ||
exit() | ||
except IOError: | ||
print("There was an error saving the wordcloud file") | ||
exit() | ||
|
||
return os.path.abspath(filepath) | ||
|
||
if __name__ == "__main__": | ||
try: | ||
video_id = sys.argv[1] | ||
except: | ||
print("Please specify a YouTube video link or video ID") | ||
exit() | ||
|
||
try: | ||
filepath = sys.argv[2] | ||
except IndexError: | ||
filepath = "wordcloud.png" | ||
|
||
wordcloud = main(video_id, filepath) | ||
print(f"Wordcloud created in {wordcloud}") |
File renamed without changes.
This file contains 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