quite a lot of changes. Fake UA

This commit is contained in:
nihilazo 2019-02-20 11:33:36 +00:00
parent f4fbe82327
commit f15322c85e
2 changed files with 8 additions and 3 deletions

View File

@ -1,14 +1,17 @@
import requests
import tempfile
import shutil
import json
import zipfile
import os
from concurrent.futures import ThreadPoolExecutor
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36"}
def get_chapters(manga_id, language, group, chapter_range):
api_url = "https://mangadex.org/api/manga/" + manga_id
r = requests.get(api_url)
r = requests.get(api_url, headers=headers)
data = r.json()
chapters = data['chapter'].items()
@ -27,7 +30,7 @@ def get_chapters(manga_id, language, group, chapter_range):
def save_page(page):
print("Downloading page " + str(page['index'] + 1))
response = requests.get(page['url'], stream=True)
response = requests.get(page['url'], stream=True, headers=headers)
filetitle = os.path.join(page['dir'], str(page['index']) + "." + page['url'].split('.')[-1:][0])
with open(filetitle, 'wb') as out_file:
shutil.copyfileobj(response.raw, out_file)
@ -36,7 +39,8 @@ def save_page(page):
def save_chapter(chapter_id):
pages_dir = tempfile.mkdtemp()
api_url = "https://mangadex.org/api/chapter/" + chapter_id
r = requests.get(api_url)
print(api_url)
r = requests.get(api_url, headers=headers)
data = r.json()
pages = []

1
yams
View File

@ -24,6 +24,7 @@ if args.output != None:
for t in range(len(split_url)):
if split_url[t] == "chapter":
print(split_url[t+1])
mangadex.save_chapter(split_url[t+1])
if split_url[t] == "title":
g = mangadex.get_chapters(split_url[t+1], args.language, args.group, crange)