#NEWLINE# def query( self , series = None , season = None , episode = None , title = None ) : #NEWLINE# #INDENT# if ( series and season and episode ) : #NEWLINE# #INDENT# url_series = self . _search_url_title ( series , 'series' ) #NEWLINE# url = ( self . server + 'cinemast/data/series/sb/{}/{}/{}/' . format ( url_series , season , episode ) ) #NEWLINE# page_link = ( self . server + 'subtitle/series/{}/{}/{}/' . format ( url_series , season , episode ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if title : #NEWLINE# #INDENT# url_title = self . _search_url_title ( title , 'movie' ) #NEWLINE# url = ( self . server + 'cinemast/data/movie/sb/{}/' . format ( url_title ) ) #NEWLINE# page_link = ( self . server + 'subtitle/movie/{}/' . format ( url_title ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( 'One or more parameters are missing' ) #NEWLINE# #UNINDENT# #UNINDENT# logger . debug ( 'Getting the list of subtitles' ) #NEWLINE# r = self . session . get ( url ) #NEWLINE# r . raise_for_status ( ) #NEWLINE# results = json . loads ( r . text ) #NEWLINE# subtitles = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( language_code , language_data ) in results . items ( ) : #NEWLINE# #INDENT# for quality_data in language_data . values ( ) : #NEWLINE# #INDENT# for ( quality , subtitles_data ) in quality_data . items ( ) : #NEWLINE# #INDENT# for subtitle_item in subtitles_data . values ( ) : #NEWLINE# #INDENT# language = Language . fromalpha2 ( language_code ) #NEWLINE# hearing_impaired = bool ( subtitle_item [ 'hearing_impaired' ] ) #NEWLINE# subtitle_id = subtitle_item [ 'id' ] #NEWLINE# subtitle_key = subtitle_item [ 'key' ] #NEWLINE# downloaded = subtitle_item [ 'downloaded' ] #NEWLINE# release = subtitle_item [ 'subtitle_version' ] #NEWLINE# if ( subtitle_id in subtitles ) : #NEWLINE# #INDENT# logger . debug ( 'Found additional release %r for subtitle %d' , release , subtitle_id ) #NEWLINE# bisect . insort_left ( subtitles [ subtitle_id ] . releases , release ) #NEWLINE# subtitles [ subtitle_id ] . downloaded += downloaded #NEWLINE# continue #NEWLINE# #UNINDENT# subtitle = SubsCenterSubtitle ( language , hearing_impaired , page_link , series , season , episode , title , subtitle_id , subtitle_key , downloaded , [ release ] ) #NEWLINE# logger . debug ( 'Found subtitle %r' , subtitle ) #NEWLINE# subtitles [ subtitle_id ] = subtitle #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return subtitles . values ( )