33import urllib
44
55
6+
67def xpath (node , path ):
78 tree = node .getroottree ()
89 base_xpath = tree .getpath (node )
910
1011 return tree .xpath (base_xpath + path )
1112
12-
1313class LibgenMirror :
1414 def __init__ (self , url , format , size , unit ):
1515 self .url = url
@@ -23,7 +23,6 @@ def parse(node, file_type, file_size, file_size_unit):
2323
2424 return LibgenMirror (url , file_type , file_size , file_size_unit )
2525
26-
2726class LibgenBook :
2827 def __init__ (self , title , authors , series , md5 , mirrors , language ,
2928 image_url ):
@@ -102,26 +101,18 @@ def parse(node):
102101class LibgenFictionClient :
103102 def __init__ (self , mirror = None ):
104103
104+ MIRRORS = [
105+ "libgen.is" ,
106+ # "libgen.lc", # Still has the old-style search
107+ "gen.lib.rus.ec" ,
108+ "93.174.95.27" ,
109+ ]
110+
105111 if mirror is None :
106- mirrors = self .get_mirrors_from_txt ('MIRRORS.txt' )
107- self .base_url = "http://{}/fiction/" .format (random .choice (mirrors ))
112+ self .base_url = "http://{}/fiction/" .format (random .choice (MIRRORS ))
108113 else :
109114 self .base_url = "http://{}/fiction/" .format (mirror )
110115
111- def get_mirrors_from_txt (self , txt ):
112- mirrors = []
113-
114- with open (txt , mode = 'r' ) as mirrors_txt :
115- for line in mirrors_txt .readlines ():
116- line = line .strip ()
117-
118- if len (line ) == 0 or line [0 ] == '#' :
119- continue
120-
121- mirrors .append (line )
122-
123- return mirrors
124-
125116 def search (self , query ):
126117 url = self .base_url
127118 query_params = {
0 commit comments