Showing 5 changed files with 315 additions and 390 deletions
+95
mangaParser/__init__.py
... ...
@@ -0,0 +1,95 @@
1
+#!/usr/bin/env python3
2
+# encoding: UTF-8
3
+__author__ = 'Yanik Cawidrone'
4
+__version__ = '0.1'
5
+
6
+"""
7
+    For more see the file 'LICENSE' for copying permission.
8
+"""
9
+from colorama import Fore, Back, Style
10
+from time import gmtime, strftime
11
+import configuration
12
+import datetime
13
+
14
+name = "mangaParser"
15
+def say(message):
16
+    date_string = strftime("%Y-%m-%d %H:%M:%S %z", gmtime())
17
+    prefix = Fore.CYAN + name + " " + Fore.RESET + date_string + " "
18
+    print(prefix + Style.DIM + message + Style.RESET_ALL)
19
+
20
+
21
+from .mangaParser import readManganatoCom
22
+from .mangaParser import mangakakalotCom
23
+from .mangaParser import manganeloTv
24
+
25
+def readManga(url,opacity,page):
26
+  if "readmanganato.com" in url:
27
+    say("READ manganato")
28
+    return readManganatoCom.read(url,opacity,page)
29
+  elif "mangakakalot.com" in url:
30
+    say("READ mangakakalot")
31
+    return mangakakalotCom.read(url,opacity,page)
32
+  elif "manganelo.tv" in url:
33
+    say("READ manganelo.tv")
34
+    return manganeloTv.read(url,opacity,page)
35
+  else:
36
+    return "<div class=\"mangaTitle\">readManga Not supported: "+url+"</div>"
37
+
38
+def addHeader(mangaTitle, linkNext, linkPrev, mangaImagesNum, opacity=10, page=1):
39
+  #Adding generic header
40
+  mangaHeader = ""
41
+  mangaHeader += "<div class=\"mangaChapNavig\">\n"
42
+  mangaHeader += "  <div class=\"mangaTitle\">"+mangaTitle+"</div>\n"
43
+  if linkPrev is not None:
44
+    mangaHeader += "  <div class=\"mangaChapNavigPrev\" onclick=\"onChapterPrev();\"><div class=\"arrow-left\"></div><div class=\"arrow-left\"></div></a></div>\n"
45
+    mangaHeader += "  <div id=\"chapterPrevious\" style=\"display: none;\">"+linkPrev+"</div>\n"
46
+  if linkNext is not None:
47
+    mangaHeader += "  <div class=\"mangaChapNavigNext\"  onclick=\"onChapterNext();\"><div class=\"arrow-right\"></div><div class=\"arrow-right\"></div></a></div>\n"
48
+    mangaHeader += "  <div id=\"chapterNext\" style=\"display: none;\">"+linkNext+"</div>\n"
49
+  mangaHeader += "  <div class=\"mangaChapNavigHome\"><a href=\".\"><div class=\"arrow-up\"></div></a></div>\n"
50
+  mangaHeader += "  <span id=\"mangaCurrPage\">"+str(page)+"</span><span id=\"mangaNumPages\"> / "+str(mangaImagesNum)+"</span>\n"
51
+  mangaHeader += "  <span id=\"mangaFSStatus\" style=\"display: none;\">0</span>\n"
52
+  mangaHeader += "  <span id=\"mangaFSToggle\" onclick=\"openFullscreen();\"><div class=\"fs-on\"></div></span>\n"
53
+  if opacity == -1:
54
+    opacityValue=2;
55
+    if 7 <= datetime.datetime.now().hour and 20 >= datetime.datetime.now().hour:
56
+      opacityValue=10;
57
+    opacity=opacityValue
58
+  mangaHeader += "  <span id=\"mangaOpacityMinus\" onclick=\"onOpacityMinus()\">&#9788;</span>"
59
+  mangaHeader += "  <span id=\"mangaOpacityValue\">"+str(opacity)+"</span>"
60
+  mangaHeader += "  <span id=\"mangaOpacityPlus\" onclick=\"onOpacityPlus()\">&#9728;</span>\n"
61
+  mangaHeader += "  <span id=\"mangaReload\" onClick=\"window.location.reload();\"><div class=\"reload-circle\"></div></span>\n" 
62
+  mangaHeader += "</div>\n"
63
+  
64
+  mangaHeader += "<a name=\"article-top\"></a><div id=\"article-current\"></div>\n"
65
+  mangaHeader += "<div class=\"row\">\n\n"
66
+  return mangaHeader
67
+
68
+def addImageList(listImages):
69
+  cpt = 0
70
+  mangaImageList=""
71
+
72
+  mangaImageList += "<a name=\"article-top\"></a><div id=\"article-current\"></div>\n"
73
+  mangaImageList += "<div class=\"row\">\n\n"
74
+
75
+
76
+  for pageImage in listImages:
77
+    mangaImageList += "<div class=\"article\" id=\"article-"+str(cpt)+"\" style=\"display: none;\">\n"
78
+    mangaImageList += "  <div class=\"column\" id=\"colLeft\" onclick=\"onArticle("+str(cpt-1)+")\">\n"
79
+    mangaImageList += "    <div class=\"arrow-left\"></div>\n"
80
+    mangaImageList += "  </div><!-- /column colLeft -->\n"
81
+        
82
+    mangaImageList += "  <div class=\"column\" id=\"colMiddle\">\n"
83
+    mangaImageList += "    <a name=\"article-"+str(cpt)+"\">\n"
84
+    mangaImageList += "    <img src=\"defer.png\" data-src=\""+pageImage+"\" class=\"center\">\n"
85
+    mangaImageList += "  </div><!-- /column colMiddle -->\n\n"
86
+    
87
+    mangaImageList += "  <div class=\"column\" id=\"colRight\" onclick=\"onArticle("+str(cpt+1)+")\">\n"
88
+    mangaImageList += "    <div class=\"arrow-right\"></div>\n"
89
+    mangaImageList += "  </div><!-- /column colRight -->\n"
90
+    mangaImageList += "</div>\n"
91
+    mangaImageList += "\n"
92
+    cpt += 1
93
+
94
+  mangaImageList += "</div><!-- /row -->\n"
95
+  return mangaImageList
+76
mangaParser/mangaParser/mangakakalotCom.py
... ...
@@ -0,0 +1,76 @@
1
+#!/usr/bin/env python3
2
+import requests
3
+import userio
4
+import mangaParser
5
+
6
+def read(url,opacity=10,page=1):
7
+  r = requests.get(url, allow_redirects=True)
8
+  content = r.text
9
+  
10
+  isMangakakalot = 1
11
+  lineNextChapter = None
12
+  linePreviousChapter = None
13
+  lineTitle = None
14
+  linkNext = None
15
+  linkPrev = None
16
+  listImages = []
17
+  for line in content.split("\n"):
18
+    if "<meta property=\"og:title\" content=\"" in line and lineTitle is None:
19
+      lineTitle = line
20
+
21
+    elif isMangakakalot == 1 and "<div class='btn-navigation-chap'>" in line and lineNextChapter is None and linkNext is None:
22
+      for subLine in line.split("><"):
23
+        if "NEXT CHAPTER" in subLine:
24
+          linkNext=subLine.split("'")[1]
25
+    elif isMangakakalot == 1 and "<div class='btn-navigation-chap'>" in line and linePreviousChapter is None and linkPrev is None:
26
+      for subLine in line.split("><"):
27
+        if "PREV CHAPTER" in subLine:
28
+          linkPrev=subLine.split("'")[1]
29
+
30
+    elif "<img class=\"img-loading\" data-src=\"" in line:
31
+      if ".jpg" in line:
32
+        listImages.append(line.split("\"")[3])    
33
+
34
+  if 0 == len(listImages):
35
+    # Attempt to extract images once more, most likely all are on one line
36
+    for line in content.split("\n"):
37
+      if " page " in line:
38
+        for subLine in line.split("><"):
39
+          if "https://" in subLine:
40
+            if ".jpg" in subLine.split("\"")[1]:
41
+              listImages.append(subLine.split("\"")[1])
42
+
43
+  if None is not linePreviousChapter:
44
+    say("Prev :"+str(len(linePreviousChapter)))
45
+    #i.e First chapter is opened
46
+    if 200 < len(linePreviousChapter):
47
+      tempLine = linePreviousChapter 
48
+      linePreviousChapter = None
49
+      for line in tempLine.split("><"):
50
+        if "navi-change-chapter-btn-prev a-h" in line and linePreviousChapter is None:
51
+          linePreviousChapter = line
52
+      linkPrev=linePreviousChapter.split("\"")[5]
53
+    else:
54
+      linkPrev="https://manganelo.tv"+linePreviousChapter.split("\"")[5]
55
+
56
+  if None is not lineNextChapter:
57
+    #i.e Last chapter is opened
58
+    say("Next :"+str(len(lineNextChapter)))
59
+    if 200 < len(lineNextChapter):
60
+      tempLine = lineNextChapter 
61
+      lineNextChapter = None
62
+      for line in tempLine.split("><"):
63
+        if "navi-change-chapter-btn-next a-h" in line and lineNextChapter is None:
64
+          lineNextChapter = line
65
+      linkNext=lineNextChapter.split("\"")[5]
66
+    else:
67
+      linkNext="https://manganelo.tv"+lineNextChapter.split("\"")[5]
68
+        
69
+  mangaImagesNum = len(listImages)
70
+  mangaTitle=lineTitle.split("\"")[3].split(" - Mangakakalot.com")[0]
71
+  mangaParser.say("Manga :"+mangaTitle)
72
+  pageContent = mangaParser.addHeader(mangaTitle, linkNext, linkPrev, mangaImagesNum, opacity, page)
73
+  pageContent += mangaParser.addImageList(listImages)
74
+
75
+  pageContent += "</div><!-- /row -->\n"
76
+  return pageContent
+71
mangaParser/mangaParser/manganeloTv.py
... ...
@@ -0,0 +1,71 @@
1
+#!/usr/bin/env python3
2
+import requests
3
+import userio
4
+import mangaParser
5
+
6
+def read(url,opacity=10,page=1):
7
+  r = requests.get(url, allow_redirects=True)
8
+  content = r.text
9
+  
10
+  #print(r.text)
11
+  lineNextChapter = None
12
+  linePreviousChapter = None
13
+  lineTitle = None
14
+  linkNext = None
15
+  linkPrev = None
16
+  listImages = []
17
+  for line in content.split("\n"):
18
+    if "navi-change-chapter-btn-prev a-h" in line and linePreviousChapter is None:
19
+      linePreviousChapter = line
20
+    elif "navi-change-chapter-btn-next a-h" in line and lineNextChapter is None:
21
+      lineNextChapter = line
22
+    elif "<meta property=\"og:title\" content=\"" in line and lineTitle is None:
23
+      lineTitle = line
24
+    elif "<img class=\"img-loading\" data-src=\"" in line:
25
+      if ".jpg" in line:
26
+        listImages.append(line.split("\"")[3])    
27
+
28
+  if 0 == len(listImages):
29
+    # Attempt to extract images once more, most likely all are on one line
30
+    for line in content.split("\n"):
31
+      if " page " in line:
32
+        for subLine in line.split("><"):
33
+          if "https://" in subLine:
34
+            if ".jpg" in subLine.split("\"")[1]:
35
+              listImages.append(subLine.split("\"")[1])
36
+
37
+  if None is not linePreviousChapter:
38
+    mangaParser.say("Prev :"+str(len(linePreviousChapter)))
39
+    #i.e First chapter is opened
40
+    if 200 < len(linePreviousChapter):
41
+      tempLine = linePreviousChapter 
42
+      linePreviousChapter = None
43
+      for line in tempLine.split("><"):
44
+        if "navi-change-chapter-btn-prev a-h" in line and linePreviousChapter is None:
45
+          linePreviousChapter = line
46
+      linkPrev=linePreviousChapter.split("\"")[5]
47
+    else:
48
+      linkPrev="https://manganelo.tv"+linePreviousChapter.split("\"")[5]
49
+
50
+  if None is not lineNextChapter:
51
+    #i.e Last chapter is opened
52
+    mangaParser.say("Next :"+str(len(lineNextChapter)))
53
+    if 200 < len(lineNextChapter):
54
+      tempLine = lineNextChapter 
55
+      lineNextChapter = None
56
+      for line in tempLine.split("><"):
57
+        if "navi-change-chapter-btn-next a-h" in line and lineNextChapter is None:
58
+          lineNextChapter = line
59
+      linkNext=lineNextChapter.split("\"")[5]
60
+    else:
61
+      linkNext="https://manganelo.tv"+lineNextChapter.split("\"")[5]
62
+        
63
+  mangaImagesNum = len(listImages)
64
+  mangaTitle=lineTitle.split("\"")[3].split(" - Manganelo")[0]
65
+  mangaParser.say("Manga :"+mangaTitle)
66
+  pageContent = mangaParser.addHeader(mangaTitle, linkNext, linkPrev, mangaImagesNum, opacity, page)
67
+  pageContent += mangaParser.addImageList(listImages)
68
+
69
+  pageContent += "</div><!-- /row -->\n"
70
+  return pageContent
71
+
+71
mangaParser/mangaParser/readManganatoCom.py
... ...
@@ -0,0 +1,71 @@
1
+#!/usr/bin/env python3
2
+import requests
3
+import userio
4
+import mangaParser
5
+
6
+def read(url,opacity=10,page=1):
7
+  r = requests.get(url, allow_redirects=True)
8
+  content = r.text
9
+
10
+  #print(r.text)
11
+  lineNextChapter = None
12
+  linePreviousChapter = None
13
+  lineTitle = None
14
+  linkNext = None
15
+  linkPrev = None
16
+  listImages = []
17
+
18
+  for line in content.split("\n"):
19
+    if "<meta property=\"og:title\" content=\"" in line and lineTitle is None:
20
+      lineTitle = line
21
+    elif "<div class=\"navi-change-chapter-btn\">" in line:
22
+      if lineNextChapter is None and linkNext is None:
23
+        for subLine in line.split("<a rel="):
24
+          if "NEXT CHAPTER" in subLine:
25
+            linkNext=subLine.split("\"")[5]
26
+      elif linePreviousChapter is None and linkPrev is None:
27
+        subLinePrev=""
28
+        for subLine in line.split("<a rel="):
29
+          if "PREV CHAPTER" in subLine:
30
+            linkPrev=subLine.split("\"")[5]
31
+    elif "<img src=\"" in line:
32
+      if ".jpg" in line:
33
+        for subLine in line.split("><img"):
34
+          if ".jpg" in subLine:
35
+            listImages.append(subLine.split("\"")[1])
36
+
37
+  if None is not linePreviousChapter:
38
+    mangaParser.say("Prev :"+str(len(linePreviousChapter)))
39
+    #i.e First chapter is opened
40
+    if 200 < len(linePreviousChapter):
41
+      tempLine = linePreviousChapter 
42
+      linePreviousChapter = None
43
+      for line in tempLine.split("><"):
44
+        if "navi-change-chapter-btn-prev a-h" in line and linePreviousChapter is None:
45
+          linePreviousChapter = line
46
+      linkPrev=linePreviousChapter.split("\"")[5]
47
+    else:
48
+      linkPrev="https://manganelo.tv"+linePreviousChapter.split("\"")[5]
49
+
50
+  if None is not lineNextChapter:
51
+    #i.e Last chapter is opened
52
+    mangaParser.say("Next :"+str(len(lineNextChapter)))
53
+    if 200 < len(lineNextChapter):
54
+      tempLine = lineNextChapter 
55
+      lineNextChapter = None
56
+      for line in tempLine.split("><"):
57
+        if "navi-change-chapter-btn-next a-h" in line and lineNextChapter is None:
58
+          lineNextChapter = line
59
+      linkNext=lineNextChapter.split("\"")[5]
60
+    else:
61
+      linkNext="https://manganelo.tv"+lineNextChapter.split("\"")[5]
62
+        
63
+  mangaImagesNum = len(listImages)
64
+  mangaTitle=lineTitle.split("\"")[3].split(" - MangaNato")[0]
65
+  mangaTitle=lineTitle.split("\"")[3].split(" - Manganelo")[0]
66
+  mangaParser.say("Manga :"+mangaTitle)
67
+  pageContent = mangaParser.addHeader(mangaTitle, linkNext, linkPrev, mangaImagesNum, opacity, page)
68
+  pageContent += mangaParser.addImageList(listImages)
69
+
70
+  pageContent += "</div><!-- /row -->\n"
71
+  return pageContent
+2 -390
mangaProxy.py
... ...
@@ -9,6 +9,7 @@ import configuration
9 9
 import socket
10 10
 import requests
11 11
 import re
12
+import mangaParser
12 13
 from userio import *
13 14
 
14 15
 # Random Example URL: https://manganelo.tv/chapter/dy925032/chapter_21
... ...
@@ -17,391 +18,12 @@ from userio import *
17 18
 server = None
18 19
 csvFilename = None
19 20
 connectionResults = None
20
-opacity = -1
21
-pageJump = 1
22
-
23
-def getReadManganatoCOM(url):
24
-  global opacity
25
-  say("getReadManganatoCOM: "+url)
26
-  r = requests.get(url, allow_redirects=True)
27
-  content = r.text
28
-
29
-  #print(r.text)
30
-  lineNextChapter = None
31
-  linePreviousChapter = None
32
-  lineTitle = None
33
-  linkNext = None
34
-  linkPrev = None
35
-  listImages = []
36
-
37
-  for line in content.split("\n"):
38
-    if "<meta property=\"og:title\" content=\"" in line and lineTitle is None:
39
-      lineTitle = line
40
-    elif "<div class=\"navi-change-chapter-btn\">" in line:
41
-      if lineNextChapter is None and linkNext is None:
42
-        #for subLine in line.split("><"):
43
-        for subLine in line.split("<a rel="):
44
-          if "NEXT CHAPTER" in subLine:
45
-            linkNext=subLine.split("\"")[5]
46
-      elif linePreviousChapter is None and linkPrev is None:
47
-        subLinePrev=""
48
-        for subLine in line.split("<a rel="):
49
-          if "PREV CHAPTER" in subLine:
50
-            linkPrev=subLine.split("\"")[5]
51
-    elif "<img src=\"" in line:
52
-      if ".jpg" in line:
53
-        for subLine in line.split("><img"):
54
-          if ".jpg" in subLine:
55
-            listImages.append(subLine.split("\"")[1])
56
-            debug(line.split("\"")[1])
57
-
58
-  if None is not linePreviousChapter:
59
-    say("Prev :"+str(len(linePreviousChapter)))
60
-    #i.e First chapter is opened
61
-    if 200 < len(linePreviousChapter):
62
-      tempLine = linePreviousChapter 
63
-      linePreviousChapter = None
64
-      for line in tempLine.split("><"):
65
-        if "navi-change-chapter-btn-prev a-h" in line and linePreviousChapter is None:
66
-          linePreviousChapter = line
67
-      linkPrev=linePreviousChapter.split("\"")[5]
68
-    else:
69
-      linkPrev="https://manganelo.tv"+linePreviousChapter.split("\"")[5]
70
-
71
-  if None is not lineNextChapter:
72
-    #i.e Last chapter is opened
73
-    say("Next :"+str(len(lineNextChapter)))
74
-    if 200 < len(lineNextChapter):
75
-      tempLine = lineNextChapter 
76
-      lineNextChapter = None
77
-      for line in tempLine.split("><"):
78
-        if "navi-change-chapter-btn-next a-h" in line and lineNextChapter is None:
79
-          lineNextChapter = line
80
-      linkNext=lineNextChapter.split("\"")[5]
81
-    else:
82
-      linkNext="https://manganelo.tv"+lineNextChapter.split("\"")[5]
83
-        
84
-  mangaImagesNum = len(listImages)
85
-  mangaTitle=lineTitle.split("\"")[3].split(" - MangaNato")[0]
86
-  mangaTitle=lineTitle.split("\"")[3].split(" - Manganelo")[0]
87
-  say("Manga :"+mangaTitle)
88
-  pageContent = ""
89
-  pageContent += "<div class=\"mangaChapNavig\">\n"
90
-  pageContent += "  <div class=\"mangaTitle\">"+mangaTitle+"</div>\n"
91
-  if linkPrev is not None:
92
-    #pageContent += "  <div class=\"mangaChapNavigPrev\"><a href=\"?url="+linkPrev+"\"><div class=\"arrow-left\"></div><div class=\"arrow-left\"></div></a></div>\n"
93
-    pageContent += "  <div class=\"mangaChapNavigPrev\" onclick=\"onChapterPrev();\"><div class=\"arrow-left\"></div><div class=\"arrow-left\"></div></a></div>\n"
94
-    pageContent += "  <div id=\"chapterPrevious\" style=\"display: none;\">"+linkPrev+"</div>\n"
95
-  if linkNext is not None:
96
-    #pageContent += "  <div class=\"mangaChapNavigNext\"><a href=\"?url="+linkNext+"\"><div class=\"arrow-right\"></div><div class=\"arrow-right\"></div></a></div>\n"
97
-    pageContent += "  <div class=\"mangaChapNavigNext\"  onclick=\"onChapterNext();\"><div class=\"arrow-right\"></div><div class=\"arrow-right\"></div></a></div>\n"
98
-    pageContent += "  <div id=\"chapterNext\" style=\"display: none;\">"+linkNext+"</div>\n"
99
-  pageContent += "  <div class=\"mangaChapNavigHome\"><a href=\".\"><div class=\"arrow-up\"></div></a></div>\n"
100
-  pageContent += "  <span id=\"mangaCurrPage\"></span><span id=\"mangaNumPages\"> / "+str(mangaImagesNum)+"</span>\n"
101
-  pageContent += "  <span id=\"mangaFSStatus\" style=\"display: none;\">0</span>\n"
102
-  pageContent += "  <span id=\"mangaFSToggle\" onclick=\"openFullscreen();\"><div class=\"fs-on\"></div></span>\n"
103
-  if opacity == -1:
104
-    opacityValue=2;
105
-    if 7 <= datetime.datetime.now().hour and 20 >= datetime.datetime.now().hour:
106
-      opacityValue=10;
107
-    opacity=opacityValue
108
-  pageContent += "  <span id=\"mangaOpacityMinus\" onclick=\"onOpacityMinus()\">&#9788;</span>"
109
-  pageContent += "  <span id=\"mangaOpacityValue\">"+str(opacity)+"</span>"
110
-  pageContent += "  <span id=\"mangaOpacityPlus\" onclick=\"onOpacityPlus()\">&#9728;</span>\n"
111
-  pageContent += "  <span id=\"mangaReload\" onClick=\"window.location.reload();\"><div class=\"reload-circle\"></div></span>\n" 
112
-  pageContent += "</div>\n"
113
-  
114
-  pageContent += "<a name=\"article-top\"></a><div id=\"article-current\"></div>\n"
115
-  pageContent += "<div class=\"row\">\n\n"
116
-
117
-  cpt = 0
118
-  for pageImage in listImages:
119
-    #debug(pageImage)
120
-    pageContent += "<div class=\"article\" id=\"article-"+str(cpt)+"\" style=\"display: none;\">\n"
121
-    pageContent += "  <div class=\"column\" id=\"colLeft\" onclick=\"onArticle("+str(cpt-1)+")\">\n"
122
-    pageContent += "    <div class=\"arrow-left\"></div>\n"
123
-    pageContent += "  </div><!-- /column colLeft -->\n"
124
-        
125
-    pageContent += "  <div class=\"column\" id=\"colMiddle\">\n"
126
-    pageContent += "    <a name=\"article-"+str(cpt)+"\">\n"
127
-    pageContent += "    <img src=\"defer.png\" data-src=\""+pageImage+"\" class=\"center\">\n"
128
-    #pageContent += "    <li>"+str(cpt)+" : "+pageImage+"</li>\n"
129
-    pageContent += "  </div><!-- /column colMiddle -->\n\n"
130
-    
131
-    pageContent += "  <div class=\"column\" id=\"colRight\" onclick=\"onArticle("+str(cpt+1)+")\">\n"
132
-    pageContent += "    <div class=\"arrow-right\"></div>\n"
133
-    pageContent += "  </div><!-- /column colRight -->\n"
134
-    pageContent += "</div>\n"
135
-    pageContent += "\n"
136
-    cpt += 1
137
-
138
-  pageContent += "</div><!-- /row -->\n"
139
-  return pageContent
140
-
141
-def getMangakakalotCom(url):
142
-  global opacity
143
-  global pageJump
144
-  debug("getMangakakalotCom :"+url)
145
-  r = requests.get(url, allow_redirects=True)
146
-  content = r.text
147
-  
148
-  isMangakakalot = 1
149
-  lineNextChapter = None
150
-  linePreviousChapter = None
151
-  lineTitle = None
152
-  linkNext = None
153
-  linkPrev = None
154
-  listImages = []
155
-  for line in content.split("\n"):
156
-    if "<meta property=\"og:title\" content=\"" in line and lineTitle is None:
157
-      lineTitle = line
158
-
159
-    elif isMangakakalot == 1 and "<div class='btn-navigation-chap'>" in line and lineNextChapter is None and linkNext is None:
160
-      for subLine in line.split("><"):
161
-        if "NEXT CHAPTER" in subLine:
162
-          linkNext=subLine.split("'")[1]
163
-          debug("linkNext: "+linkNext)
164
-    elif isMangakakalot == 1 and "<div class='btn-navigation-chap'>" in line and linePreviousChapter is None and linkPrev is None:
165
-      for subLine in line.split("><"):
166
-        if "PREV CHAPTER" in subLine:
167
-          linkPrev=subLine.split("'")[1]
168
-          debug("linkPrev: "+linkPrev)
169
-
170
-    elif "<img class=\"img-loading\" data-src=\"" in line:
171
-      if ".jpg" in line:
172
-        listImages.append(line.split("\"")[3])    
173
-
174
-  if 0 == len(listImages):
175
-    # Attempt to extract images once more, most likely all are on one line
176
-    for line in content.split("\n"):
177
-      if " page " in line:
178
-        for subLine in line.split("><"):
179
-          if "https://" in subLine:
180
-            if ".jpg" in subLine.split("\"")[1]:
181
-              listImages.append(subLine.split("\"")[1])
182
-
183
-  if None is not linePreviousChapter:
184
-    say("Prev :"+str(len(linePreviousChapter)))
185
-    #i.e First chapter is opened
186
-    if 200 < len(linePreviousChapter):
187
-      tempLine = linePreviousChapter 
188
-      linePreviousChapter = None
189
-      for line in tempLine.split("><"):
190
-        if "navi-change-chapter-btn-prev a-h" in line and linePreviousChapter is None:
191
-          linePreviousChapter = line
192
-      linkPrev=linePreviousChapter.split("\"")[5]
193
-    else:
194
-      linkPrev="https://manganelo.tv"+linePreviousChapter.split("\"")[5]
195
-
196
-  if None is not lineNextChapter:
197
-    #i.e Last chapter is opened
198
-    say("Next :"+str(len(lineNextChapter)))
199
-    if 200 < len(lineNextChapter):
200
-      tempLine = lineNextChapter 
201
-      lineNextChapter = None
202
-      for line in tempLine.split("><"):
203
-        if "navi-change-chapter-btn-next a-h" in line and lineNextChapter is None:
204
-          lineNextChapter = line
205
-      linkNext=lineNextChapter.split("\"")[5]
206
-    else:
207
-      linkNext="https://manganelo.tv"+lineNextChapter.split("\"")[5]
208
-        
209
-  mangaImagesNum = len(listImages)
210
-  mangaTitle=lineTitle.split("\"")[3].split(" - Manganelo")[0]
211
-  say("Manga :"+mangaTitle)
212
-  pageContent = ""
213
-  pageContent += "<div class=\"mangaChapNavig\">\n"
214
-  pageContent += "  <div class=\"mangaTitle\">"+mangaTitle+"</div>\n"
215
-  if linkPrev is not None:
216
-    #pageContent += "  <div class=\"mangaChapNavigPrev\"><a href=\"?url="+linkPrev+"\"><div class=\"arrow-left\"></div><div class=\"arrow-left\"></div></a></div>\n"
217
-    pageContent += "  <div class=\"mangaChapNavigPrev\" onclick=\"onChapterPrev();\"><div class=\"arrow-left\"></div><div class=\"arrow-left\"></div></a></div>\n"
218
-    pageContent += "  <div id=\"chapterPrevious\" style=\"display: none;\">"+linkPrev+"</div>\n"
219
-  if linkNext is not None:
220
-    #pageContent += "  <div class=\"mangaChapNavigNext\"><a href=\"?url="+linkNext+"\"><div class=\"arrow-right\"></div><div class=\"arrow-right\"></div></a></div>\n"
221
-    pageContent += "  <div class=\"mangaChapNavigNext\"  onclick=\"onChapterNext();\"><div class=\"arrow-right\"></div><div class=\"arrow-right\"></div></a></div>\n"
222
-    pageContent += "  <div id=\"chapterNext\" style=\"display: none;\">"+linkNext+"</div>\n"
223
-  pageContent += "  <div class=\"mangaChapNavigHome\"><a href=\".\"><div class=\"arrow-up\"></div></a></div>\n"
224
-  pageContent += "  <span id=\"mangaCurrPage\">"+str(pageJump)+"</span><span id=\"mangaNumPages\"> / "+str(mangaImagesNum)+"</span>\n"
225
-  say("page: "+str(pageJump))
226
-  pageContent += "  <span id=\"mangaFSStatus\" style=\"display: none;\">0</span>\n"
227
-  pageContent += "  <span id=\"mangaFSToggle\" onclick=\"openFullscreen();\"><div class=\"fs-on\"></div></span>\n"
228
-  if opacity == -1:
229
-    opacityValue=2;
230
-    if 7 <= datetime.datetime.now().hour and 20 >= datetime.datetime.now().hour:
231
-      opacityValue=10;
232
-    opacity=opacityValue
233
-  pageContent += "  <span id=\"mangaOpacityMinus\" onclick=\"onOpacityMinus()\">&#9788;</span>"
234
-  pageContent += "  <span id=\"mangaOpacityValue\">"+str(opacity)+"</span>"
235
-  pageContent += "  <span id=\"mangaOpacityPlus\" onclick=\"onOpacityPlus()\">&#9728;</span>\n"
236
-  pageContent += "  <span id=\"mangaReload\" onClick=\"window.location.reload();\"><div class=\"reload-circle\"></div></span>\n" 
237
-  pageContent += "</div>\n"
238
-  
239
-  pageContent += "<a name=\"article-top\"></a><div id=\"article-current\"></div>\n"
240
-  pageContent += "<div class=\"row\">\n\n"
241
-
242
-  cpt = 0
243
-  for pageImage in listImages:
244
-    #debug(pageImage)
245
-    pageContent += "<div class=\"article\" id=\"article-"+str(cpt)+"\" style=\"display: none;\">\n"
246
-    pageContent += "  <div class=\"column\" id=\"colLeft\" onclick=\"onArticle("+str(cpt-1)+")\">\n"
247
-    pageContent += "    <div class=\"arrow-left\"></div>\n"
248
-    pageContent += "  </div><!-- /column colLeft -->\n"
249
-        
250
-    pageContent += "  <div class=\"column\" id=\"colMiddle\">\n"
251
-    pageContent += "    <a name=\"article-"+str(cpt)+"\">\n"
252
-    pageContent += "    <img src=\"defer.png\" data-src=\""+pageImage+"\" class=\"center\">\n"
253
-    #pageContent += "    <li>"+str(cpt)+" : "+pageImage+"</li>\n"
254
-    pageContent += "  </div><!-- /column colMiddle -->\n\n"
255
-    
256
-    pageContent += "  <div class=\"column\" id=\"colRight\" onclick=\"onArticle("+str(cpt+1)+")\">\n"
257
-    pageContent += "    <div class=\"arrow-right\"></div>\n"
258
-    pageContent += "  </div><!-- /column colRight -->\n"
259
-    pageContent += "</div>\n"
260
-    pageContent += "\n"
261
-    cpt += 1
262
-
263
-  pageContent += "</div><!-- /row -->\n"
264
-  return pageContent
265
-
266
-def getManganeloTV(url):
267
-  global opacity
268
-  debug("getManganeloTV :"+url)
269
-  r = requests.get(url, allow_redirects=True)
270
-  content = r.text
271
-  
272
-  isMangakakalot = 0
273
-  #print(r.text)
274
-  lineNextChapter = None
275
-  linePreviousChapter = None
276
-  lineTitle = None
277
-  linkNext = None
278
-  linkPrev = None
279
-  listImages = []
280
-  for line in content.split("\n"):
281
-    if "navi-change-chapter-btn-prev a-h" in line and linePreviousChapter is None:
282
-      linePreviousChapter = line
283
-    elif "navi-change-chapter-btn-next a-h" in line and lineNextChapter is None:
284
-      print("Found at"+str(line))
285
-      lineNextChapter = line
286
-
287
-    elif "<meta property=\"og:title\" content=\"" in line and lineTitle is None:
288
-      lineTitle = line
289
-
290
-    elif isMangakakalot == 1 and "<div class='btn-navigation-chap'>" in line and lineNextChapter is None and linkNext is None:
291
-      for subLine in line.split("><"):
292
-        if "NEXT CHAPTER" in subLine:
293
-          linkNext=subLine.split("'")[1]
294
-    elif isMangakakalot == 1 and "<div class='btn-navigation-chap'>" in line and linePreviousChapter is None and linkPrev is None:
295
-      for subLine in line.split("><"):
296
-        if "PREV CHAPTER" in subLine:
297
-          linkPrev=subLine.split("'")[1]
298
-
299
-    elif "<img class=\"img-loading\" data-src=\"" in line:
300
-      if ".jpg" in line:
301
-        listImages.append(line.split("\"")[3])    
302
-  if None is not linkNext:
303
-    print("NEXT :"+linkNext)
304
-  if None is not linkPrev:
305
-    print("PREV :"+linkPrev)
306
-
307
-  if 0 == len(listImages):
308
-    # Attempt to extract images once more, most likely all are on one line
309
-    for line in content.split("\n"):
310
-      if " page " in line:
311
-        for subLine in line.split("><"):
312
-          if "https://" in subLine:
313
-            if ".jpg" in subLine.split("\"")[1]:
314
-              listImages.append(subLine.split("\"")[1])
315
-
316
-  if None is not linePreviousChapter:
317
-    say("Prev :"+str(len(linePreviousChapter)))
318
-    #i.e First chapter is opened
319
-    if 200 < len(linePreviousChapter):
320
-      tempLine = linePreviousChapter 
321
-      linePreviousChapter = None
322
-      for line in tempLine.split("><"):
323
-        if "navi-change-chapter-btn-prev a-h" in line and linePreviousChapter is None:
324
-          linePreviousChapter = line
325
-      linkPrev=linePreviousChapter.split("\"")[5]
326
-    else:
327
-      linkPrev="https://manganelo.tv"+linePreviousChapter.split("\"")[5]
328
-
329
-  if None is not lineNextChapter:
330
-    #i.e Last chapter is opened
331
-    say("Next :"+str(len(lineNextChapter)))
332
-    if 200 < len(lineNextChapter):
333
-      tempLine = lineNextChapter 
334
-      lineNextChapter = None
335
-      for line in tempLine.split("><"):
336
-        if "navi-change-chapter-btn-next a-h" in line and lineNextChapter is None:
337
-          lineNextChapter = line
338
-      linkNext=lineNextChapter.split("\"")[5]
339
-    else:
340
-      linkNext="https://manganelo.tv"+lineNextChapter.split("\"")[5]
341
-        
342
-  mangaImagesNum = len(listImages)
343
-  mangaTitle=lineTitle.split("\"")[3].split(" - Manganelo")[0]
344
-  say("Manga :"+mangaTitle)
345
-  pageContent = ""
346
-  pageContent += "<div class=\"mangaChapNavig\">\n"
347
-  pageContent += "  <div class=\"mangaTitle\">"+mangaTitle+"</div>\n"
348
-  if linkPrev is not None:
349
-    #pageContent += "  <div class=\"mangaChapNavigPrev\"><a href=\"?url="+linkPrev+"\"><div class=\"arrow-left\"></div><div class=\"arrow-left\"></div></a></div>\n"
350
-    pageContent += "  <div class=\"mangaChapNavigPrev\" onclick=\"onChapterPrev();\"><div class=\"arrow-left\"></div><div class=\"arrow-left\"></div></a></div>\n"
351
-    pageContent += "  <div id=\"chapterPrevious\" style=\"display: none;\">"+linkPrev+"</div>\n"
352
-  if linkNext is not None:
353
-    #pageContent += "  <div class=\"mangaChapNavigNext\"><a href=\"?url="+linkNext+"\"><div class=\"arrow-right\"></div><div class=\"arrow-right\"></div></a></div>\n"
354
-    pageContent += "  <div class=\"mangaChapNavigNext\"  onclick=\"onChapterNext();\"><div class=\"arrow-right\"></div><div class=\"arrow-right\"></div></a></div>\n"
355
-    pageContent += "  <div id=\"chapterNext\" style=\"display: none;\">"+linkNext+"</div>\n"
356
-  pageContent += "  <div class=\"mangaChapNavigHome\"><a href=\".\"><div class=\"arrow-up\"></div></a></div>\n"
357
-  pageContent += "  <span id=\"mangaCurrPage\"></span><span id=\"mangaNumPages\"> / "+str(mangaImagesNum)+"</span>\n"
358
-  pageContent += "  <span id=\"mangaFSStatus\" style=\"display: none;\">0</span>\n"
359
-  pageContent += "  <span id=\"mangaFSToggle\" onclick=\"openFullscreen();\"><div class=\"fs-on\"></div></span>\n"
360
-  if opacity == -1:
361
-    opacityValue=2;
362
-    if 7 <= datetime.datetime.now().hour and 20 >= datetime.datetime.now().hour:
363
-      opacityValue=10;
364
-    opacity=opacityValue
365
-  pageContent += "  <span id=\"mangaOpacityMinus\" onclick=\"onOpacityMinus()\">&#9788;</span>"
366
-  pageContent += "  <span id=\"mangaOpacityValue\">"+str(opacity)+"</span>"
367
-  pageContent += "  <span id=\"mangaOpacityPlus\" onclick=\"onOpacityPlus()\">&#9728;</span>\n"
368
-  pageContent += "  <span id=\"mangaReload\" onClick=\"window.location.reload();\"><div class=\"reload-circle\"></div></span>\n" 
369
-  pageContent += "</div>\n"
370
-  
371
-  pageContent += "<a name=\"article-top\"></a><div id=\"article-current\"></div>\n"
372
-  pageContent += "<div class=\"row\">\n\n"
373
-
374
-  cpt = 0
375
-  for pageImage in listImages:
376
-    #debug(pageImage)
377
-    pageContent += "<div class=\"article\" id=\"article-"+str(cpt)+"\" style=\"display: none;\">\n"
378
-    pageContent += "  <div class=\"column\" id=\"colLeft\" onclick=\"onArticle("+str(cpt-1)+")\">\n"
379
-    pageContent += "    <div class=\"arrow-left\"></div>\n"
380
-    pageContent += "  </div><!-- /column colLeft -->\n"
381
-        
382
-    pageContent += "  <div class=\"column\" id=\"colMiddle\">\n"
383
-    pageContent += "    <a name=\"article-"+str(cpt)+"\">\n"
384
-    pageContent += "    <img src=\"defer.png\" data-src=\""+pageImage+"\" class=\"center\">\n"
385
-    #pageContent += "    <li>"+str(cpt)+" : "+pageImage+"</li>\n"
386
-    pageContent += "  </div><!-- /column colMiddle -->\n\n"
387
-    
388
-    pageContent += "  <div class=\"column\" id=\"colRight\" onclick=\"onArticle("+str(cpt+1)+")\">\n"
389
-    pageContent += "    <div class=\"arrow-right\"></div>\n"
390
-    pageContent += "  </div><!-- /column colRight -->\n"
391
-    pageContent += "</div>\n"
392
-    pageContent += "\n"
393
-    cpt += 1
394
-
395
-  pageContent += "</div><!-- /row -->\n"
396
-  return pageContent
397 21
 
398 22
 class MyServer(BaseHTTPRequestHandler):
399 23
     def log_message(self, format, *args):
400 24
         # To silence the default output of server (too verbose)
401 25
         return  
402 26
     def do_GET(self):
403
-        global opacity
404
-        global pageJump
405 27
         global csvFilename
406 28
         global csvFilenameTemp
407 29
         global connectionResults
... ...
@@ -473,17 +95,7 @@ class MyServer(BaseHTTPRequestHandler):
473 95
             #    data_page += "<xmp>"+json.dumps(urlArgs)+"</xmp>\n"
474 96
 
475 97
             if not url is None:
476
-                if "manganelo" in url:
477
-                    data_page += getManganeloTV(url)
478
-                elif "readmanganato.com" in url:
479
-                    data_page += getReadManganatoCOM(url)
480
-                elif "mangakakalot.com" in url:
481
-                    data_page += getMangakakalotCom(url)
482
-                else:
483
-                    warn("Unsupported Hoster at "+url)
484
-                    data_page += "<span id=\"lbl\">Unsupported hoster at "+url+"</span>"
485
-                    data_page += "<div class=\"mangaChapNavigHome\"><a href=\".\"><div class=\"arrow-up\"></div></a></div>"
486
-
98
+                data_page = mangaParser.readManga(url,opacity,pageJump)
487 99
             else:
488 100
                 try:
489 101
                     with open(server['favorite'], "rt") as f: