|
|
@@ -3,13 +3,14 @@ import re |
|
|
|
|
|
|
|
import requests |
|
|
|
|
|
|
|
import constants |
|
|
|
import time_methods |
|
|
|
from file_io import * |
|
|
|
from file_io import generate_json_path |
|
|
|
from json_methods import extract_filenames |
|
|
|
|
|
|
|
|
|
|
|
user_agent = 'https://git.teknik.io/abrax/lizard' |
|
|
|
|
|
|
|
|
|
|
|
def fetch_and_parse_thread_json(board, thread_no): |
|
|
|
url = generate_thread_json_url(board, thread_no) |
|
|
|
p = generate_json_path(board, thread_no) |
|
|
@@ -60,7 +61,7 @@ def download_file(file_url, file_path): |
|
|
|
""" If the request succeeds, downloads the file and returns True. |
|
|
|
|
|
|
|
On a 404, returns False. On other responses, raises exception. """ |
|
|
|
r = requests.get(file_url, headers={'user-agent': constants.user_agent}) |
|
|
|
r = requests.get(file_url, headers={'user-agent': user_agent}) |
|
|
|
|
|
|
|
if r.status_code == requests.codes.ok: |
|
|
|
save_file(file_path, r.content) |