#NEWLINE# def __init__( self , search_query ) : #NEWLINE# #INDENT# if ( not isinstance ( search_query , str ) ) : #NEWLINE# #INDENT# raise ValueError ( 'Expected str for 1st parameter (search_query).' ) #NEWLINE# #UNINDENT# self . avail_files = OrderedDict ( ) #NEWLINE# self . visible_files = None #NEWLINE# self . adj_tokens = { #NEWLINE# #INDENT# False : None , #NEWLINE# True : None , #NEWLINE# #UNINDENT# } #NEWLINE# self . vf_iter = None #NEWLINE# self . search_params = { #NEWLINE# #INDENT# 'maxResults' : 10 , #NEWLINE# 'order' : self . preferences [ 'order' ] , #NEWLINE# #UNINDENT# } #NEWLINE# self . yts_opts = dict ( ) #NEWLINE# parsed = self . __searchParser ( search_query ) #NEWLINE# self . search_params . update ( parsed [ 0 ] ) #NEWLINE# _pref = deepcopy ( self . preferences ) #NEWLINE# if ( 'metadata' in meta_list [ 1 ] ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# meta_list = parsed [ 1 ] [ 'metadata' ] . split ( ',' ) #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# meta_list = [ ] #NEWLINE# #UNINDENT# if ( 'desc' in meta_list ) : #NEWLINE# #INDENT# _pref [ 'metadata' ] [ 'desc' ] = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# _pref [ 'metadata' ] [ 'desc' ] = False #NEWLINE# #UNINDENT# if ( 'thumb' in meta_list ) : #NEWLINE# #INDENT# _pref [ 'metadata' ] [ 'thumb' ] = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# _pref [ 'metadata' ] [ 'thumb' ] = False #NEWLINE# #UNINDENT# #UNINDENT# self . preferences = _pref #NEWLINE# self . yts_opts = parsed [ 1 ] #NEWLINE# if ( ( 'audio' in parsed [ 1 ] ) and ( 'video' not in parsed [ 1 ] ) ) : #NEWLINE# #INDENT# self . yts_opts [ 'video' ] = False #NEWLINE# #UNINDENT# if ( ( 'video' in parsed [ 1 ] ) and ( 'audio' not in parsed [ 1 ] ) ) : #NEWLINE# #INDENT# self . yts_opts [ 'audio' ] = False #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# self . __getChannelId ( ) #NEWLINE# #UNINDENT# except requests . exceptions . ConnectionError : #NEWLINE# #INDENT# raise ConnectionError #NEWLINE# #UNINDENT# if parsed [ 0 ] . get ( 'publishedBefore' ) : #NEWLINE# #INDENT# self . search_params [ 'publishedBefore' ] += 'T00:00:00Z' #NEWLINE# #UNINDENT# if parsed [ 0 ] . get ( 'publishedAfter' ) : #NEWLINE# #INDENT# self . search_params [ 'publishedAfter' ] += 'T00:00:00Z'