Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Restricting search period
# Function to create string for search start date
def get_start_date_string(search_period_days):
"""Returns string for date at start of search period."""
search_start_date = datetime.today() – timedelta(search_period_days)
date_string = datetime(year=search_start_date.year,month=search_start_date.month,
day=search_start_date.day).strftime(‘%Y-%m-%dT%H:%M:%SZ’)
return date_string
# Creating date string and executing search
date_string = get_start_date_string(7)
results = youtube_api.search().list(q=search_terms, part=snippet’,
type=video’, order=viewCount’, maxResults=50,
publishedAfter=date_string).execute()
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.