def build_query_params_for_search(self,youtube_api_key,search_string,type_='video'):
from utils import ret_bracketed_option
#specify different results by adding order_option in square brackets in the search string.
stripped_string, order_option=ret_bracketed_option(search_string) #developer feature: specify the order in search parameter "[date]" etc.
if order_option:
if order_option.lower() in['date','rating','relevance','title','videocount','viewcount']:
log(' youtube search:using special order option [{0}]'.format(order_option))
else:
log(' youtube search:unsupported order option [{0}]'.format(order_option))
order_option='relevance'
stripped_string=search_string
else:
order_option='relevance'
return 'search', {
'key': youtube_api_key,
'fields':'items(kind,id(videoId),snippet(publishedAt,channelTitle,channelId,title,description,thumbnails(medium)))',
'type': type_, #video,channel,playlist.
'maxResults': '50', # Acceptable values are 0 to 50
'part': 'snippet',
'order': order_option, #date,rating,relevance,title,videoCount,viewCount
'q': stripped_string,
'safeSearch':'moderate' if hide_nsfw else 'none',
}
评论列表
文章目录