Skip to content

Instantly share code, notes, and snippets.

@layou233
Created August 28, 2021 10:34
Show Gist options
  • Select an option

  • Save layou233/124d87fe7085a18a42124bdfe8db3381 to your computer and use it in GitHub Desktop.

Select an option

Save layou233/124d87fe7085a18a42124bdfe8db3381 to your computer and use it in GitHub Desktop.
Optifine Cape URL Generator
Copyright (c) 2021 layou233
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# Optifine Cape URL Generator
# Made by Github@layou233, Bilibili@贴吧蜡油
#
# THIS IS A FREE SOFTWARE, OPEN SOURCED UNDER MIT LICENSE
# EDUCATION PURPOSE ONLY
#
# Please install Requests package before use.
from webbrowser import open
from json import loads
from requests import post
HEADERS = {
'Content-Type': 'application/json'
}
def authenticate(user, passwd):
data = {
'agent': {
'name': 'Minecraft',
'version': 1
},
'username': user,
'password': passwd
}
# data = '{' + f'''"username":"{user}","password":"{passwd}"''' + '}'
r = post('https://authserver.mojang.com/authenticate',
json=data, headers=HEADERS)
if r.status_code != 200:
print(r.text)
raise ValueError
return loads(r.text)
def join_server(access_token, uuid, server_id):
data = {
'accessToken': access_token,
'selectedProfile': uuid,
'serverId': server_id
}
r = post('https://sessionserver.mojang.com/session/minecraft/join',
json=data, headers=HEADERS)
if r.status_code == 204:
return
raise ValueError
if __name__ == '__main__':
alt = input('Enter your combo: ').split(':', 2)
profile = authenticate(alt[0], alt[1])
print(profile)
if len(profile['availableProfiles']) == 0:
print('Demo account. Exited.')
exit(0)
uuid = profile['selectedProfile']['id']
name = profile['selectedProfile']['name']
join_server(profile['accessToken'], uuid, 'OFCapeMadeByBilibiliAtTieBaLaYou')
url = f'https://optifine.net/capeChange?u={uuid}&n={name}&s=OFCapeMadeByBilibiliAtTieBaLaYou'
print('Successfully generated your Optifine Cape URL:\n', url)
input('\nPress the Enter to open this link in your browser.')
open(url)
input('Press the Enter to exit.')
@Arr42
Copy link

Arr42 commented Jul 9, 2025

Generator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment