Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix broken link #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions src/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import json
import time
import requests
import shutil


logging.basicConfig()
Expand Down Expand Up @@ -479,29 +480,18 @@ class PreprocessArguments:

# Mirrors for database
MIRRORS = [
'https://sponsor.ajay.app/database/sponsorTimes.csv', # Latest
'https://sb-mirror.mchang.xyz/sponsorTimes.csv', # 5 minute delay
'https://sb.ltn.fi/database/sponsorTimes.csv', # 5 minute delay
]
# TODO only download latest updates/changes



def download_file(url, filename):
"""
Helper method handling downloading large files from `url` to `filename`.
with requests.get(url, stream=True) as r:
with open(filename, 'wb') as f:
shutil.copyfileobj(r.raw, f)

Adapted from https://stackoverflow.com/a/42071418
"""
chunk_size = 1024
r = requests.get(url, stream=True)
total_bytes = int(r.headers['Content-Length'])
with open(filename, 'wb') as f, tqdm(unit='B', total=total_bytes) as progress:
for chunk in r.iter_content(chunk_size=chunk_size):
if chunk: # filter out keep-alive new chunks
progress.update(len(chunk))
f.write(chunk)

return total_bytes == os.path.getsize(filename)
return filename


def main():
Expand Down