Skip to content
Browse files

handled new mangafox url without volume

  • Loading branch information...
1 parent 172504d commit 21d018c6c4851689c1a89cab6f0536af6c988dc6 @sugree committed May 7, 2012
Showing with 48 additions and 7 deletions.
  1. +48 −7 mangafox.py
View
55 mangafox.py
@@ -3,6 +3,7 @@
from __future__ import print_function
import re
+import os
from manga import Manga, App
@@ -15,21 +16,33 @@ class MangaFox(Manga):
CHAPTER_PATTERN = '%(series)s-v%(volume)02d-c%(chapter)s.cbz'
PAGE_PATTERN = '%(series)s-v%(volume)02d-c%(chapter)s-%(page)02d'
- CHAPTER_CRE = re.compile(r'/manga/[^/]+/v(\d+)/c([0-9.]+)/')
+ CHAPTER_CRE_1 = re.compile(r'/manga/[^/]+/v(\d+)/c([0-9.]+)/')
+ CHAPTER_CRE_2 = re.compile(r'/manga/[^/]+/c([0-9.]+)/')
+
+ NV_CHAPTER_URL = '%(baseurl)s/manga/%(series)s/c%(chapter)s/'
+ NV_PAGE_URL = '%(baseurl)s/manga/%(series)s/c%(chapter)s/%(page)d.html'
+
+ NV_CHAPTER_PATTERN = '%(series)s-c%(chapter)s.cbz'
+ NV_PAGE_PATTERN = '%(series)s-c%(chapter)s-%(page)02d'
def __init__(self):
- Manga.__init__(self, 'http://www.mangafox.com')
+# Manga.__init__(self, 'http://www.mangafox.com')
+ Manga.__init__(self, 'http://mangafox.me')
def _list_chapters(self, doc):
chapters = []
for l in doc.xpath("//div[@id='chapters']/ul[@class='chlist']/li/div//a[@class='tips']"):
u = l.attrib['href']
- m = self.CHAPTER_CRE.search(u)
- if not m:
- print('unsupported url', u)
+ m = self.CHAPTER_CRE_1.search(u)
+ if m:
+ chapters.append({'volume': int(m.group(1)),
+ 'chapter': m.group(2)})
continue
- chapters.append({'volume': int(m.group(1)),
- 'chapter': m.group(2)})
+ m = self.CHAPTER_CRE_2.search(u)
+ if m:
+ chapters.append({'chapter': m.group(1)})
+ continue
+ print('unsupported url', u)
return chapters
def _list_pages(self, doc):
@@ -42,6 +55,34 @@ def _download_page(self, doc):
url = doc.xpath("//img[@id='image']")[0].attrib['src']
return url
+ def get_chapter_url(self, data):
+ if 'volume' in data:
+ return Manga.get_chapter_url(self, data)
+ d = data
+ d.update({'baseurl': self.baseurl})
+ return self.NV_CHAPTER_URL % d
+
+ def get_page_url(self, data):
+ if 'volume' in data:
+ return Manga.get_page_url(self, data)
+ d = data
+ d.update({'baseurl': self.baseurl})
+ return self.NV_PAGE_URL % d
+
+ def get_chapter_filename(self, data):
+ if 'volume' in data:
+ return Manga.get_chapter_filename(self, data)
+ d = data
+ d.update({'baseurl': self.baseurl})
+ return os.path.join(data['series'], self.NV_CHAPTER_PATTERN % d)
+
+ def get_page_filename(self, data):
+ if 'volume' in data:
+ return Manga.get_page_filename(self, data)
+ d = data
+ d.update({'baseurl': self.baseurl})
+ return os.path.join(data['series'], self.NV_PAGE_PATTERN % d)
+
class MangaFoxApp(App):
def __init__(self):
App.__init__(self, chapter_func=str)

0 comments on commit 21d018c

Please sign in to comment.
Something went wrong with that request. Please try again.