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

Added Preview and stored in db #39

Merged
merged 2 commits into from
Dec 31, 2018
Merged

Conversation

arpit3018
Copy link
Contributor

  1. Added youtube url preview
  2. Stored the data received by youtube api to database
  3. Modified Readme.md

Copy link
Owner

@mohitkh7 mohitkh7 left a 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
Copy link
Owner

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")
Copy link
Owner

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.
Copy link
Owner

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 -*-
Copy link
Owner

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):
Copy link
Owner

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))
Copy link
Owner

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=")
Copy link
Owner

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.

@mohitkh7 mohitkh7 merged commit 315a70f into mohitkh7:master Dec 31, 2018
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.

2 participants