Skip to content

Commit

Permalink
add user-agent
Browse files Browse the repository at this point in the history
  • Loading branch information
WasinUddy authored Oct 4, 2024
1 parent e713524 commit bff0824
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions scripts/download_minecraft_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@ def main():
# Load versions file
with open(f"versions/{args.type}.txt", 'r') as f:
version = f.read().strip()


# Set URL
url = f"https://www.minecraft.net/bedrockdedicatedserver/bin-linux{'' if args.type=='stable' else '-preview'}/bedrock-server-{version}.zip"

# Custom User-Agent to mimic a browser request
headers = {
"User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36'
}

# Download and extract server
print(f"Downloading {url}...")
response = requests.get(url)
response = requests.get(url, headers=headers)
response.raise_for_status()

print("Extracting...")
Expand All @@ -36,9 +40,7 @@ def main():

print("Cleaning up...")


print("Done.")


if __name__ == "__main__":
main()

0 comments on commit bff0824

Please sign in to comment.