def generate_search_qs(term, match='term', videoDuration='any', after=None):
 aliases = dict(views='viewCount')
 qs = {'q': term, 'maxResults': 50, 'safeSearch': 'none', 'order': aliases.get(config.ORDER.get, config.ORDER.get), 'part': 'id,snippet', 'type': 'video', 'videoDuration': videoDuration, 'key': config.API_KEY.get}
 if after:
  after = after.lower()
  qs['publishedAfter'] = (('%sZ' % (datetime.utcnow() - timedelta(days=DAYS[after])).isoformat()) if (after in DAYS.keys()) else ('%s%s' % (after, ('T00:00:00Z' * (len(after) == 10)))))
 if (match == 'related'):
  qs['relatedToVideoId'] = term
  del qs['q']
 if config.SEARCH_MUSIC.get:
  qs['videoCategoryId'] = 10
 return qs

def generate_search_qs ( term , match = 'term' , videoDuration = 'any' , after = None ) : aliases = dict ( views = 'viewCount' ) qs = { 'q' : term , 'maxResults' : 50 , 'safeSearch' : 'none' , 'order' : aliases . get ( config . ORDER . get , config . ORDER . get ) , 'part' : 'id,snippet' , 'type' : 'video' , 'videoDuration' : videoDuration , 'key' : config . API_KEY . get } if after : after = after . lower ( ) qs [ 'publishedAfter' ] = ( ( '%sZ' % ( datetime . utcnow ( ) - timedelta ( days = DAYS [ after ] ) ) . isoformat ( ) ) if ( after in DAYS . keys ( ) ) else ( '%s%s' % ( after , ( 'T00:00:00Z' * ( len ( after ) == 10 ) ) ) ) ) if ( match == 'related' ) : qs [ 'relatedToVideoId' ] = term del qs [ 'q' ] if config . SEARCH_MUSIC . get : qs [ 'videoCategoryId' ] = 10 return qs
return query string .