-
Notifications
You must be signed in to change notification settings - Fork 19
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
Added Preview and stored in db #39
Conversation
arpit3018
commented
Dec 27, 2018
- Added youtube url preview
- Stored the data received by youtube api to database
- Modified Readme.md
71b1eec
to
5c60d58
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arpit3018 Make the suggested changes.
learn/views.py
Outdated
if "watch" in url: | ||
#Identifies that it is a video | ||
temp,slug = url.split("watch?v=") | ||
import os |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per PEP8 convention, import should not be inside any function or class. It should be on the top of the file.
learn/views.py
Outdated
#Identifies that it is a video | ||
temp,slug = url.split("watch?v=") | ||
import os | ||
api_key = os.getenv("YOUTUBE_API_KEY") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic to fetch confidential keys from env variable should be put in settings.py and not inside this function.
README.md
Outdated
1. Visit the url https://console.cloud.google.com/apis/ | ||
2. Sign in with your google account. | ||
3. Search for **YouTube Data API v3** and enable it. | ||
4. After enabling to go credentials present in the left navbar. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct "to go" into "go to"
@@ -0,0 +1,20 @@ | |||
# -*- coding: utf-8 -*- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This migrations should be merged into single migration file.
|
||
url_entires = {} | ||
|
||
def youtubeResource(request): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add relevant comments which will make it easy for other to understand logic behind code.
learn/views.py
Outdated
api_key = os.getenv("YOUTUBE_API_KEY") | ||
try: | ||
contents = urlreq.urlopen("https://www.googleapis.com/youtube/v3/videos?part=snippet%2CcontentDetails%2Cstatistics&id="+slug+"&key="+api_key).read() | ||
print(type(contents)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove debug print statements.
learn/views.py
Outdated
flag = True | ||
if "watch" in url: | ||
#Identifies that it is a video | ||
temp,slug = url.split("watch?v=") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of temp variable use _ (underscore) to handle unnecessary data returned by split statement.