Showing 2 changed files with 126 additions and 9 deletions
+119 -9
mangaProxy.py
... ...
@@ -58,7 +58,7 @@ def completedManganeloTV(genre):
58 58
 
59 59
   return pageContent
60 60
 
61
-def getManganeloTV(url):
61
+def getReadManganatoCOM(url):
62 62
   debug("Downloading: "+url)
63 63
   #if "manganelo.com" in url:
64 64
   #  url=url.replace("manganelo.com","manganelo.tv")
... ...
@@ -66,9 +66,120 @@ def getManganeloTV(url):
66 66
   r = requests.get(url, allow_redirects=True)
67 67
   content = r.text
68 68
 
69
-  isMangakakalot = 0
70
-  if "mangakakalot.com" in url:
71
-    isMangakakalot = 1
69
+  #print(r.text)
70
+  lineNextChapter = None
71
+  linePreviousChapter = None
72
+  lineTitle = None
73
+  linkNext = None
74
+  linkPrev = None
75
+  listImages = []
76
+
77
+
78
+
79
+  for line in content.split("\n"):
80
+    if "<meta property=\"og:title\" content=\"" in line and lineTitle is None:
81
+      lineTitle = line
82
+    elif "<div class=\"navi-change-chapter-btn\">" in line:
83
+      if lineNextChapter is None and linkNext is None:
84
+        #for subLine in line.split("><"):
85
+        for subLine in line.split("<a rel="):
86
+          if "NEXT CHAPTER" in subLine:
87
+            linkNext=subLine.split("\"")[5]
88
+      elif linePreviousChapter is None and linkPrev is None:
89
+        subLinePrev=""
90
+        for subLine in line.split("<a rel="):
91
+          if "PREV CHAPTER" in subLine:
92
+            linkPrev=subLine.split("\"")[5]
93
+    elif "<img src=\"" in line:
94
+      if ".jpg" in line:
95
+        for subLine in line.split("><"):
96
+          if ".jpg" in subLine:
97
+            listImages.append(line.split("\"")[1])
98
+
99
+  if None is not linePreviousChapter:
100
+    say("Prev :"+str(len(linePreviousChapter)))
101
+    #i.e First chapter is opened
102
+    if 200 < len(linePreviousChapter):
103
+      tempLine = linePreviousChapter 
104
+      linePreviousChapter = None
105
+      for line in tempLine.split("><"):
106
+        if "navi-change-chapter-btn-prev a-h" in line and linePreviousChapter is None:
107
+          linePreviousChapter = line
108
+      linkPrev=linePreviousChapter.split("\"")[5]
109
+    else:
110
+      linkPrev="https://manganelo.tv"+linePreviousChapter.split("\"")[5]
111
+
112
+  if None is not lineNextChapter:
113
+    #i.e Last chapter is opened
114
+    say("Next :"+str(len(lineNextChapter)))
115
+    if 200 < len(lineNextChapter):
116
+      tempLine = lineNextChapter 
117
+      lineNextChapter = None
118
+      for line in tempLine.split("><"):
119
+        if "navi-change-chapter-btn-next a-h" in line and lineNextChapter is None:
120
+          lineNextChapter = line
121
+      linkNext=lineNextChapter.split("\"")[5]
122
+    else:
123
+      linkNext="https://manganelo.tv"+lineNextChapter.split("\"")[5]
124
+        
125
+  mangaImagesNum = len(listImages)
126
+  mangaTitle=lineTitle.split("\"")[3].split(" - MangaNato")[0]
127
+  mangaTitle=lineTitle.split("\"")[3].split(" - Manganelo")[0]
128
+  say("Manga :"+mangaTitle)
129
+  pageContent = ""
130
+  pageContent += "<div class=\"mangaChapNavig\">\n"
131
+  pageContent += "  <div class=\"mangaTitle\">"+mangaTitle+"</div>\n"
132
+  if linkPrev is not None:
133
+    pageContent += "  <div class=\"mangaChapNavigPrev\"><a href=\"?url="+linkPrev+"\"><div class=\"arrow-left\"></div><div class=\"arrow-left\"></div></a></div>\n"
134
+  if linkNext is not None:
135
+    pageContent += "  <div class=\"mangaChapNavigNext\"><a href=\"?url="+linkNext+"\"><div class=\"arrow-right\"></div><div class=\"arrow-right\"></div></a></div>\n"
136
+  pageContent += "  <div class=\"mangaChapNavigHome\"><a href=\".\"><div class=\"arrow-up\"></div></a></div>\n"
137
+  pageContent += "  <span id=\"mangaCurrPage\"></span><span id=\"mangaNumPages\"> / "+str(mangaImagesNum)+"</span>\n"
138
+  pageContent += "  <span id=\"mangaFSStatus\" style=\"display: none;\">0</span>\n"
139
+  pageContent += "  <span id=\"mangaFSToggle\" onclick=\"openFullscreen();\"><div class=\"fs-on\"></div></span>\n"
140
+  opacityValue=2;
141
+  if 7 <= datetime.datetime.now().hour and 20 >= datetime.datetime.now().hour:
142
+    opacityValue=10;
143
+  pageContent += "  <span id=\"mangaOpacityMinus\" onclick=\"onOpacityMinus()\">&#9788;</span>"
144
+  pageContent += "  <span id=\"mangaOpacityValue\">"+str(opacityValue)+"</span>"
145
+  pageContent += "  <span id=\"mangaOpacityPlus\" onclick=\"onOpacityPlus()\">&#9728;</span>\n"
146
+  pageContent += "  <span id=\"mangaReload\" onClick=\"window.location.reload();\"><div class=\"reload-circle\"></div></span>\n" 
147
+  pageContent += "</div>\n"
148
+  
149
+  pageContent += "<a name=\"article-top\"></a><div id=\"article-current\"></div>\n"
150
+  pageContent += "<div class=\"row\">\n\n"
151
+
152
+  cpt = 0
153
+  for pageImage in listImages:
154
+    #debug(pageImage)
155
+    pageContent += "<div class=\"article\" id=\"article-"+str(cpt)+"\" style=\"display: none;\">\n"
156
+    pageContent += "  <div class=\"column\" id=\"colLeft\" onclick=\"onArticle("+str(cpt-1)+")\">\n"
157
+    pageContent += "    <div class=\"arrow-left\"></div>\n"
158
+    pageContent += "  </div><!-- /column colLeft -->\n"
159
+        
160
+    pageContent += "  <div class=\"column\" id=\"colMiddle\">\n"
161
+    pageContent += "    <a name=\"article-"+str(cpt)+"\">\n"
162
+    pageContent += "    <img src=\"defer.png\" data-src=\""+pageImage+"\" class=\"center\">\n"
163
+    #pageContent += "    <li>"+str(cpt)+" : "+pageImage+"</li>\n"
164
+    pageContent += "  </div><!-- /column colMiddle -->\n\n"
165
+    
166
+    pageContent += "  <div class=\"column\" id=\"colRight\" onclick=\"onArticle("+str(cpt+1)+")\">\n"
167
+    pageContent += "    <div class=\"arrow-right\"></div>\n"
168
+    pageContent += "  </div><!-- /column colRight -->\n"
169
+    pageContent += "</div>\n"
170
+    pageContent += "\n"
171
+    cpt += 1
172
+
173
+  pageContent += "</div><!-- /row -->\n"
174
+  return pageContent
175
+
176
+def getManganeloTV(url):
177
+  debug("Downloading: "+url)
178
+  #if "manganelo.com" in url:
179
+  #  url=url.replace("manganelo.com","manganelo.tv")
180
+  #  say("Replace URL:"+url)
181
+  r = requests.get(url, allow_redirects=True)
182
+  content = r.text
72 183
 
73 184
   #print(r.text)
74 185
   lineNextChapter = None
... ...
@@ -99,6 +210,8 @@ def getManganeloTV(url):
99 210
     elif "<img class=\"img-loading\" data-src=\"" in line:
100 211
       if ".jpg" in line:
101 212
         listImages.append(line.split("\"")[3])    
213
+  print("NEXT :"+linkNext)
214
+  print("PREV :"+linkPrev)
102 215
 
103 216
   if 0 == len(listImages):
104 217
     # Attempt to extract images once more, most likely all are on one line
... ...
@@ -136,10 +249,7 @@ def getManganeloTV(url):
136 249
       linkNext="https://manganelo.tv"+lineNextChapter.split("\"")[5]
137 250
         
138 251
   mangaImagesNum = len(listImages)
139
-  if not isMangakakalot:
140
-    mangaTitle=lineTitle.split("\"")[3].split(" - Manganelo")[0]
141
-  else:
142
-    mangaTitle=lineTitle.split("\"")[3].split(" - Mangakakalot.com")[0]
252
+  mangaTitle=lineTitle.split("\"")[3].split(" - Manganelo")[0]
143 253
   say("Manga :"+mangaTitle)
144 254
   pageContent = ""
145 255
   pageContent += "<div class=\"mangaChapNavig\">\n"
... ...
@@ -260,7 +370,7 @@ class MyServer(BaseHTTPRequestHandler):
260 370
                 if "manganelo" in url:
261 371
                     data_page += getManganeloTV(url)
262 372
                 elif "readmanganato.com" in url:
263
-                    data_page += getManganeloTV(url)
373
+                    data_page += getReadManganatoCOM(url)
264 374
                 elif "mangakakalot.com" in url:
265 375
                     data_page += getManganeloTV(url)
266 376
                 else:
+7
pages/static/style.css
... ...
@@ -209,3 +209,10 @@ a:hover{}
209 209
   .row2 { display: block; margin-top: 25px;}
210 210
   .center { min-width: 90vw; }
211 211
 }
212
+
213
+@media screen and (max-width: 1280px) { 
214
+  /*#colLeft { display: none; }
215
+  #colRight { display: none; }*/
216
+  .row2 { display: block; margin-top: 25px;}
217
+  .center { min-width: 88vw; }
218
+}