Skip to content
New issue

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

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

Already on GitHub? # to your account

updated youtube_utils.py #1015

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
5 changes: 3 additions & 2 deletions libs/youtube_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
from datetime import timedelta, date, datetime
import json
import urllib2
import urllib
sujit22993 marked this conversation as resolved.
Show resolved Hide resolved
sujit22993 marked this conversation as resolved.
Show resolved Hide resolved

import isodate
from boto.s3.connection import S3Connection
Expand All @@ -17,7 +17,8 @@ def get_youtube_entry(youtubeid, url='https://www.googleapis.com/youtube/v3/vide
logger = logging.getLogger('social_website')
if youtubeid != "":
try:
response = urllib2.urlopen(''.join([url, youtubeid, '&key=', GOOGLE_API_KEY]))
response = urllib.urlopen(''.join([url, youtubeid, '&key=', GOOGLE_API_KEY]))
# print(response.read())
sujit22993 marked this conversation as resolved.
Show resolved Hide resolved
data = json.loads(response.read())
if int(data['pageInfo']['totalResults']) > 0:
return data
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ipython-genutils==0.2.0
isodate==0.5.4
jdcal==1.3
Mezzanine==4.1.0
MySQL-python==1.2.3
#MySQL-python==1.2.3
sujit22993 marked this conversation as resolved.
Show resolved Hide resolved
newrelic==2.82.0.62
numpy==1.12.0
oauth2==1.5.211
Expand Down
6 changes: 3 additions & 3 deletions social_website/management/commands/sync_website.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from django.core.management.base import BaseCommand, CommandError

from social_website.utils.refresh_stats import refresh_collection_partner_stats, refresh_offline_stats, refresh_online_stats
from social_website.utils.elastic_search.setup import setup_elastic_search
# from social_website.utils.elastic_search.setup import setup_elastic_search
sujit22993 marked this conversation as resolved.
Show resolved Hide resolved
from social_website.utils.sync_with_coco import recreate_person_video_record, sync_with_serverlog


Expand Down Expand Up @@ -78,8 +78,8 @@ def only_offline(self):

def only_online(self):
refresh_online_stats()
refresh_collection_partner_stats()
setup_elastic_search()
# refresh_collection_partner_stats()
# setup_elastic_search()
sujit22993 marked this conversation as resolved.
Show resolved Hide resolved

def fast(self):
sync_with_serverlog()
Expand Down
1 change: 1 addition & 0 deletions social_website/utils/refresh_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def refresh_online_stats():
url = 'https://www.googleapis.com/youtube/v3/videos?part=statistics&id='
for vid in Video.objects.all():
yt_entry = get_youtube_entry(vid.youtubeID, url)
print(yt_entry)
Maaz1997 marked this conversation as resolved.
Show resolved Hide resolved
if yt_entry:
online_stats = get_online_stats(yt_entry)
vid.onlineViews = online_stats['views']
Expand Down