From 839e2b0b0b2bffc7304e1ea0641f62b352d74d40 Mon Sep 17 00:00:00 2001 From: Maaz1997 Date: Fri, 4 Dec 2020 15:27:49 +0530 Subject: [PATCH 1/2] updated youtube_utils.py --- geographies/management/commands/log/ap_migration_log.log | 0 libs/youtube_utils.py | 5 +++-- requirements/requirements.txt | 2 +- social_website/management/commands/sync_website.py | 6 +++--- social_website/utils/refresh_stats.py | 1 + 5 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 geographies/management/commands/log/ap_migration_log.log diff --git a/geographies/management/commands/log/ap_migration_log.log b/geographies/management/commands/log/ap_migration_log.log new file mode 100644 index 0000000000..e69de29bb2 diff --git a/libs/youtube_utils.py b/libs/youtube_utils.py index 51cac04892..2ae8167b5d 100644 --- a/libs/youtube_utils.py +++ b/libs/youtube_utils.py @@ -2,7 +2,7 @@ import logging from datetime import timedelta, date, datetime import json -import urllib2 +import urllib import isodate from boto.s3.connection import S3Connection @@ -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()) data = json.loads(response.read()) if int(data['pageInfo']['totalResults']) > 0: return data diff --git a/requirements/requirements.txt b/requirements/requirements.txt index ba7ac40c33..c6580ebb2d 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -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 newrelic==2.82.0.62 numpy==1.12.0 oauth2==1.5.211 diff --git a/social_website/management/commands/sync_website.py b/social_website/management/commands/sync_website.py index e98d1b79ab..9cdebe0144 100644 --- a/social_website/management/commands/sync_website.py +++ b/social_website/management/commands/sync_website.py @@ -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 from social_website.utils.sync_with_coco import recreate_person_video_record, sync_with_serverlog @@ -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() def fast(self): sync_with_serverlog() diff --git a/social_website/utils/refresh_stats.py b/social_website/utils/refresh_stats.py index f613bea25a..ed36d5bf02 100644 --- a/social_website/utils/refresh_stats.py +++ b/social_website/utils/refresh_stats.py @@ -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) if yt_entry: online_stats = get_online_stats(yt_entry) vid.onlineViews = online_stats['views'] From 204c85dc3b13274ce166c5a20cee33d77c15587b Mon Sep 17 00:00:00 2001 From: Maaz1997 Date: Tue, 8 Dec 2020 11:54:42 +0530 Subject: [PATCH 2/2] changes updated in youtube_utils.py --- libs/youtube_utils.py | 5 ++--- social_website/management/commands/sync_website.py | 2 +- social_website/utils/refresh_stats.py | 1 - 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/libs/youtube_utils.py b/libs/youtube_utils.py index 2ae8167b5d..51cac04892 100644 --- a/libs/youtube_utils.py +++ b/libs/youtube_utils.py @@ -2,7 +2,7 @@ import logging from datetime import timedelta, date, datetime import json -import urllib +import urllib2 import isodate from boto.s3.connection import S3Connection @@ -17,8 +17,7 @@ def get_youtube_entry(youtubeid, url='https://www.googleapis.com/youtube/v3/vide logger = logging.getLogger('social_website') if youtubeid != "": try: - response = urllib.urlopen(''.join([url, youtubeid, '&key=', GOOGLE_API_KEY])) - # print(response.read()) + response = urllib2.urlopen(''.join([url, youtubeid, '&key=', GOOGLE_API_KEY])) data = json.loads(response.read()) if int(data['pageInfo']['totalResults']) > 0: return data diff --git a/social_website/management/commands/sync_website.py b/social_website/management/commands/sync_website.py index 9cdebe0144..707fe1ca3b 100644 --- a/social_website/management/commands/sync_website.py +++ b/social_website/management/commands/sync_website.py @@ -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 from social_website.utils.sync_with_coco import recreate_person_video_record, sync_with_serverlog diff --git a/social_website/utils/refresh_stats.py b/social_website/utils/refresh_stats.py index ed36d5bf02..f613bea25a 100644 --- a/social_website/utils/refresh_stats.py +++ b/social_website/utils/refresh_stats.py @@ -30,7 +30,6 @@ 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) if yt_entry: online_stats = get_online_stats(yt_entry) vid.onlineViews = online_stats['views']