Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
including date published in model
from datetime import datetime, timedelta
# creating variable for time one week ago
today_date = datetime.today()
one_week_ago_date = today_date - timedelta(7)
one_week_ago_string = datetime(year=one_week_ago_date.year,month=one_week_ago_date.month,
day=one_week_ago_date.day).strftime('%Y-%m-%dT%H:%M:%SZ')
# updating the search by adding 'publishedAfter'
results = youtube.search().list(q='coding', part='snippet', type='video',
order='viewCount', maxResults=100, publishedAfter=one_week_ago_string).execute()
# incorporating ratio limit and days since published into final custom score:
def custom_score(viewcount, ratio, days_since_published):
if ratio > 5:
ratio = 5
score = (viewcount * ratio) / days_since_published
return score
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.