Skip to content

Commit 3b0989a

Browse files
committed
prepared package collect and prepare final
1 parent 11e3789 commit 3b0989a

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/bplusplus/collect_and_prepare.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,29 +107,24 @@ def collect_and_prepare(group_by_key: Group, search_parameters: dict[str, Any],
107107
__count_classes_and_output_table(output_directory, output_directory / 'class_idx.txt' )
108108

109109
def __download_file_from_google_drive(drive_url, destination):
110-
# Extract the file ID from the Google Drive URL
111110
file_id = drive_url.split('/d/')[1].split('/')[0]
112111
URL = "https://drive.google.com/uc?export=download"
113112

114-
# Send a request to Google Drive to start the file download
115113
with requests.Session() as session:
116114
response = session.get(URL, params={'id': file_id}, stream=True)
117115

118-
# Get confirmation token if required (for large files)
119116
token = None
120117
for key, value in response.cookies.items():
121118
if key.startswith('download_warning'):
122119
token = value
123120

124121
if token:
125-
# Reattempt download with confirmation token
126122
response = session.get(URL, params={'id': file_id, 'confirm': token}, stream=True)
127123

128-
# Save the file content
129124
CHUNK_SIZE = 32768
130125
with open(destination, "wb") as f:
131126
for chunk in response.iter_content(CHUNK_SIZE):
132-
if chunk: # Filter out keep-alive new chunks
127+
if chunk:
133128
f.write(chunk)
134129

135130
print(f"File downloaded successfully and saved at: {destination}")

0 commit comments

Comments
 (0)