Skip to content

Commit

Permalink
[fallenangels] update to new domain and site-layout
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Apr 9, 2017
1 parent cf79a47 commit fece09d
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 16 deletions.
63 changes: 48 additions & 15 deletions gallery_dl/extractor/fallenangels.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,55 @@
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.

"""Extract manga-chapters from http://famatg.com/"""
"""Extract manga-chapters from https://fascans.com/"""

from . import foolslide
from .common import Extractor, Message
from .. import text
import json


class FallenangelsChapterExtractor(foolslide.FoolslideChapterExtractor):
"""Extractor for manga-chapters from famatg.com"""
class FallenangelsChapterExtractor(Extractor):
"""Extractor for manga-chapters from fascans.com"""
category = "fallenangels"
pattern = foolslide.chapter_pattern(r"(?:manga|truyen)\.famatg\.com")
test = [
("http://manga.famatg.com/read/chronos_ruler/en/0/20/", {
"url": "a777f93533674744b74c9b57c7dfa7254f5ddbed",
"keyword": "76e7130a64d96317e3e4dcd55d770c9f6d9cb71d",
}),
("https://truyen.famatg.com/read/madan_no_ou_to_vanadis/vi/0/33/", {
"url": "b46bf1ef0537c3ce42bf2b9e4b62ace41c2299cd",
"keyword": "658cdbecd3a1698f5462c1db437b423b6bcf7dd3",
}),
]
subcategory = "chapter"
directory_fmt = ["{category}", "{manga}", "{chapter:>03} - {title}"]
filename_fmt = "{manga}_{chapter:>03}_{page:>03}.{extension}"
pattern = [r"(?:https?://)?manga\.fascans\.com/manga/([^/]+)/(\d+)"]
test = [("https://manga.fascans.com/manga/chronos-ruler/20/1", {
"url": "4604a7914566cc2da0ff789aa178e2d1c8c241e3",
"keyword": "b2b9c7fd4696b9369d230c3069b5333b476f35d6",
})]

def __init__(self, match):
Extractor.__init__(self)
self.manga, self.chapter = match.groups()

def items(self):
url = "https://manga.fascans.com/manga/{}/{}/1".format(
self.manga, self.chapter)
page = self.request(url).text
data = self.get_metadata(page)
imgs = self.get_images(page)
data["count"] = len(imgs)
yield Message.Version, 1
yield Message.Directory, data
for data["page"], img in enumerate(imgs, 1):
url = img["page_image"]
yield Message.Url, url, text.nameext_from_url(url, data)

def get_metadata(self, page):
"""Collect metadata for extractor-job"""
data = {
"chapter": self.chapter,
"lang": "en",
"language": "English",
}
return text.extract_all(page, (
("manga", 'name="description" content="', ' Chapter '),
("title", ': ', ' - Page 1'),
), values=data)[0]

@staticmethod
def get_images(page):
"""Return a list of all images in this chapter"""
return json.loads(text.extract(page, "var pages = ", ";")[0])
7 changes: 6 additions & 1 deletion test/test_extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,13 @@ def test(self):
return test


skip = [
# dont work on travis-ci
"exhentai", "kissmanga", "mangafox", "dynastyscans",
# temporary issues
"mangashare",
]
# enable selective testing for direct calls
skip = ["exhentai", "kissmanga", "mangafox", "mangashare", "fallenangels"]
if __name__ == '__main__' and len(sys.argv) > 1:
extractors = [
extr for extr in extractor.extractors()
Expand Down

0 comments on commit fece09d

Please sign in to comment.