Skip to content

Commit

Permalink
Merge pull request #3 from surfer190/new_layout
Browse files Browse the repository at this point in the history
New layout
  • Loading branch information
surfer190 authored Sep 16, 2023
2 parents 66e17fa + 9d6591d commit 695be01
Show file tree
Hide file tree
Showing 7 changed files with 591 additions and 353 deletions.
60 changes: 60 additions & 0 deletions download.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
"""
1. Give the user a list of releases to download
2. User selects
3. By default download all
"""
import csv
import pathlib
import sys

import httpx

DOWNLOAD_DIR = pathlib.Path(__file__).parent / "downloads"

client = httpx.Client(headers={"user-agent": "lofigirl-downloader/0.2.0"})


def download_file(file_href):

# Stream the download
# with client.stream("GET", file_href) as reader:
# for data in reader.iter_bytes():
# print(data)

file_name_with_extension = file_href.split("/")[-1]

file_path = DOWNLOAD_DIR / file_name_with_extension

# check if zip already exists
if pathlib.Path(file_path).is_file():
print(f"File exists: {file_path}")
return

file_response = client.get(file_href)

if file_response.status_code == httpx.codes.OK:
content_type = file_response.headers.get("content-type")
content_disposition = file_response.headers.get("content-disposition")

if content_type == "application/zip":
extension = "zip"
else:
print(
f"Unexpected file extension '{content_type}' for {content_disposition}"
)
sys.exit(1)

with open(file_path, "wb") as current_file:
current_file.write(file_response.content)
print(f"Completed: {file_href}")


if __name__ == "__main__":
with open("releases.csv", newline="", encoding='utf-8') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
artists = row.get("artists")
title = row.get("title")
link = row.get("link")

download_file(link)
249 changes: 0 additions & 249 deletions download_releases.py

This file was deleted.

Loading

0 comments on commit 695be01

Please sign in to comment.